Print ancestors of a node in a Binary Tree Node

Given a Binary tree and an integer, print all the ancestors of the node. For example: If the given tree is as below: Input: 5 […]

Reversing words in a String

Given a String, reverse the string but do not reverse the words. For example, if Input : "MCN Professionals is now Ritambhara" Output: "Ritambhara now […]

Level-wise traversal of a binary tree

Write an Algorithm to print the elements of a binary tree in level-wise order. For example if the Binary tree is as given below: Then […]

sorting 1 billion numbers

Which sorting algorithm will you use to sort 1 billion numbers.

Check if number is a power of 2

How will you check if a number if a power of two or not? For example: 4, 8, 1024 etc are powers of two. But […]

Search in a matrix sorted on rows & columns

Given a matrix whose each row and column is sorted as shown below 10 20 30 40 15 25 35 45 27 29 37 48 […]

Traversing a matrix in spiral order

Given a Matrix, write a function that will print the elements in spiral order. For example, if the Matrix is as below: Then the output […]

Delete a linked list

Write a function to delete a linked list. The function should take a pointer to the head of the list and should delete all the […]

Insert in a sorted linked list

Given a linked list, with all the nodes in sorted order. Write a function that inserts a new integer in the sorted manner. i.e If […]

Recursive function to reverse a linked list

Earlier I talked about Reversing a Singly linked list without using recursion. Today let’s write a recursive function to reverse a singly linked list.