Professional Documents
Culture Documents
Data Structure Final Exam Ay 2023-2024
Data Structure Final Exam Ay 2023-2024
TEST I: Direction: Read each statement carefully. Select the correct letter that best suits
your answer by shading the corresponding circle on the answer sheet provided.
TEST II Direction: Read and understand the set of sentences in each given number. Choose the
correct letter of the correct answer.
37. 1. Hashing is a technique used to map data of arbitrary size to fixed-size values, usually for fast
data retrieval.
2. Interpolation search is an efficient search algorithm for uniformly distributed data. A
39. 1. Linear search is the most efficient algorithm for searching in all cases.
2. Linear search can only be applied to arrays and not to linked lists. B
41. 1. Linear interpolation always passes through the known data points.
2. Interpolation methods are always stable and accurate regardless of the distribution of data
points. C
42. 1. In a queue, elements can be accessed and removed from any position, not just the front
2. Queue is often used in the First-In-First-out search algorithm. D
43. 1. Binary search can be applied to unsorted datasets and still maintain its efficiency. D
2. The length of an array is determined by the number of elements it can contain.
44. 1. Enqueue operation in a queue adds an element to the rear of the queue.
2. Dequeue operation in a queue can be performed from any position within the queue. C
45. 1. Stacks are often used in implementing function calls and recursion in programming
2. A stack allows access to elements in the middle without popping the entire stack. C
TEST III: Direction: Analyze and evaluate the given code. Choose the correct letter from the
given choices.
Consider the following array: [4,1,7,3,9,2]. Apply the bubble sort algorithm to sort the array.
46. Consider the following array: [4,1,7,3,9,2]. Apply the bubble sort algorithm to sort the array.
What is the array after the second pass?
a. [1,4,3,7,2,9] c. [4,1,7,3,9,2]
b. [1,2,3,4,7,9] d. [4,1,3,7,2,9]
47. Consider the following array: [4,1,7,3,9,2]. Apply the bubble sort algorithm to sort the array.
What is the array after the first pass?
a. [1,4,3,7,2,9] c. [4,1,7,3,9,2]
b. [1,2,3,4,7,9] d. [4,1,3,7,2,9]
48. Consider the following array: [4,1,7,3,9,2]. Apply the bubble sort algorithm to sort the array.
What is the array after the third pass?
a. [1,4,3,7,2,9] c. [4,1,7,3,9,2]
b. [1,2,3,4,7,9] d. [4,1,3,7,2,9]
49. Consider the following array: [4,1,7,3,9,2]. Apply the bubble sort algorithm to sort the array.
What is the array after the fourth pass?
a. [1,4,3,7,2,9] c. [4,1,7,3,9,2]
b. [1,2,3,4,7,9] d. [4,1,3,7,2,9]
50. Consider the following array: [4,1,7,3,9,2]. Apply the bubble sort algorithm to sort the array.
What would be the sorted array?
a. [1,4,3,7,2,9] c. [4,1,7,3,9,2]
b. [1,2,3,4,7,9] d. [4,1,3,7,2,9]
51. Consider the following array [2,12,5,16,18,30,21,25]. You want to perform a binary search to find
the element “16”. After the binary search, what is the status of the array?
a. [2,12,5,16,18,30,21,25]. c. [2,5,12,16,18,21,25,30]
b. [30,25,21,18,16,12,5,2]. d. [2,5,12,18,21,25,30]
52. If a binary search is applied to a sorted array of length 16, what is the maximum number of
comparisons needed to find an element?
a. 4 c. 16
b. 8 d. 32
53. Suppose you have a queue with the elements [3,5,7,9]. If you enqueue the element 11 and then
dequeue two elements, what will be the resulting queue?
a. [7,9,11] c. [11]
b. [9,11] d. [3,5,7,9]
54. Consider a queue with the following elements:[2,4,6,8,10]. If you enqueue the elements 12 and
dequeue an element, what will be the resulting queue?
a. [4,6,8,10,12] c. [6,8,10,12]
b. [2,4,6,8,10,12] d. [2,4,,6,8,10]
55. Suppose you have an array with the following elements:[2,4,6,8,10]. If you perform a binary
search for the element 7, what will be the result?
a. Element found at index 2 c. Element found at index 3
b. Element not found d. Element found at index 4
56. Suppose you have a sorted array [1,3,5,7,9,11,13,15] and you want to find the index of the element
7 using binary search. After each iteration of the binary search, which subarray would be
considered next?
a. [1,3,5,7] c. [5,7,9,11,12,15]
b. [7,9,11,13,15] d. [1,3,5,7,9,11,13,15]
57. Consider a stack with the elements [2,4,6,8,10]. If you push the element 12 onto the stack and then
pop an element, what will be the resulting stack?
a. [2,4,6,8,10] c. [2.4.6.8.12]
b. [2,4,6,8,10,12] d. [2,4,6,12]
58. Suppose you have a stack with the elements [3,5,7,9]. If you push element 11 onto the stack and
then pop two elements, what will be the resulting stack?
a. [7,9,11] c. [11]
b. [9,11] d. [3,5,7,9]
59. Consider an array with the following elements: [12,4,8,6,10]. If you perform a linear search for the
element 6, what will be the result?
a. Element found at index 3 c. Element found at index 4
b. Element not found d. Element found at index 2
60. If a linear search is applied to an array of length 10, and the element to be searched is at the last
index, what is the maximum number of comparisons needed to find the element?
a. 1 c. 10
b. 5 d. 9
61. Suppose you have an array with the following elements: [8,3,1,7,4]. After two passes of the
Bubble Sort algorithm, what will be the new order of the array?
a. [1,3,4,7,8] c. [8,3,1,7,4]
b. [3,1,7,4,8] d. [4,7,1,3,8]
62. Consider an array [1,3,5,7,9] and the target element is 5. How many iterations will the binary
search algorithm take to find the target?
a. 1 c. 3
b. 2 d. 4
63. Consider an initially empty stack. If the sequence of operations is: Push(3), Push(5), Pop(),
Push(2), Pop(), what is the final state of the stack?
a. [3,5] c. [2]
b. [5,2] d. [5,3,2]
64. Suppose you have a queue with the elements [1,2,3,4]. If you perform two consecutive Dequeue
operations, what will be the resulting queue?
a. [3,5] c. [1,2]
b. [2,3] d. [4]
65. Consider a stack with the elements [7,9,2,4]. If you push element 5 onto the stack, what will be the
top element?
a. 2 c. 4
b. 9 d. 7
66. Consider an initially empty queue. If the sequence of operations is: Enqueue(3), Enqueue(5),
Dequeue(), Enqueue(2), Dequeue(), what is the final state of the queue?
a. [3,5] c. [2]
b. [5,2] d. [3,2]
67. Consider a queue with the elements [7,9,2,4]. If you enqueue the element 5, what will be the front
element?
a. 2 c. 4
b. 5 d. 7
68. Consider a queue with the elements [2,4,6,8.10]. If you perform linear search for the element 7,
what will be the result?
a. Element found at index 2 c. Element found at index 3
b. Element not found d. Element found at index 4
69. Consider a queue with the elements [3,7,2,8.5]. If you perform linear search for the element 8,
what will be the result?
a. Element found at index 2 c. Element found at index 3
b. Element not found d. Element found at index 4
70. Consider a queue with the elements [12,4,6,8.10]. If you perform linear search for the element 6,
what will be the result?
a. Element found at index 2 c. Element found at index 3
b. Element not found d. Element found at index 4
71. Consider the following array: [2,1,7,10,9,4,8,6]. Apply the bubble sort algorithm to sort the array.
What is the array after the first pass?
c. [1,2,7,4,8,6,9,10] c. [1,2,4,7,6,8,9,10]
d. [1,2,7,9,4,8,6,10] d. [1,2,4,6,7,8,9,10]
72. Consider the following array: [2,1,7,10,9,4,8,6]. Apply the bubble sort algorithm to sort the array.
What is the array after the second pass?
a. [1,2,7,4,8,6,9,10] c. [1,2,4,7,6,8,9,10]
b. [1,2,7,9,4,8,6,10] d. [1,2,4,6,7,8,9,10]
73. Consider the following array: [2,1,7,10,9,4,8,6]. Apply the bubble sort algorithm to sort the array.
What is the array after the third pass?
a. [1,2,7,4,8,6,9,10] c. [1,2,4,7,6,8,9,10]
b. [1,2,7,9,4,8,6,10] d. [1,2,4,6,7,8,9,10]
74. Consider the following array: [2,1,7,10,9,4,8,6]. Apply the bubble sort algorithm to sort the array.
What is the array after the fourth pass?
a. [1,2,7,4,8,6,9,10] c. [1,2,4,7,6,8,9,10]
b. [1,2,7,9,4,8,6,10] d. [1,2,4,6,7,8,9,10]
75. Consider the following array: [2,1,7,10,9,4,8,6]. Apply the bubble sort algorithm to sort the array.
What would be the sorted array?
a. [1,2,7,4,8,6,9,10] c. [1,2,4,7,6,8,9,10]
b. [1,2,7,9,4,8,6,10] d. [1,2,4,6,7,8,9,10]
Prepared by: