Data Structures and Algorithms Final review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

9. The total number of comparisons in a bubble sort is .... A. O(n logn) B. O(2n) C. O(n2) D. O(n)

Ans. A ) O(n logn)

25. What is an AVL tree? a) a tree which is unbalanced and is a height balanced tree b) a tree which is balanced and is a height balanced tree c) a tree with at most 3 children d) a tree with three children

Answer: b a tree which is balanced and is a height balanced tree

22. Which of the following is also known as Rope data structure? a) Linked List b) Array c) String d) Cord

Answer: d Cord

11. The prefix form of A-B/ (C * D ^ E) is? a) -A/B*C^DE b) -A/BC*^DE c) -ABCD*^DE d) -/*^ACBDE

Answer: a -A/B*C^DE

15) Which of the following is the infix expression? a) A+B*C b) +A*BC c) ABC+* d) None of the above

Answer: a A+B*C

1. The number of edges in a complete graph of n vertices is a. n(n+1)/2 b. n(n-1)/2 c. n2/2 d. n

B n(n-1)/2

16) Which of the following is the prefix form of A+B*C? a) A+(BC*) b) +AB*C c) ABC+* d) +A*BC

Answer: d +A*BC

22) Consider the following stack implemented using stack. #define SIZE 11 struct STACK { int arr[SIZE]; int top=-1; } What would be the maximum value of the top that does not cause the overflow of the stack? a) 8 b) 9 c) 11 d) 10

Answer: d 10

31) Which of the following that determines the need for the Circular Queue? a) Avoid wastage of memory b) Access the Queue using priority c) Follows the FIFO principle d) None of the above

Answer: a Avoid wastage of memory

21. Which of the following is the most widely used external memory data structure? a) B-tree b) Red-black tree c) AVL tree d) Both AVL tree and Red-black tree

Answer: a B-tree

1) How can we describe an array in the best possible way? a. The Array shows a hierarchical structure. b. Arrays are immutable. c. Container that stores the elements of similar types d. The Array is not a data structure

Answer: c Container that stores the elements of similar types

1. If two trees have same structure and but different node content, then they are called _ a. Synonyms trees b. Joint trees c. Equivalent trees d. Similar trees

D Similar trees

23. What will be the output of the following program? main() { char str[]="san foundry"; int len = strlen(str); int i; for(i=0;i<len;i++) push(str[i]); // pushes an element into stack for(i=0;i<len;i++) pop(); //pops an element from the stack } a) yrdnuof nas b) foundry nas c) sanfoundry d) san foundry

Answer: a yrdnuof nas

she left 30 blank ig

30 is blank

30) The time complexity of enqueue operation in Queue is __ a) O(1) b) O(n) c) O(logn) d) O(nlogn)

Answer: a O(1)

33. Which type of data structure is a ternary heap? a) Hash b) Array c) Priority Stack d) Priority Queue

d) Priority Queue

8. sorting is good to use when alphabetizing a large list of names. A. Merge B. Heap C. Radix D. Bubble

Ans. C Radix

1. Finding the location of a given item in a collection of items is called ...... A. Discovering B. Finding C. Searching D. Mining

Ans. C searching

1. The time complexity of quicksort is ........ A. O(n) B. O(logn) C. O(n2) D. O(n logn)

Ans. D O(n logn)

1. Quick sort is also known as ........ A. merge sort B. tree sort C. shell sort D. partition and exchange sort

Ans. D partition and exchange sort

1. If two trees have same structure and node content, then they are called a. Synonyms trees b. Joint trees c. Equivalent trees d. Similar trees

Ans: C Equivalent

50) Which of the following is the time complexity to search an element in the linked list? a. O(1) O(n) O(logn) O(nlogn) Answer: O(n)

Answer: O(n)

20) The minimum number of stacks required to implement a stack is __ a) 1 b) 3 c) 2 d) 5

Answer: c 2

1. Which of following data structure is more appropriate for implementing quick sortiteratively? (A) Deque (B) Queue (C) Stack (D) Priority queue

C Stack

12) Which one of the following is not the application of the stack data structure a) String reversal b) Recursion c) Backtracking d) Asynchronous data transfer

Answer: d Asynchronous data transfer

39) Which data structure is the best for implementing a priority queue? a) Stack b) Linked list c) Array d) Heap

Answer: d Heap

14) Which data structure is required to convert the infix to prefix notation? a) Stack b) Linked list c) Binary tree d) Queue

Answer: a Stack

10) When the user tries to delete the element from the empty stack then the condition is said to be a ____ a) Underflow b) Garbage collection c) Overflow d) None of the above

Answer: a Underflow

29. Which is the most appropriate data structure for reversing a word? a) stack b) queue c) graph d) tree

Answer: a stack

32) Which one of the following is the correct way to increment the rear end in a circular queue? a) rear =rear+1 b) (rear+1) % max c) (rear % max) + 1 d) None of the above

Answer: b (rear+1) % max

46) In a circular queue implementation using array of size 5, the array index starts with 0 where front and rear values are 3 and 4 respectively. Determine the array index at which the insertion of the next element will take place. a) 5 b) 0 c) 1 d) 2

Answer: b 0

35) How many Queues are required to implement a Stack? a) 3 b) 2 c) 1 d) 4

Answer: b 2

8) Which one of the following is the size of int arr[9] assuming that int is of 4 bytes? a) 9 b) 36 c) 35 d) None of the above

Answer: b 36

11) If the size of the stack is 10 and we try to add the 11th element in the stack then the condition is known as___ a) Underflow b) Garbage collection c) Overflow d) None of the above

Answer: c Overflow

9) Which one of the following is the process of inserting an element in the stack? a) Insert b) Add c) Push d) None of the above

Answer: c Push

25) A list of elements in which enqueue operation takes place from one end, and dequeue operation takes place from one end is__ a) Binary tree b) Stack c) Queue d) Linked list

Answer: c Queue

23) What is another name for the circular queue among the following options? a) Square buffer b) Rectangle buffer c) Ring buffer d) None of the above

Answer: c Ring buffer

17. Which of the following is not the type of queue? a) Priority queue b) Circular queue c) Single ended queue d) Ordinary queue

Answer: c Single ended queue

5) Which of the following highly uses the concept of an array? a) Binary Search tree b) Caching c) Spatial locality d) Scheduling of Processes

Answer: c Spatial locality

13. Which data structure is based on the Last In First Out (LIFO) principle? a) Tree b) Linked List c) Stack d) Queue

Answer: c Stack

24) If the elements '1', '2', '3' and '4' are inserted in a queue, what would be order for the removal? a) 1234 b) 4321 c) 3241 d) None of the above

Answer: a 1234

15. What is a bit array? a) Data structure that compactly stores bits b) Data structure for representing arrays of records c) Array in which elements are not present in continuous locations d) An array in which most of the elements have the same value

Answer: a Data structure that compactly stores bits

21) Which one of the following node is considered the top of the stack if the stack is implemented using the linked list? a) First node b)Second node c) Last node d) None of the above

Answer: a First node

47) If circular queue is implemented using array having size MAX_SIZE in which array index starts with 0, front points to the first element in the queue, and rear points to the last element in the queue. Which one of the following conditions used to specify that the circular queue is empty? a) Front=rear= -1 b) Front=rear=0 c) Front=rear+1 d) None of the above

Answer: a Front=rear= -1

47) If circular queue is implemented using array having size MAX_SIZE in which array index starts with 0, front points to the first element in the queue, and rear points to the last element in the queue. Which one of the following conditions used to specify that the circular queue is empty? a) Front=rear= -1 b) Front=rear=0 c) Front=rear+1 d) None of the above

Answer: a Front=rear= -1 Explanation: The answer is a, i.e., front=rear= -1. When the circular queue is empty means that no element is available in the queue then the front and rear are initialized with a -1 value.

7) What is the output of the below code? #include <stdio.h> int main() { int arr[5]={10,20,30,40,50}; printf("%d", arr[5]); return 0; } a) Garbage value b) 10 c) 50 d) None of the above

Answer: a Garbage value

45) What would be the output after performing the following operations in a Deque? Insertfront(10); Insertfront(20); Insertrear(30); Insertrear(40); Deletefront(); Insertfront(50); Deleterear(); Display(); a) 10, 20, 30 b) 50, 10, 30 c) 40, 20, 30 d) None of the above

Answer: b 50, 10, 30

12. Which of the following points is/are not true about Linked List data structure when it is compared with an array? a) Random access is not allowed in a typical implementation of Linked Lists b) Access of elements in linked list takes less time than compared to arrays c) Arrays have better cache locality that can make them better in terms of performance d) It is easy to insert and delete elements in Linked List

Answer: b Access of elements in linked list takes less time than compared to arrays

16. Which of the following tree data structures is not a balanced binary tree? a) Splay tree b) B-tree c) AVL tree d) Red-black tree

Answer: b B-tree

42) A linear data structure in which insertion and deletion operations can be performed from both the ends is___ a) Queue b) Deque c) Priority queue d) Circular queue

Answer: b Deque

35. A data structure in which elements can be inserted or deleted at/from both ends but not in the middle is? a) Priority queue b) Dequeue c) Circular queue d) Queue

Answer: b Dequeue

19. Which algorithm is used in the top tree data structure? a) Backtracking b) Divide and Conquer c) Branch d) Greedy

Answer: b Divide and Conquer

4) Which of the following is the advantage of the array data structure? a) Elements of mixed data types can be stored. b) Easier to access the elements in an array c) Index of the first element starts from 1. d) Elements of an array cannot be sorted

Answer: b Easier to access the elements in an array

40) Which of the following principle is used if two elements in the priority queue have the same priority? a) LIFO b) FIFO c) Linear tree d) None of the above

Answer: b FIFO

26) Which of the following principle does Queue use? a) LIFO principle b) FIFO principle c) Linear tree d) Ordered array

Answer: b FIFO principle

31. Which of the following is the simplest data structure that supports range searching? a) AA-trees b) K-d trees c) Heaps d) binary search trees

Answer: b K-d trees

49) What would be the time complexity if user tries to insert the element at the end of the linked list (head pointer is known)? a) O(1) b) O(n) c) O(logn) d) O(nlogn)

Answer: b O(n)

50) Which of the following is the time complexity to search an element in the linked list? a) O(1) b) O(n) c) O(logn) d) O(nlogn)

Answer: b O(n)

44) Which of the following data structure allows you to insert the elements from both the ends while deletion from only one end? a) Input-restricted queue b) Output-restricted queue c) Priority queue d) None of the above

Answer: b Output-restricted queue

13) Which data structure is mainly used for implementing the recursive algorithm? a) Queue b) Stack c) Binary tree d) Linked list

Answer: b Stack

17) Which of the following is not the correct statement for a stack data structure? a) Arrays can be used to implement the stack b) Stack follows FIFO c) Elements are stored in a sequential manner d) Top of the stack contains the last inserted element

Answer: b Stack follows FIFO

38) The necessary condition to be checked before deletion from the Queue is__ a) Overflow b) Underflow c) Rear value d) Front value

Answer: b Underflow

48) Consider the implementation of the singly linked list having the head pointer only in the representation. Which of the following operations can be performed in O(1) time? i) Deletion of the last node in the linked list ii) Insertion at the front of the linked list iii) Deletion of the first node in the linked list iv) Insertion at the end of the linked list a.) ii b) both ii and iii c) both i and iv d) both i and ii

Answer: b both ii and iii

28. What is the use of the bin data structure? a) to have efficient traversal b) to have efficient region query c) to have efficient deletion d) to have efficient insertion

Answer: b to have efficient region query

24. Which of the following data structure can provide efficient searching of the elements? a) binary search tree b) unordered lists c) 2-3 tree d) treap (tree & heap)

Answer: c 2-3 tree

18) If the elements '1', '2', '3' and '4' are added in a stack, so what would be the order for the removal? a) 1234 b) 2134 c) 4321 d) None of the above

Answer: c 4321

19) What is the outcome of the prefix expression +, -, *, 3, 2, /, 8, 4, 1? a) 12 b) 11 c) 5 d) 4

Answer: c 5

34. What is a dequeue? a) A queue implemented with both singly and doubly linked lists b) A queue with insert/delete defined for front side of the queue c) A queue with insert/delete defined for both front and rear ends of the queue d) A queue implemented with a doubly linked list

Answer: c A queue with insert/delete defined for both front and rear ends of the queue

34) In the linked list implementation of queue, where will the new element be inserted? a) At the middle position of the linked list b) At the head position of the linked list c) At the tail position of the linked list d) None of the above

Answer: c At the tail position of the linked list

41) Which of the following statement is not true regarding the priority queue? a) Processes with different priority can be easily handled b) Easy to implement c) Deletion is easier d) None of the above

Answer: c Deletion is easier

26. What is the time complexity for searching a key or integer in Van Emde Boas data structure? a) O (M!) b) O (log M!) c) O (log (log M)) d) O (M2)

Answer: c O (log (log M))

43) In the Deque implementation using singly linked list, what would be the time complexity of deleting an element from the rear end? a) O(1) b) O(n2) c) O(n) d) O(nlogn)

Answer: c O(n)

6) Which of the following is the disadvantage of the array? a) Stack and Queue data structures can be implemented through an array. b) Index of the first element in an array can be negative c) Wastage of memory if the elements inserted in an array are lesser than the allocated size d) Elements can be accessed sequentially.

Answer: c Wastage of memory if the elements inserted in an array are lesser than the allocated size

20. What is the need for a circular queue? a) easier computations b) implement LIFO principle in queues c) effective usage of memory d) to delete elements based on priority

Answer: c effective usage of memory

29) Which one of the following is the overflow condition if a circular queue is implemented using array having size MAX? a) rear= MAX-1 b) rear=MAX c) front=(rear+1) mod max d) None of the above

Answer: c front=(rear+1) mod max

28) Which one of the following is the overflow condition if linear queue is implemented using an array with a size MAX_SIZE? a) rear = front b) rear = front+1 c) rear=MAX_SIZE -1 d) rear = MAX_SIZE

Answer: c rear=MAX_SIZE -1

14. Which of the following application makes use of a circular linked list? a) Recursive function calls b) Undo operation in a text editor c) Implement Hash Tables d) Allocating CPU to resources

Answer: d Allocating CPU to resources

36) Which one of the following is not the application of the Queue data structure? a) Resource shared between various systems b) Data is transferred asynchronously c) Load balancing d) Balancing of symbols

Answer: d Balancing of symbols

37) Which of the following option is true if implementation of Queue is from the linked list? a) In enqueue operation, new nodes are inserted from the beginning and in dequeue operation, nodes are removed from the end. b) In enqueue operation, new nodes are inserted from the end and in dequeue operation, nodes are deleted from the beginning. c) In enqueue operation, new nodes are inserted from the end and in dequeue operation, nodes are deleted from the end. d) Both a and b

Answer: d Both a and b In enqueue operation, new nodes are inserted from the beginning and in dequeue operation, nodes are removed from the end. & In enqueue operation, new nodes are inserted from the end and in dequeue operation, nodes are deleted from the beginning.

33) Consider the following code. int fun() { if(isEmpty()) { return -10; } else { int n; n= q[front]; front++; return n; } } Which operation does the above code perform? a) Enqueue b) Dequeue c) Return the front element d) Both b and c

Answer: d Dequeue & Return the front element

10. The data structure required for Breadth First Traversal on a graph is? a) Array b) Stack c) Tree d) Queue

Answer: d Queue

27) Which one of the following is not the type of the Queue? a) Linear Queue b) Circular Queue c) Double ended Queue d) Single ended Queue

Answer: d Single ended Queue

27. The optimal data structure used to solve Tower of Hanoi is _________a) Tree b) Heap c) Priority queue d) Stack

Answer: d Stack

18. Which of the following data structures can be used for parentheses matching? a) binary tree b) queue c) priority queue d) stack

Answer: d stack

32. What is the advantage of a hash table as a data structure? a) easy to implement b) faster access of data c) exhibit good locality of reference d) very efficient for less number of entries

Answer: d very efficient for less number of entries


Set pelajaran terkait

apcsa unit 1 progress check MCQ part A

View Set

Iggy Chapter 61: Assessment of the Endocrine System

View Set

Chapter 5: Neurodevelopmental Disorders

View Set

MGT 3020 Chapter 1 What is organizational Behavior?

View Set

Module 6 Acute Lymphocytic Leukemia

View Set

Chapter 45 all: Disorders of the Female Reproductive System

View Set

Evaluating Function Notation -- GRAPHS

View Set