Welcome Guest

Questions for r

Rate the Questions

Rating: 2.3/5

Q. No. : 1
Question :Print all edge nodes of a complete binary tree anti-clockwise. In other words, print the boundary of the tree.
Solution Discuss
Q. No. : 2
Question :Given an n X n array with rows sorted and cols sorted, find the number of negative elements in most efficient way
Solution Discuss
Q. No. : 3
Question :Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
Solution Discuss
Q. No. : 4
Question :Given an unsigned integer 1345, the program constructs a linked list of 1->3->4->5.
Write the test cases for it.
Solution Discuss
Q. No. : 5
Question :Given two sorted arrays where the size of second array is large enough to hold the first array, write code to merge them (in sorted order). Write test cases
Solution Discuss
Q. No. : 6
Question :Write code to check if a string contains a substring.
Solution Discuss
Q. No. : 7
Question :how would you explain the "computer networks" to a Kindergarden child
Discuss
Q. No. : 8
Question :BFS a binary tree but print the last row in reverse order. Here last row means highest level leaf nodes.
Solution Discuss
Q. No. : 9
Question :Write a function that gets an integer and returns its string representation in Roman numbers.
Solution Discuss
Q. No. : 10
Question :How would you test an elevator?
Solution Discuss
Q. No. : 11
Question :There is a table on which a number of coins are placed. You also know that there are as many coins with Head up as many coins with Tail up. Now you have to divide the coins (number of coins is even) into two equal piles such that number of coins with Heads up and Tails up in either piles be the same. The catch is you are blind folded and you cannot determine the sides (for sure) if you are blinded .
Solution Discuss
Q. No. : 12
Question :Given a M*N matrix A in which all the elements in a row and all the elements in a column are strictly increasing. Find a path from the smallest element (ie A[0][0]) to the largest element (ie A[M-1][N-1]) such that the sum of the elements in the path is maximum. Time Complexity O(m+n). Use efficient space
Solution Discuss
Q. No. : 13
Question :Write a function to check if two strings are anagrams. Write a fuction to find all possible anagrams of a given string. You are given a method isWord() to check if the string is a valid word in a dictionary. Assuming that pre processing can be done what pre processing will u do inorder to speed up the process of finding anagrams.
Solution Discuss
Q. No. : 14
Question :Give examples of cases where you would prefer to pass objects/variables by reference instead of value?
Solution Discuss
Q. No. : 15
Question :Perform Sorted Insert on a link list and write test cases
Solution Discuss
Q. No. : 16
Question :Datastructure and algorithm for undo and redo of a wordprocessor?
Solution Discuss
Q. No. : 17
Question :Write a method that returns all subsets of a set.
Solution Discuss
Q. No. : 18
Question :Write a program to find the mirror image of a n-ary tree( may or may not binary)
Solution Discuss
Q. No. : 19
Question :Given a 2D array / matrix of integers. Write a program to print the elements in spiral order. Consider a matrix as show in the diagram to the right. The desired output of the program should be as: 1,2,3,4,8,12,16,20,19,18,17,13,9,5,6, 7,11,15,14,10.
Solution Discuss
Q. No. : 20
Question :Find an Item in a Sorted Array with Shifted Elements
Solution Discuss
Q. No. : 21
Question :There are two sorted arrays A1 and A2. Array A1 is full where as array A2 is partially empty and number of empty slots are just enough to accommodate all elements of A1. Write a program to merge the two sorted arrays to fill the array A2. You cannot use any additional memory and expected run time is O(n).
Solution Discuss
Q. No. : 22
Question :You are given an array containing positive integers. All the integers occur even number of times except one. Find this special integer.
Solution Discuss
Q. No. : 23
Question :Write a function to perform a binary search on a Sorted Array.
Solution Discuss
Q. No. : 24
Question :Given a singly linked list, find the node in the middle.
Solution Discuss
Q. No. : 25
Question :Given a singly linked list find the n-th node from the back.
Solution Discuss
Q. No. : 26
Question :How would you design the data structures for a very large social network (Facebook, LinkedIn, etc)? Describe how you would design an algorithm to show the connection,
or path, between two people
Solution Discuss
Q. No. : 27
Question :Write the code for producing/printing permutations of the characters in a string. For example: If "abc" is the input string, output permutations should be "abc", "bac", "bca", "acb", "cab", "cba".
Solution Discuss
Q. No. : 28
Question :Imagine you have ten trees to plant. You have to get an orchard
which must consist of five straight rows of trees and each row must
contain four trees. One straight line of ten trees cannot be used.
Thus the question is: what template could be used for the planting?
Solution Discuss
Q. No. : 29
Question :How will you implement pow(a,b) without using multiplication or division operators. You can use only add/substract operators.
Solution Discuss
Q. No. : 30
Question :Implement a queue using 2 stacks
Solution Discuss
Q. No. : 31
Question :Print a singly linked list in reverse order
Solution Discuss
Q. No. : 32
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. : 33
Question :5 6 7 8 8 8 8 8 What is the next number in the series ?
Solution Discuss
Q. No. : 34
Question :Which is faster ++a or a++?
Solution Discuss
Q. No. : 35
Question :What it wrong with this function:
F1(...){
x = new();
F2();
delete x;
}
Solution Discuss
Q. No. : 36
Question :Given 2 squares on a 2 dimensional plane, find a line that would cut these two squares in half.
Solution Discuss
Q. No. : 37
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. : 38
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. : 39
Question :What is: in-order traversal of tree, quick sort in an array
Discuss
Q. No. : 40
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. : 41
Question :Print Fibonacci series in order of log(n).
Solution Discuss
Q. No. : 42
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. : 43
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. : 44
Question :What is static method? What is a static initializer?
Solution Discuss
Q. No. : 45
Question :Write a method to calculate the acute angle between a clock hour hand and minute hand.
Solution Discuss
Q. No. : 46
Question :Template vs. Inheritance. Why use one over the other?
Solution Discuss
Q. No. : 47
Question :Given a IP address, Validate the IP address. The IP address lies between [000.000.000.000]-[255.255.255.255] .
IP address is in String, hence you can fetch the characters in the string and move ahead.
Solution Discuss
Q. No. : 48
Question :Virtual Functions and its implementation?
Solution Discuss
Q. No. : 49
Question :What’s the difference between these two declarations?
struct str1 { … } ;
typedef struct { … } str2 ;
Solution Discuss
Q. No. : 50
Question :Find the day of the week of a given date?
Solution Discuss