Data Structures 1. Each entry in a linked list is a called a --------- (a)link (b)node (c)data structure (d)none of the above 2. Linked list uses type of memory allocation (a)static (b)dynamic (c)random (d)compile time 3. The functions used for memory allocation (a)malloc (b)calloc (c)a and b (d)none of the above 4. Which of the following is primitive type? (a)string (b)integer (c)float (d)b and c 5. The five items: A, B, C, D and E are pushed in a stack, one after the other starting from A. The stack is popped four times and F is pushed on the stack. Now one item is popped from the stack. The popped item is. (a)a (b)b (c)c (d)f 6. What is the value of the postfix expression 6 3 2 4 + - * (a)something between -15 and -100 (b)something between -5 and -15 c)something between 5 and -5 (d)none of the above 7. Determine the value of the following postfix expressions when the variables have the values: A=2, B=3, C=4 and D=5 AB*C-D+ (a)-7 (b)3 (c)7 (d)-3 8. Convert the infix expression A*B-(C+D)+E into postfix form (a)ab*cd+-e+ (b)ab*cd-+e+ (c)abcd*-+e+ (d)none of the above 9. When topological sort cannot be performed on graphs? (a) acyclic graph (b) cyclic graphs weighted graph (d) none of these 10. Dijkstra s algorithm is used to determine the shortest path between to in a weighted digraph. (a) the first vertex, last vertex (b) source vertex, other vertices the first vertex, second vertex (d) none of these 11. Which type of algorithmic technique is used in Dijkstra s algorithm? (a) divide and conquer (b) Greedy algorithm Backtracking (d) none of these 12. Topological sort is. (a) one of the sorting method (b) ordering of vertices ordering of numbers (d) none of these 13. Which data structure is used in dfs? a) stack b) queue c)linked list d)tree
14. Which data structure is used in bfs? a) stack b) queue c)linked list d)tree 15. Which is the phenomenon which occurs when a hash function maps 2 different keys to the same table address? a) Collision b) Overlaps c) Nothing Happens d) Rebound 16. Which one is not divide and conquer algorithm a) merge sort b) quick sort c) bubble sort d) binary search 17. The average case time complexity of quick sort is. a. O(n) b.o(n 2 ) c. O(nlogn) d. None of these 18. The worst case time complexity of binary search is. a. O(logn) b.o(n 2 ) c. O(nlogn) d. None of these 19. Write the expression for the expression tree a) (a+b*c)+((d*e+f)*g) b) (a+b)*c+((d*e+f)*g) c) (a+b)*c+(d*(e+f)*g) d) (a+b*c)+d*(e+f*g) 20. The prefix notation for the expression tree is a) + + a * b c * + * d e f g b) + a * + b c * + * d e f g c) + + a * b c * + d * e f g d) + + a * b c + * * d e f g
21. Which one of the following is used in the implementation of tree? a) stack b) queue c)array d)linked list 22. The algorithm works by dividing an input array into two halves, sorting them recursively and then merging the two sorted halves to get the original array sorted. a) heap sort b) quick sort c) merge sort d) selection sort 23. ------------------- is a divide and conquer algorithm that works by partitioning its input elements according to their values relative to some pre selected element. a) heap sort b) quick sort c) merge sort d) selection sort 24. The selection of pivot element is used in ----------------- a) heap sort b) quick sort c) merge sort d) selection sort 25. Which one of the following is not an internal sorting? a) heap sort b) quick sort c) poly phase merge d) selection sort 26. Which data structure is used in implementing towers of Hanoi? a) stack b)queue c) linked list d)tree 27. Which one of the following is an application of stack? a) infix to postfix conversion b) printers c) ticket reservation d) minimum spanning tree 28. Which one of the following algorithm is used to find the minimum spanning tree? (a) prim s algorithm (b) dijkstra s algorithm (c) knapsack (d) none of the above 29. Which one of the following algorithm is used to find the single source shortest path problem? (a) prim s algorithm (b) dijkstra s algorithm (c) knapsack (d) none of the above 30. What is the minimum spanning tree of the following graph? Which one of the following is true? (a) Kruskal Algorithm looks easier than Prim s (b) Kruskal Algorithm is harder to implement than prim s ( c) Kruskal Algorithm is less efficient than prim s (d) All the above 31. The running time of Kruskals algorithm is (a) Θ (log n) (b) Θ (n log m) (c) Θ (n2) (d) Θ(m log m)
32. ------------------is a method for efficiently solving a broad range of search and optimization problems which exhibit the characteristics of overlapping sub problems and optimal substructure. (a) branch and bound (b) backtracking (c) dynamic programming (d) greedy 33. Two main measures for the efficiency of an algorithm are a. Processor and memory b. Complexity and capacity c. Time and space d. Data and space 34. Which of the following data structure is linear data structure? a. Trees b. Graphs c. Arrays d. None of above 35. How many different binary search trees can be made from three nodes that contain the key values 1, 2,3 & 4? a) 12 b)13 c)14 d)15 36. Which of the following name does not relate to stacks? a. FIFO lists b. LIFO list c. Piles d. Push-down lists 37. The term "push" and "pop" is related to the a. array b. lists c. stacks d. all of above 38. A data structure where elements can be added or removed at either end but not in the middle a. Linked lists b. Stacks c. Queues d. Dequeue 39. When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return a. FAEKCDBHG b. FAEKCDHGB c. EAFKHDCBG d. FEAKDCHBG 40. What is the data structures used to perform recursion? a. Linked lists b. Stacks c. Queues d. Dequeue 41. A binary tree with 20 nodes has null branches? a)19 b)20 c)21 d)22 42. How many different trees are possible with 10 nodes? a) 1014 b)1024 c)1034 d)none of the above 43. There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree? a)12 b)13 c)15 d)14 44. There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a complete binary tree? a)12 b)13 c)15 d)14 45. Minimum number of queues needed to implement the priority queue? a)1 b)2 c)3 d)none of the above
46. If n denotes the number of vertices in the given graph, then How many edges we have in the minimum spanning tree? (a) n (b) n-1 (c) n+1 (d)none of the above 47. The following tree is A. Heap B. Full & Complete C. Heap & Complete D.None of these 48. How many binary search trees can be constructed with 5 nodes? 40 42 44 46 49. Binary trees with 20 nodes have ----- null branches? 19 21 20 400 50. BFS of the following graph leads to (a) a b c d e f g h b) a b d c g e f h (c ) a b d e h c f g (d) a b d e h c g f 51. Traverse the graph and give the post order result? (a) D H B E A F C I G J (B) A B D H E C F G I J (C ) H D E B F I J G C A (D) H E D F B J I C G A
52. Convert the expression ((A + B) * C - (D - E) ^ (F + G)) to equivalent Prefix and Postfix notations. a. Prefix Notation: - +ABC *^ - DE + FG Postfix Notation: AB + C * DE - FG + ^ - b. Prefix Notation: - * +ABC ^ DE + - FG Postfix Notation: AB + C * DE - FG + ^ - c. Prefix Notation: - * +ABC ^ - DE + FG Postfix Notation: AB + C * DE - FG + ^ - d. Prefix Notation: - * +ABC ^ - DE + FG Postfix Notation: AB + C * DE - FG + - ^ 53. Sorting is not possible by using which of the following methods? a. Insertion b. Selection c. Exchange d. Deletion 54. Consider the following pseudo code that uses a stack declare a stack of characters while ( there are more characters in the word to read ) { read a character push the character on the stack } while ( the stack is not empty ) { pop a character off the stack write the character to the screen } What is output for input geeksquiz? (A) geeksquizgeeksquiz (B) ziuqskeeg (C) geeksquiz (D) ziuqskeegziuqskeeg 55. Following is an incorrect pseudocode for the algorithm which is supposed to determine whether a sequence of parentheses is balanced: declare a character stack while ( more input is available) { read a character if ( the character is a '(' ) push it on the stack else if ( the character is a ')' and the stack is not empty ) pop a character off the stack else print "unbalanced" and exit } print "balanced" Which of these unbalanced sequences does the above code think is balanced? (A) ((( )) (B) ( ))(( ) (C) (( )( ))) (D) (( )))( ) 56. The following postfix expression with single digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * - Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are: (A) 6, 1 (B) 5, 7 (C) 3, 2 (D) 1, 5 57. Assume that the operators +, -, are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x, +, -. The postfix expression corresponding to the infix expression a + b c - d ^ e ^ f is (A) abc + def ^ ^ (B) abc + de ^ f ^ (C) ab + c d e ^ f ^ (D) + a bc ^ ^ def 58. Given a Binary Search Tree (BST), print its values in ascending order. a. Perform Depth first traversal b. Perform Breadth first traversal c. Perform Post order traversal d. Perform In order traversal 59. The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of the following is the post order traversal sequence of the same tree? (A) 10, 20,15, 23, 25,35, 42,39,30 (B) 15,10, 25, 23, 20, 42,35,39,30 (C) 15, 20,10, 23, 25, 42,35,39,30 (D) 15,10, 23, 25, 20,35, 42,39,30 60. Suppose a circular queue of capacity (n 1) elements is implemented with an array of N elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are (A) full: (REAR+1) mod n==front empty: REAR ==FRONT (B) full:(rear+1)mod n==front empty: (FRONT+1)mod n==rear (C) full: REAR==FRONT empty: (REAR+1) mod n ==FRONT (D) full: (FRONT+1)mod n==rear empty: REAR ==FRONT 61. A max-heap is a heap where the value of each parent is greater than or equal to the value of its children. Which of the following is a max-heap?
62. Consider two binary operators ' ' and ' ' with the precedence of operator being lower than that of the operator. Operator is right associative while operator, is left associative. Which one of the following represents the parse tree for expression