Tutorial by Examples

// Returns the nth number in the Fibonacci sequence function fibonacci(n) { if (n === 1 || n === 0) { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } }
// Checks a string to see if it is a palindrome bool function IsPalindrome(string input) { if (input.size() <= 1) { return true; } else if (input[0] == input[input.size() - 1]) { return IsPalindrome(input.substr(1,input.size() - 2)); } else { r...
var directories = [ {name: 'users' , parent : null }, {name: 'distalx' , parent : 'users' }, {name: 'guest' , parent : 'users' }, {name: 'shared' , parent : 'users' }, {name: 'documents' , parent : 'distalx' }, {name: 'music' , parent : 'distalx' }, {name: 'desktop' , parent : '...
Structure for Binary Search Tree (BST) nodes: struct node { int data; node * left; node * right; } Search Algorithm // Check if a value exists in the tree bool BSTSearch(node * current, int value) { if (current->data == value) { return true; } e...
function getCombinations(params, combinationsResults){ if(params.length == 0) return combinationsResults; var head = params[0]; var tail = params.slice(1); var combinationsResultsCurrent = []; if(Array.isArray(head)){ _.uniq(head).forEach(function(item){ ...

Page 1 of 1