Welcome Guest

Questions for A

Rate the Questions

Rating: 1.5/5

Q. No. : 1
Question :Given an array of integers.....
Imagine it as a pyramid as below:

2 3
4 5 6
7 8 9 10
find a path from level 1 to last level such that the sum is maximum.... The path is such that its children should be reachable.
1,2,5,9 is a path
1,2,6,10 is not a path since 6 is not reachable from 2.
The array is not sorted and numbers are random.
Solution Discuss
Q. No. : 2
Question :A n-tree where each node contains any no of nodes. Print the nodes in level order and each level must contain a line with a gap
Solution Discuss
Q. No. : 3
Question :Write a program to arrange numbers from 1 to 16 such that the sum of two consecutive numbers is a perfect square
Solution Discuss
Q. No. : 4
Question :If you have a N steps staircase and you are standing at 1 step now you have options to step up to 2step or you can skip one step and go to 3rd step... so at ith step you have a option to go to i+1 step or i+2 step. So how many ways you can climb the stairs?
Solution Discuss
Q. No. : 5
Question :In a sequence of integers, find the max length increasing order subsequence.
Solution Discuss
Q. No. : 6
Question :Given a binary tree, find a path (from root to a leaf) which gives maximum value by adding values of nodes.
Solution Discuss
Q. No. : 7
Question :How will you find the page with most incoming links from billions of web-pages
Solution Discuss
Q. No. : 8
Question :You have millions of documents numbered 1,2,3,4,5 ......
You also have a mapping from a word to the list of documents that contains it

Find all the 'pair of words' that occur together in one and only document
Solution Discuss
Q. No. : 9
Question :Given n number of points in space and a point P, find 3 nearest point to p.
Solution Discuss
Q. No. : 10
Question :Write C code to find maximum and second maximum in an array
Solution Discuss
Q. No. : 11
Question :

For a given matrix NxN having 0 or 1’s only. You have to find the count of rows and columns where atleast one 1 occurs.


0 0 0 0

1 0 0 1

1 0 0 1

1 1 0 1

Row count having 1 atleast once: 3

Col count having 1 atleast once: 3
Solution Discuss
Q. No. : 12
Question :You are provided with a max heap of 'n' elements with a number 'x' and 'k'...You have to find whether 'k' elements in heap are greater than 'x' or not??
Time Complexity should be O(k)
Solution Discuss
Q. No. : 13
Question :

int main()
printf("BOOM \n");
return 0;

How many BOOMs will be printed ?
Solution Discuss
Q. No. : 14
Question :Three 1x1 squares are taken on a 8x8 chess board.

1. What is the probablity, that all three squares are diagonal to each other ?

2.What is the probability, that all three squares are diagonal to each other and lie adjacent.
Solution Discuss
Q. No. : 15
Question :

Given a binary tree and a node, print all the ancestors of that node.

/ \
4 5
/ \ / \
2 3 7 8

print all the ancestors of 7 ans:1 5 7
Solution Discuss
Q. No. : 16
Question :What is the difference between mutex and binary semaphore?
Solution Discuss
Q. No. : 17
Question :ind the two nodes in Binary Tree which have longest distance between them.

Should return I & C for following tree

/ \
/ \
/ \
Solution Discuss
Q. No. : 18
Question :Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers
Solution Discuss
Q. No. : 19
Question :Given a set of 1 Trillion integers on hard disk, find the smallest 1 million of them. You can fit at most 1 million integers in memory at a time. State the fastest solution you can think of
Solution Discuss
Q. No. : 20
Question :Given a graph's shortest path algorithm, how can you make use of it to find the second shortest path?
Solution Discuss
Q. No. : 21
Question :Given any number say 12, find the next multiple of 8 eg 16 using bit-wise manipulations.?
Solution Discuss
Q. No. : 22
Question :Write a generic macro swap which can be used for any data types like integer, float, pointer.
Solution Discuss
Q. No. : 23
Question :An n-ary tree has n nodes in each internal nodes. Find the no of leaf nodes in such a tree with N nodes?
Solution Discuss
Q. No. : 24
Question :Write a function F(x, p, n, y) such that it returns x with the n bits that begin at position p (from LSB) set to the rightmost n bits of y.

