Tag Archives: Recursion Programming Questions

Write a program to count nodes in a tree

Approach: Traverse all the nodes in a tree. You can do any traversal and just start counting. But there is a concept called tail recursion which is handy and very easily readable. If you have a tree, if you know the number of nodes in the left and number of nodes in right +1, then, Read More →

Write C code to implement the Binary Search algorithm

Binary search is used to quickly find a value in a sorted sequence.At each step, the algorithm compares the median value in the search space to the target value. Based on the comparison and because the sequence is sorted, it can then eliminate half of the search space. By doing this repeatedly, it will eventually Read More →