DATA STRUCTURES AND
ALGORITHMS FINAL REVIEW EXAM
QUESTIONS ANSWERS
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) - Correct Answers -Answer: O(n)
Explanation: The answer is O(n). The worst-case time complexity to search an element
in the linked list is O(n) because if we have to find the last element then we need to
traverse till the nth node.
33. Which type of data structure is a ternary heap?a) Hash
b) Array
c) Priority Stack
d) Priority Queue - Correct Answers -
1. Which of following data structure is more appropriate for implementing quick
sortiteratively?
(A) Deque
(B) Queue
(C) Stack
(D) Priority queue - Correct Answers -C
Stack
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 - Correct Answers -B
n(n-1)/2
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 - Correct Answers -D
Similar trees
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 - Correct Answers -Ans: C
Equivalent
1. Finding the location of a given item in a collection of items is called ......
A. Discovering
B. Finding
C. Searching
D. Mining - Correct Answers -Ans. C
searching
1. The time complexity of quicksort is ........
A. O(n)
B. O(logn)
C. O(n2)
D. O(n logn) - Correct Answers -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 - Correct Answers -Ans. D
partition and exchange sort
8. sorting is good to use when alphabetizing a large list of names.
A. Merge
B. Heap
C. Radix
D. Bubble - Correct Answers -Ans. C
Radix
9. The total number of comparisons in a bubble sort is ....
A. O(n logn)
B. O(2n)
C. O(n2)
D. O(n) - Correct Answers -Ans. A )
O(n logn)
, 10. The data structure required for Breadth First Traversal on a graph is?
a) Array
b) Stack
c) Tree
d) Queue - Correct Answers -Answer: d
Queue
Explanation: In Breadth First Search Traversal, BFS, starting vertex is first taken and
adjacent vertices which are unvisited are also taken. Again, the first vertex which was
added as an unvisited adjacent vertex list will be considered to add further unvisited
vertices of the graph. To get the first unvisited vertex we need to follows First In First
Out principle. Queue uses FIFO principle.
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 - Correct Answers -Answer: a
-A/B*C^DE
Explanation: Infix Expression is A-B/(C*D^E)This can be written as: A-
(B/(C*(D^E)))Thus prefix expression is -A/B*C^DE.
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 - Correct Answers -Answer: b
Access of elements in linked list takes less time than compared to arrays
Explanation: To access an element in a linked list, we need to traverse every element
until we reach the desired element. This will take more time than arrays as arrays
provide random access to its elements.
13. Which data structure is based on the Last In First Out (LIFO) principle?
a) Tree
b) Linked List
c) Stack
d) Queue - Correct Answers -Answer: c
Stack
Explanation: The data structure that follows the Last In First Out (LIFO) principle is the
Stack. It operates like a stack of objects, making it suitable for specific-order
management.
ALGORITHMS FINAL REVIEW EXAM
QUESTIONS ANSWERS
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) - Correct Answers -Answer: O(n)
Explanation: The answer is O(n). The worst-case time complexity to search an element
in the linked list is O(n) because if we have to find the last element then we need to
traverse till the nth node.
33. Which type of data structure is a ternary heap?a) Hash
b) Array
c) Priority Stack
d) Priority Queue - Correct Answers -
1. Which of following data structure is more appropriate for implementing quick
sortiteratively?
(A) Deque
(B) Queue
(C) Stack
(D) Priority queue - Correct Answers -C
Stack
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 - Correct Answers -B
n(n-1)/2
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 - Correct Answers -D
Similar trees
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 - Correct Answers -Ans: C
Equivalent
1. Finding the location of a given item in a collection of items is called ......
A. Discovering
B. Finding
C. Searching
D. Mining - Correct Answers -Ans. C
searching
1. The time complexity of quicksort is ........
A. O(n)
B. O(logn)
C. O(n2)
D. O(n logn) - Correct Answers -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 - Correct Answers -Ans. D
partition and exchange sort
8. sorting is good to use when alphabetizing a large list of names.
A. Merge
B. Heap
C. Radix
D. Bubble - Correct Answers -Ans. C
Radix
9. The total number of comparisons in a bubble sort is ....
A. O(n logn)
B. O(2n)
C. O(n2)
D. O(n) - Correct Answers -Ans. A )
O(n logn)
, 10. The data structure required for Breadth First Traversal on a graph is?
a) Array
b) Stack
c) Tree
d) Queue - Correct Answers -Answer: d
Queue
Explanation: In Breadth First Search Traversal, BFS, starting vertex is first taken and
adjacent vertices which are unvisited are also taken. Again, the first vertex which was
added as an unvisited adjacent vertex list will be considered to add further unvisited
vertices of the graph. To get the first unvisited vertex we need to follows First In First
Out principle. Queue uses FIFO principle.
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 - Correct Answers -Answer: a
-A/B*C^DE
Explanation: Infix Expression is A-B/(C*D^E)This can be written as: A-
(B/(C*(D^E)))Thus prefix expression is -A/B*C^DE.
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 - Correct Answers -Answer: b
Access of elements in linked list takes less time than compared to arrays
Explanation: To access an element in a linked list, we need to traverse every element
until we reach the desired element. This will take more time than arrays as arrays
provide random access to its elements.
13. Which data structure is based on the Last In First Out (LIFO) principle?
a) Tree
b) Linked List
c) Stack
d) Queue - Correct Answers -Answer: c
Stack
Explanation: The data structure that follows the Last In First Out (LIFO) principle is the
Stack. It operates like a stack of objects, making it suitable for specific-order
management.