Bank
Bank
Right?
D)There is no best case for Bubble Sort. It always takes O(n*n) time
2. In computer science, algorithm refers to a special method usable by a computer for the solution
to a problem.
a) True
b) False
3. Which sorting algorithm repeatedly steps through the list, compares adjacent elements, and
swaps them if they are in the wrong order?
A)Insertion Sort
B)Quick Sort
C)Bubble Sort
D)Merge Sort
A)O(n)
B)O(n^2)
C)O(n log n)
D)O(log n)
5. Which sorting algorithm divides the array into a sorted and an unsorted part and repeatedly picks
the smallest element from the unsorted part?
A)Bubble Sort
B)Selection Sort
C)Insertion Sort
D)Merge Sort
A)O(n^2)
B)O(n log n)
C)O(n)
D)O(log n)
7.Which sorting algorithm works by repeatedly inserting elements into their correct position in the
sorted portion of the array?
A)Insertion Sort
B)Merge Sort
C)Quick Sort
D)Bubble Sort
A)Insertion Sort
B)Merge Sort
C)Bubble Sort
D)Selection Sort
9.In Quick Sort, what is the term for the element used to partition the array?
A)Median
B)Pivot
C)Divider d)Anchor
10. What is the main drawback of empirical analysis in algorithm efficiency?
a. O(log n) )
b. ( O(n^2) )
c. ( O(2^n) )
d. ( O(n log n) )
a. (n^2)
b. (log n)
c. (2^n)
d. (nlog n)
A)Stack
B)Queue
C)Binary Tree
D)Array
A)DFS
B)BFS
C)Quick Sort
D)Exhaustive Search
O(V + E)
O(V^2)
O(E log V)
O(VE)
b. Matrix multiplication.
a. Binary search
b. Dijkstra's algorithm
c. Merge sort
d. Backtracking
23. What is the growth rate of all logarithmic functions( log_a(n)) regardless of base (a)?
b. (O(log n)).
c. (O(nlog n)).
a.Quick Sort
b.Merge Sort
c.Insertion Sort
d.Bubble Sort
True
False
A)True
B) False
True
False
32.Analyze the time complexity of this nested loop:
for i in range(n):
N^2
for j in range(i + 1):
print(i, j)
<Fuction> factorial(n):
if n == 0:
return 1
(N)
return n * factorial(n - 1)
34.
<Function> factorial_reduce(n):
if n <= 1:
return 1
return n * factorial_reduce(n // 2)
35.function exponentialLoop(n):
i=1
while i <= n:
if i % 2 == 0:
print(i)
i=i*2
36. static int MaxSubarraySum(int[] arr)
return maxSum;
A)True
B)False
39.Which of the following problems is not typically solved using Dynamic Programming?
B) Knapsack Problem.
40.Dynamic Programming is only suitable for problems that can be broken down into subproblems.
True
False
A) Making the optimal choice at each step without considering future consequences.
True
False
46.In backtracking, when a solution path reaches an invalid state, it backtracks to the previous step
and tries a different path.
True/False:
B) Solving Sudoku.
D) Sorting an array.
49.In an if-then-else statement, the worst-case time complexity is determined by the faster of the
two sequences of statements.
True
False
B) Compare
d- compare the time complexity of merge sort , Quick Sort , bubble Sort
Apply
1- Merge Sort
2- Quick sort Assume that Pivot first element in List
3- Bubble Sort
2- Dynamic Programming
3- Back Tracking
5- linear search
6- DFS , BFS
Solve Knapsak Problem by Gready Algorthim (capacity W=9)
Let’s say you have a set of coins with values [1, 2, 5, 10] and you need to give minimum number of
coin to someone change for 39.
Apply :
1- Greedy Algorithm
2- Dynamic Programming