Check if parenthesis are matched or not

Write a function that accepts a string of parenthesis ( ‘(‘ and ‘)‘ characters ) and return true if parenthesis are matched and false otherwise […]

Making tree from traversals

Given the pre-order and in-order traversal of a Binary Tree. Construct the tree from these traversals. InOrder: 1 4 5 8 10 30 40 PreOrder: […]

Basic Tree Traversals (Preorder, Inorder, Postorder)

If the node of a Binary tree is defined as below: struct Node{ Node * lptr; // Pointer to Left subtree int data; Node *rptr; […]

Has Path Sum (binary tree)

Given a Binary Tree and a number x, Write a function to see if there exist a root to leaf path in the tree whose sum […]

Counting leaf nodes of a Binary Tree

Write a function to count the leaf nodes of a binary tree.

Checking if a number is fibonacci

By definition first 2 Fibonacci numbers are defined as 0 and 1. nth Fibonacci number can be computed as sum of (n-2)th & (n-1)th Fibonacci […]

Check if a Binary tree is sub-tree of another

Given pointers to the root of two Binary Trees, write code to check if first Binary tree is subtree of second binary tree. The signature […]

infix, prefix & postfix notations (Polish Notations)

What are Infix, Prefix and Postfix notations ?

Computing average of stream of numbers

Given a stream of numbers (keep reading numbers from the keyboard). Write code to print the average at each point. For example: user is entering […]

Delete alternate node of the linked list

Given a linked list. Write code to delete alternate nodes from the list. For example: If the list given is 2 -> 3 -> 5 […]