Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Republic of the Philippines

OCCIDENTAL MINDORO STATE COLLEGE


Rizal Street, San Jose, Occidental Mindoro
Website: www.omsc.edu.ph Email address: bsitdepartment22@gmail.com
Tele/Fax: (043) 457-0305
Bachelor of Science in Information Technology

DATA STRUCTURE AND ALGORITHM


FINAL EXAMINATION
1st Semester, 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.

1. What would be the appropriate approach, involving steps outlined in a symbolic


representation, to locate a specific element (key) within a collection?
a. Psuedocode c. Data Structure
b. Algorithm d. Searching
2. What method involves systematically reducing the workload by half at each comparison
during the search process?
a. Binary Search c. Data Search
b. Algorithm d. Hash Search
3. What Algorithm is specifically designed for searching a key in an array that has been
ordered by numerical values assigned to the keys (key values)?
a. Binary Search c. Interpolation Search
b. Bubble Search d. Hash Search
4. It is a process also known as sequential searching, which involves checking every element
in a list sequentially until the desired element is found.
a. Binary Search c. Interpolation Search
b. Linear Search d. Hash Table Search
5. Which data structure is specifically designed to implement an associative array?
a. Binary Search c. Interpolation Search
b. Linear Search d. Hash Table Search
6. What term refers to an order group of homogeneous elements or items?
a. Psuedocode c. Data Structure
b. Algorithm d. Queue
7. What term refers to the maximum number of items that might be on the queue?
a. Max Item c. Item type
b. Algorithm d. Queue
8. Which of the following statements accurately describes the principles of FILO(First In,
Last Out and LIFO (Last In, First Out) in the context of a stack?
a. FILO means that the first item added to the stack is the first one to be removed,
while LIFO means the last item added is the last one to be removed.
b. FILO means that the last item added to the stack is the first one to be removed,
while LIFO means the first item added is the last one to be removed
c. FILO and LIFO are interchangeable terms, both describing the same principle of
stack operation.
d. FILO and LIFO have no specific meaning in the context of stack.
9. Which of the following statements correctly describes the two constructors commonly
used in implementing a stack?
a. The “Empty Constructor” initializes an empty stack, while the “Push Constructor”
pushes an element on the top of an existing stack.
b. The “Default Constructor” sets the stack size to a predetermined value, while the
“Custom Constructor” dynamically adjusts the size based on runtime needs.
c. The “Push Constructor” is responsible for adding elements to the stack, while “Pop
Constructor” is used for removing elements from the stack.
d. The “Copy Constructor” creates a duplicate stack, while the “Resize constructor”
adjusts the stack size during runtime.
10. It is a type of selector which gives back the stack without the top most element.
a. Top c. Pop
b. Push d.isEmpty
11. What are the two fundamental operations that define the behavior of a queue?
a. Push and Pop c. Add and Remove
b. Enqueue and Dequeue d. Insert and Delete
12. Explain the concept of “Enqueue” in a queue. How does this operation affect the structure
of the queue, and why is it essential in queue-based algorithms?
a. Enqueue adds an element to the front of the queue, ensuring constant complexity.
b. Enqueue adds an element to the rear of the queue, maintaining the FIFO order.
c. Enqueue removes the oldest element from the queue, ensuring efficient retrieval.
d. Enqueue swaps the positions of the first and last elements in the queue for better
performance.
13. Which term is commonly used to describe the process of removing an element from a
queue?
a. Extract c. RemoveFront
b. Dequeue d. PopFront
14. Describe a real-world scenario were understanding the FIFO (First In, First Out) principle
of a queue is crucial. How does the FIFO property impact the outcome in this scenario?
a. Managing print jobs in a printer queue.
b. Sorting elements in ascending order
c. Retrieving items from the middle of the queue
d. Retrieving items from the middle of the queue.
15. What is the purpose of the “peek” operation in a stack?
a. To remove the top element
b. To add an element to the stack
c. To view the top element without removing it
d. To check if the stack is empty
16. What is Bubble Sort, and how does it work in sorting a list of elements?
a. Bubble Sort is a complex sorting algorithm that uses a divide-and-conquer
approach.
b. Bubble Sort is a simple sorting algorithm that repeatedly steps through the list,
compares adjacent elements, and swaps them if they are in the wrong order.
c. Bubble Sort is an algorithm specifically designed for searching elements in a
database.
d. Bubble Sort is a sorting technique that works only on numeric data.
17. It is a comparison-based sorting algorithm that builds binary data strurcture and repeatedly
extracts the minimum element.
a. Bubble c. Hash
b. Heap d. Quick
18. It is a data structure that uses a function to map keys to indices, enabling constant-time
average retrieval.
a. Bubble c. Hash
b. Heap d. Quick
19. What is a collision in the context of Hash Tables?
a. A collision occurs when two keys hash to the same index.
b. A collision occurs when a key cannot be hashed to any index.
c. A collision occurs when two keys hash to the same index.
d. A collision occurs when a key is missing in the hash table.
20. In a stack, where does the deletion (pop) of an element occur?
a. Front
b. End
c. Middle
d. Top
21. How are collisions typically resolved?
a. Collisions are resolved by ignoring one of the conflicting keys
b. Collisions are resolved by rehashing the key with a new function.
c. Collisions are resolved by using techniques like chaining or open addressing.
d. Collisions are resolved by adding the missing key.
22. What is stack in data structure?
a. An ordered collection of elements
b. A First-in, first-out (FIFO) data structure
c. A last-in, first out (LIFO) data structure
d. A sorted collection of elements
23. What is a queue in data structure?
a. Last In First Out (LIFO) structure
b. First In First Out (FIFO) structure
c. Random access structure
d. Stack structure
24. Which of the following is the correct order of operations in a stack
a. Push, Pop, Peek
b. Peek, Push, Pop
c. Pop, Peek, Push
d. Push, Peek, pop
25. Which of the following data structure uses a stack for its implementation?
a. Queue
b. Linked List
c. Tree
d. Recursion
26. In a queue, where do new elements get added?
a. Front
b. Middle
c. End
d. Random position
27. What is the term used for the process of adding an element to the rear of the queue
a. Push
b. Enqueue
c. Insert
d. Append
28. If you have a stack with a maximum size of 5 and you attempt to push an element onto a
full stack? what will happen?
a. The element will be added to the stack.
b. The stack will remain unchanged.
c. An error will occur, indicating stack overflow.
d. The top element will be automatically removed.
29. If the input array for binary search is not sorted, what is the expected behavior of the
algorithm?
a. It will work correctly without issues.
b. It will enter an infinite loop
c. It will return incorrect results
d. It will raise an exception error.
30. In hashing, what is the purpose of the hash function?
a. To resize the hash table.
b. To determine the load factor.
c. To calculate the average search time.
d. To map keys to indices in the hash table.
31. If you have a queue with a maximum size of 5 and you attempt to enqueue an element
onto a full queue, what will happen?
a. An error will occur, indicating queue overflow.
b. The element will be added to the queue.
c. The queue will remain unchanged
d. The front element will be automatically removed.
32. In the binary search algorithm, what is the purpose of the mid variable?
a. It represents the length of the array.
b. It is the target element to be found.
c. It is the middle index of the current search range.
d. It is the sum of the left and right indices.
33. Which of the following statements is TRUE in the context of function calls?
a. Stack helps ensure functions are called in alphabetical order.
b. Stack keeps track of the order of function calls and their local variables.
c. Stack prevents the execution of recursive functions.
d. Stack enforces a first-in, las-out order for function calls.
34. Which of the following statements is TRUE if you pop an element from an empty stack?
a. An error is thrown
b. The program crashes
c. Nothing happens
d. The top element is set to null
35. Which is TRUE in the purpose of a priority queue?
a. Sort elements in ascending order
b. Organize elements in random order
c. Assign priorities to elements and process them accordingly
d. To reverse the order of elements.

TEST II Direction: Read and understand the set of sentences in each given number. Choose the
correct letter of the correct answer.

a. Both statements are true


b. Both Statements are false
c. First statement is true but the second is false
d. First statement is false but the second is true

36. 1. Bubble Sort is an adaptive sorting algorithm A


2. Bubble Sort is a stable sorting algorithm

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

38. 1. Binary search can only be applied to sorted arrays or lists.


2. In most programming languages, the names of processing items can contain letters, numbers,
underscores, punctuation, characters, and spaces. 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

40. 1. A Stack Follows the first-In-First-Out principle


2. Stack can only be implemented using arrays and not 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:

ARJEANETTE J. GONZAGA, LPT


Data Structure and Algorithm Instructor

You might also like