Sample Questions 2-1
Sample Questions 2-1
(A) O(n2)
(B) O(nlg n)
(C) O(n)
(D) O(l g n)
2. How many PUSH and POP operations will be needed to evaluate the following expression by
reverse polish notation in a stack machine (A * B) + (C * D/E) ?
(A) 4 PUSH and 3 POP instructions
(B) 5 PUSH and 4 POP instructions
(C) (C) 6 PUSH and 2 POP instructions
(D) (D) 5 PUSH and 3 POP instructions
3. Convert the following infix expression into its equivalent post fix expression
(A + B^ D) / (E – F) + G
(A) ABD^ + EF – / G+
(B) ABD + ^EF – / G+
(C) ABD + ^EF / – G+
(D) ABD^ + EF / – G+
4. You have to sort a list L, consisting of a sorted list followed by a few ‘random’ elements. Which
of the following sorting method would be most suitable for such a task ?
(A) Bubble sort
(B) Selection sort
(C) Quick sort
(D) (D) Insertion sort
5. Consider an array A[20, 10], assume 4 words per memory cell and the base address of array A
is 100. What is the address of A[11, 5] ? Assume row major storage.
(A) 560
(B) 565
(C) 570
(D) 575
8. Suppose that we have numbers between 1 and 1000 in a binary search tree and we want to
search for the number 365. Which of the following sequences could not be the sequence of
nodes examined ?
(A) 4, 254, 403, 400, 332, 346, 399, 365
(B) 926, 222, 913, 246, 900, 260, 364, 365
(C) 927, 204,913, 242, 914, 247, 365
(D) 4, 401, 389, 221, 268, 384, 383, 280, 365
9. Level order Traversal of a rooted Tree can be done by starting from root and performing:
(A) Breadth First Search (B) Depth first search (C) Root search (D) Deep search
10. The average case occurs in the Linear Search Algorithm when:
(A) The item to be searched is in some where middle of the Array
(B) The item to be searched is not in the array
(C) The item to be searched is in the last of the array
(D) The item to be searched is either in the last or not in the array
11. To determine the efficiency of an algorithm the time factor is measured by:
(A) Counting micro seconds
(B) Counting number of key operations
(C) Counting number of statements
(D) Counting kilobytes of algorithm
(A) 2 3 4 6 7 13 15 17 18 18 20
(B) 20 18 18 17 15 13 7 6 4 3 2
(C) 15 13 20 4 7 17 18 2 3 6 18
(D) 2 4 3 13 7 6 15 17 20 18 18
14. In general, in a recursive and non-recursive implementation of a problem (program):
(A) Both time and space complexities are better in recursive than in nonrecursive program
(B) Both time and space complexities are better in non-recursive than in recursive program
(C) Time complexity is better in recursive version but space complexity is better in non-
recursive version of the program
(D) Space complexity is better in recursive version but time complexity is better in non-
recursive version of the program