Two elements of complex data types are not directly comparable. Consider the student structure defined as below struct Student { int rollNo; char name[25]; char grade; }; Student arr[MAX_NUM_STUDENTS]; Objects of Student type are not directly comparable. To sort array arr, we need to specify how one student compares with another student. If there are […]

I visit many colleges and universities (mostly technical). Following is my feedback:

Given a pointer to the root node of the tree, write code to find if it is an Almost Complete Binary Tree or not? A Binary Tree of depth d is Almost Complete iff: The tree is Complete Binary Tree (All nodes) till level (d-1). At level d, (i.e the last level), if a Node […]

What improvement has java-8 made that performance of HashMap.get() function call is fast by 20% in Java-8.

It is almost impossible to design a generic hash system without collision. In case of collision, it need to be handled. There are multiple ways of handling collision. Separate chaining is one of such techniques.

You may solve the simple probability, “Given a set of n randomly chosen people, what is the probability of two people having same birthday?” You may also solve, “At least how many people need to be picked to make the probability 100% that at least two of them have same birthday?” Answer to the second question is […]

Let us design a data structure in which we want to store numbers (taking it for simplicity, else it can be anything). We want to minimise the time taken by the following three operations: Insertion, time taken to insert a new value. Deletion, time taken to remove an existing value. Searching, time taken to search […]

Doctor gave you two types of medicine tablets (pils) A and B, and asked you to take one from each daily. The two tablets are in different bottles and look exactly same One day, while taking the pills, you open Bottle-A and tap one pill out in your hand. Then you open the second bottle to […]

Given a binary tree and two values. Find if these values appear in sibling nodes in the tree. For example, if tree is Then 2 and 6 are siblings but 6 and 9 are not siblings (they are cousin nodes).

A valid mathematical expression can also have duplicate parenthesis as shown below: ((a+b)) (((a+(b)))+(c+d)) Write code to find if an expression has duplicate parenthesis. You may assume that expression does not have any white spaces.