Do not change other bits. Both x and y are unsigned integers.
Solution Discuss
Q. No. : 25
Question :Find the maximum of three integers using conditional operator ?
Solution Discuss
Q. No. : 26
Question :Write a function to find out longest palindrome in a given string.
Solution Discuss
Q. No. : 27
Question :There are N nuts and N bolts, all unique pairs od Nut and Bolt
You cant compare Nut with Nut.
You cant compare Bolt with Bolt
You CAN compare Nut with Bolt
Now how would you figure out matching pairs of nut and bolt from the given N nut and Bolt.
The basic soln is O(N^2). Give O(NlogN soln)
Solution Discuss
Q. No. : 28
Question :A square Island surrounded by bigger square, and in between there is infinite depth water. The distance between them is L. The wooden blocks of L are given.
The L length block can't be placed in between to cross it, as it will fall in water (just fitting).
How would you cross using these L length blocks.
Solution Discuss
Q. No. : 29
Question :Two integers A and B are given, find the no of bits that need to be flipped in A to get B
Solution Discuss
Q. No. : 30
Question :A C program that prints itself.
Solution Discuss
Q. No. : 31
Question :Difference between malloc and calloc
Solution Discuss
Q. No. : 32
Question :How would you dynamically allocate 2D array? Use 2 malloc() and then do the same thing using only 1 malloc().
Solution Discuss
Q. No. : 33
Question :Find out if 2 given binary trees are identical (data is same in both trees)
Solution Discuss
Q. No. : 34
Question :Merge 2 sorted arrays in constant space and minimum time complexity.
Solution Discuss
Q. No. : 35
Question :What is the difference between these two statements
void (*p) (void *a[],int n)
void *(*p[]) (void *a, int n)
Solution Discuss
Q. No. : 36
Question :Write an algorithm to print a binary tree level wise and that too from leaves to root. Also only one queue and one stack can be used for the purpose.
Solution Discuss
Q. No. : 37
Question :You are given a lot of cuboid boxes with different length, breadth and height. You need to find the maximum subset which can fit into each other.

For example:
If Box A has LBH as 7 8 9
If Box B has LBH as 5 6 8
If Box C has LBH as 5 8 7
If Box D has LBH as 4 4 4

then answer is A,B,D

A box can fit into another only and only if all dimensions of that is less than the bigger box. Also Rotation of boxes is not possible.
Solution Discuss
Q. No. : 38
Question :Given a binary matrix, find out the maximum size rectangular sub-matrix with all 1

consider the below binary matrix.

0 1 1 0 0
1 1 0 1 0
1 1 1 1 1
1 1 1 1 1
1 1 1 1 0
0 0 0 0 0

Then the result should be

1 1 1 1 1
1 1 1 1 1
Solution Discuss
Q. No. : 39
Question :What is the difference between >> and >>> in java?
Solution Discuss
Q. No. : 40
Question :What is transient variable in java?
Solution Discuss
Q. No. : 41
Question :What is better Inheritance or Composition and why ?
Solution Discuss
Q. No. : 42
Question :What is wrong with this formula to convert from Celsius to Fahrenheit

degF = 5/9*(c+32)
Solution Discuss
Q. No. : 43
Question :Find the transpose of a square matrix using recursion
Solution Discuss
Q. No. : 44
Question :Convert a binary search tree to a sorted doubly linked list in-place.
Solution Discuss
Q. No. : 45
Question :Find the depth of a binary tree.
Solution Discuss
Q. No. : 46
Question :Find the next number for a given number without using any arithmetic operators(use bit operations)
Solution Discuss
Q. No. : 47
Question :Given a stack S, write a C program to sort the stack (in ascending order).
You are not allowed to make any assumptions about how the stack is implemented; the only
functions allowed to be used are: Push, Pop, Top, IsEmpty, IsFull.
Solution Discuss
Q. No. : 48
Question :There is a sequence of increasing numbers that have the same number of binary 1s in them. Given n, the number of 1 bits set in each number, write an algorithm
or C program to find the nth number in the series
Solution Discuss
Q. No. : 49
Question :You are given have a datatype, say X in C. Determine the size of the datatype,
without declaring a variable or a pointer variable of that type, and, of course without using the sizeof operator
Solution Discuss
Q. No. : 50
Question :Given two sets, Write a function to provide the union of them.
Solution Discuss
Q. No. : 51
Question :You have m nuts and n bolts, Every unique nut is fit in every unique bolt, Suggest an effective algorithm for placing each nut in each bolt in less no. of passes?
Solution Discuss
Q. No. : 52
Question :Write a program in C to store details of 100 books of a library where
each record contains booknumber, book name, bookauthor, publisher,
number of copies,unit cost.
Read the data from an external file.
Implement insertion of new record
Deletion of existing record
modification of existing record
Find the total worth of the library.
Q. No. : 53
Question :There are four dogs, each at the counter of a large square. Each of the dogs begins chasing the dog clockwise from it. All of the dogs run at the same speed. All continuously adjust their direction so that they are always heading straight towards their clockwise neighbor. How long does it take for the dogs to catch each other? Where does this happen? (Hint: Dog’s are moving in a symmetrical fashion, not along the edges of the square).
Solution Discuss
Q. No. : 54
Question :Algorithm to partition set of numbers into two such that difference between their sum is min and they have equal number of elements?
Solution Discuss
Q. No. : 55
Question :How to call a C++ function which is compiled with C++ compiler in C code?
Solution Discuss
Q. No. : 56
Question :How do you initialize a static member of a class with return value of some function?
Solution Discuss
Q. No. : 57
Question :If you are given the name of the function at run time how will you invoke the function?
Solution Discuss
Q. No. : 58
Question :How does HTTP works?
Solution Discuss
Q. No. : 59
Question :What is the difference between COM and CORBA?
Solution Discuss
Q. No. : 60
Question :What is web service?
Solution Discuss
Q. No. : 61
Question :Explain the Traveling Salesman problem? What is an NP-complete problem? What is the Hamiltonian cycle problem?
Solution Discuss
Q. No. : 62
Question :Design a data structure such that given a stream of numbers, you can find the maximum of the numbers at any point and also all the numbers.
Solution Discuss
Q. No. : 63
Question :Design an algorithm and write code to find the common ancestor of two nodes in a tree.
Solution Discuss
Q. No. : 64
Question :Reverse Each K element in Link List .
Solution Discuss
Q. No. : 65
Question :How to find the smallest element in rotated sorted array?

