School:ST.
Raphael institute
Course: Introduction To Algorithms
Level: HND Based
Lecturer: Engr. KAINMI P.N
SECTION A
TYPE: multiple-choice questions (MCQs) (1mrk/qtn)
Question 1: What is an algorithm?
A) A set of instructions to solve a problem
B) A type of computer hardware
C) A programming language
D) A storage device
Question 2: Which of the following is NOT a characteristic of a good algorithm?
A) Efficiency
B) Correctness
C) Complexity
D) Simplicity
Question 3: What is the primary idea behind a greedy algorithm?
A) It considers all possible solutions to find the best one
B) It makes the locally optimal choice at each step
C) It breaks the problem into subproblems and solves each one
D) It uses recursion to solve the problem
Question 4: Which of the following is an example of a divide and conquer approach?
A) Dijkstra’s Algorithm
B) QuickSort
C) MergeSort
D) Both B and C
Question 5: Which of the following sorting algorithms is considered the most efficient on
average?
A) BubbleSort
B) MergeSort
C) QuickSort
D) InsertionSort
Question 6: Binary Search can only be applied to which of the following?
A) Unsorted arrays
B) Linked lists
C) Sorted arrays
D) All of the above
Question 7: Which tree traversal visits nodes in the order: root, left, right?
A) In-order
B) Pre-order
C) Post-order
D) Level-order
Question 8: Which algorithm is used to find the shortest path in a weighted graph?
A) Kruskal’s Algorithm
B) Dijkstra’s Algorithm
C) QuickSort
D) Floyd-Warshall Algorithm
Question 9: Which algorithm is used to find the Minimum Spanning Tree (MST) in a
graph?
A) Dijkstra’s Algorithm
B) Kruskal’s Algorithm
C) QuickSort
D) Floyd-Warshall Algorithm
Question 10: What does Big-O notation describe?
A) The speed of an algorithm
B) The amount of memory an algorithm uses
C) The time complexity of an algorithm
D) The space complexity of an algorithm
Question 11: Which of the following is NOT a characteristic of Divide and Conquer
algorithms?
A) The problem is broken into smaller subproblems
B) The subproblems are solved independently
C) The solution to the subproblems is combined to solve the main problem
D) They always use recursion
Question 12: Which of the following real-world systems uses Dijkstra’s Algorithm?
A) A GPS navigation system to find the shortest route
B) A sorting system for names in a directory
C) A web crawler for indexing pages
D) A file compression tool
Question 13:
What does the "bubble" refer to in the Bubble Sort algorithm?
A) The smallest element in the list.
B) The process of comparing each element with its adjacent element.
C) The largest element that moves to its final position after each pass.
D) The middle element that gets sorted first.
Question 14:
Consider the following array: [5, 3, 8, 4, 2]. What will the array look like after the first
pass of the Bubble Sort algorithm?
A) [5, 3, 8, 4, 2]
B) [3, 5, 4, 2, 8]
C) [3, 4, 2, 5, 8]
D) [2, 3, 4, 5, 8]
Question 15:
How can we tell if the array is already sorted during the Bubble Sort algorithm?
A) If all elements are equal.
B) If no swaps are made during a full pass.
C) If the elements are in descending order.
D) If the first element is the largest.
Consider the algorithm below
This algorithm finds the largest number in a given list of numbers.
Steps:
1. Start with an empty list of numbers.
2. Assume the first number in the list is the largest.
3. Compare each number in the list with the current largest number.
4. If a number is greater than the current largest, update the largest number.
5. Continue until all numbers are checked.
6. The largest number is the result.
Example:
List: [2, 5, 1, 7, 3]
● Start with the first number: 2.
● Compare 2 with 5. Update the largest to 5.
● Compare 5 with 1. Largest stays 5.
● Compare 5 with 7. Update the largest to 7.
● Compare 7 with 3. Largest stays 7.
Result: The largest number is 7.
Question 16
Which of the following is NOT required to perform this algorithm?
A) Comparing numbers in the list.
B) Keeping track of the largest number.
C) Swapping numbers in the list.
D) Iterating through the entire list.
Question 17
What will the algorithm return if all the numbers in the list are the same, e.g., [4, 4, 4, 4]?
A) 4
B) 0
C) The first number in the list
D) None of the above
Question 18
In a list [10, -2, 5, 0, -1], what happens when the algorithm checks -2?
A) It updates the largest number to -2.
B) It skips -2 because it is smaller than 10.
C) It swaps -2 with 10.
D) It adds -2 to the largest number.
SECTION B
Question 19: Explain the difference between an algorithm and a program.(2mrks)
SECTION C :(10mrks)
Question 20: find the shortest path from A to all other nodes in the graph below using the
Dijkstra's Algorithm