Input 1: array[]={4,5,6,7,8,9,1,2,3};
Output : position of smallest element means here 6 (array starts from zero).

Input 2: array[]={1,2,3,4,5,6,7,8,9};
Output : position of smallest element means here 0 (array starts from zero).
Solution Discuss
Q. No. : 66
Question :You have been given a linked list of numbers.
The size is not know. You need to find out if the number stored
in the list is a palindrome in the best possible optimized manner.
Solution Discuss
Q. No. : 67
Question :How to find an element in rotated sorted array?
Input 1: array[]={4,5,6,7,8,9,1,2,3}; element=5
Output : position of the element(=5) is 1 (array starts from zero).

Input 2: array[]={1,2,3,4,5,6,7,8,9}; element=7
Output : position of the element(=7) is 6 (array starts from zero).
Solution Discuss
Q. No. : 68
Question :What is "group by"?
Solution Discuss
Q. No. : 69
Question :Swap two numbers without using a temporarily variable.
Solution Discuss
Q. No. : 70
Question :How do you programmatically create & terminate a process on linux
Solution Discuss
Q. No. : 71
Question :write a program that accepts two mandatory arguments without using any built in date or time functions . The first argument is a string "[HH:MM {AM|PM}" and the second argument is an integer Which denotes minutes. The minutes get added to the string. The return value or output of the program should be a string of the same format as the first argument. For example AddMinutes("10:23 AM", 13) would return "10:36 AM
Solution Discuss
Q. No. : 72
Question :Print a singly linked list in reverse order
Solution Discuss
Q. No. : 73
Question :Write me a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function
Solution Discuss
Q. No. : 74
Question :5 6 7 8 8 8 8 8 What is the next number in the series ?
Solution Discuss
Q. No. : 75
Question :Which is faster ++a or a++?
Solution Discuss
Q. No. : 76
Question :What it wrong with this function:
x = new();
delete x;
Solution Discuss
Q. No. : 77
Question :Given 2 squares on a 2 dimensional plane, find a line that would cut these two squares in half.
Solution Discuss
Q. No. : 78
Question :Suppose you have a 100 files in a directory and you need to find out if a keyword occurs in these files. How would you do it in Unix? How would you do it in Windows?
Solution Discuss
Q. No. : 79
Question :Given a cube. A ant is placed in a corner and cannot move. A spider starts from the opposite corner, and can move along cube edges in any direction (x,y,z) with probablity 1/3. What is the expected number of steps for this spider to get to the ant?
Solution Discuss
Q. No. : 80
Question :What is: in-order traversal of tree, quick sort in an array
Q. No. : 81
Question :A duck is in circular pond. The duck wants to swim ashore, because it wants to fly off and this particular duck is not able to start flying from the water. There is also a fox, on the shore. The fox wants to eat the duck, but this particular fox cannot swim, so it can only hope to catch the duck when the duck reaches the shore. The fox can run 4 times faster than the duck can swim. Is there always a way for the duck to escape?
Solution Discuss
Q. No. : 82
Question :Print Fibonacci series in order of log(n).
Solution Discuss
Q. No. : 83
Question :A computer has three registers, A, B and R. It has only three instructions:

A->R : Load R with A

B->R : Load R with B

A-R->A : Subtract R from A and store the result in A

Using these instructions how can you do the follwoing?

B->A : Load A with B
Solution Discuss
Q. No. : 84
Question :Design an inventory tracking system using database tables. Customers, inventory, and orders are tracked.

Then, write a query to find an order when you only have a lastname
Solution Discuss
Q. No. : 85
Question :What is static method? What is a static initializer?
Solution Discuss
Q. No. : 86
Question :Write a method to calculate the acute angle between a clock hour hand and minute hand.
Solution Discuss
Q. No. : 87
Question :Template vs. Inheritance. Why use one over the other?
Solution Discuss
Q. No. : 88
Question :Given a IP address, Validate the IP address. The IP address lies between []-[] .
IP address is in String, hence you can fetch the characters in the string and move ahead.
Solution Discuss
Q. No. : 89
Question :Virtual Functions and its implementation?
Solution Discuss
Q. No. : 90
Question :What’s the difference between these two declarations?
struct str1 { … } ;
typedef struct { … } str2 ;
Solution Discuss
Q. No. : 91
Question :Find the day of the week of a given date?
Solution Discuss