Unit 1 - Practice Quiz

CSE205

1 Which of the following defines the worst-case time complexity of an algorithm?

A. Big O Notation
B. Omega Notation
C. Theta Notation
D. Beta Notation

2 What is the time complexity of accessing an element at a specific index in an array?

A. O(n)
B. O(log n)
C. O(1)
D. O(n^2)

3 Which notation represents the lower bound of an algorithm's running time?

A. Big O Notation
B. Omega Notation
C. Theta Notation
D. Little o Notation

4 In the context of algorithm analysis, what does the Space-Time trade-off imply?

A. Improving time complexity always improves space complexity
B. Reducing time complexity often increases space complexity
C. Time and space complexity are unrelated
D. Algorithms always require equal time and space

5 What is the formula to calculate the memory address of the k-th element in a linear array with base address B and word size W (assuming lower bound is LB)?

A. Address(k) = B + W * (k - LB)
B. Address(k) = B + W * (k + LB)
C. Address(k) = B + (k - LB) / W
D. Address(k) = W + B * (k - LB)

6 Which of the following is a linear data structure?

A. Tree
B. Graph
C. Array
D. Heap

7 What is the worst-case time complexity of inserting an element at the beginning of an array of size n?

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)

8 Which sorting algorithm works by repeatedly swapping adjacent elements if they are in the wrong order?

A. Selection Sort
B. Insertion Sort
C. Bubble Sort
D. Merge Sort

9 What is the worst-case time complexity of Bubble Sort?

A. O(n)
B. O(n log n)
C. O(n^2)
D. O(1)

10 Which searching algorithm requires the array to be sorted beforehand?

A. Linear Search
B. Binary Search
C. Hashing
D. Breadth-First Search

11 What is the worst-case time complexity of Linear Search?

A. O(1)
B. O(log n)
C. O(n)
D. O(n^2)

12 What is the best-case time complexity of an optimized Bubble Sort (using a flag)?

A. O(1)
B. O(n)
C. O(n^2)
D. O(log n)

13 In Selection Sort, how many swaps are performed in the worst case for an array of size n?

A. O(n)
B. O(n^2)
C. O(log n)
D. O(1)

14 Which notation represents the tight bound (both upper and lower) of an algorithm?

A. Big O
B. Omega
C. Theta
D. Little o

15 What is the time complexity of Binary Search?

A. O(n)
B. O(n^2)
C. O(log n)
D. O(1)

16 In Insertion Sort, what is the time complexity when the input array is already sorted?

A. O(n^2)
B. O(n)
C. O(1)
D. O(n log n)

17 Which operation is NOT efficiently supported by a standard array?

A. Random Access
B. Traversal
C. Insertion in the middle
D. Updating an element

18 What is the space complexity of Bubble Sort?

A. O(n)
B. O(log n)
C. O(1)
D. O(n^2)

19 How is the middle element calculated in Binary Search to avoid integer overflow?

A. mid = (low + high) / 2
B. mid = low + (high - low) / 2
C. mid = low + high
D. mid = (high - low) / 2

20 Which sorting algorithm is considered 'stable' among the following?

A. Selection Sort
B. Quick Sort
C. Heap Sort
D. Bubble Sort

21 What is the worst-case complexity of Selection Sort?

A. O(n)
B. O(n log n)
C. O(n^2)
D. O(n!)

22 Which of the following describes an algorithm that runs in constant time?

A. O(n)
B. O(1)
C. O(log n)
D. O(n^2)

23 Which sorting technique acts like sorting a hand of playing cards?

A. Bubble Sort
B. Merge Sort
C. Insertion Sort
D. Selection Sort

24 What is the complexity of merging two sorted arrays of size M and N?

A. O(M * N)
B. O(M + N)
C. O(log(M + N))
D. O(1)

25 Traversing an array means:

A. Sorting the array
B. Accessing each element exactly once
C. Searching for an element
D. Deleting an element

26 In row-major order, elements of a 2D array are stored:

A. Row by row
B. Column by column
C. Diagonally
D. Randomly

27 The minimum number of comparisons required to find the minimum and maximum element in an array of size n is:

A. 2n
B. n
C. 1.5n
D. n^2

28 Linear search is highly inefficient for:

A. Small arrays
B. Unsorted arrays
C. Large arrays
D. Linked Lists

29 What does 'n' usually represent in complexity analysis?

A. Number of iterations
B. Input size
C. Number of variables
D. CPU speed

30 If an algorithm has a time complexity of O(n^2), doubling the input size increases the time by:

A. 2 times
B. 4 times
C. 8 times
D. It remains same

31 Which algorithm is generally preferred for small datasets due to low overhead?

A. Merge Sort
B. Insertion Sort
C. Heap Sort
D. Quick Sort

32 The operation of processing each element in the list is known as:

A. Sorting
B. Merging
C. Inserting
D. Traversal

33 What is the output of a Binary Search if the element is not found?

A. The middle index
B. The array size
C. A failure indicator (e.g., -1)
D. The last element

34 Selection sort is NOT an adaptive sorting algorithm. What does this mean?

A. It uses extra space
B. Its time complexity depends on the initial order of elements
C. Its time complexity is the same regardless of initial order
D. It cannot handle duplicates

35 Which of the following is an application of Binary Search?

A. Finding a path in a maze
B. Debugging code (bisecting)
C. Sorting an array
D. Printing all elements

36 What is the maximum number of comparisons in a Binary Search for an array of size 32?

A. 32
B. 16
C. 6
D. 5

37 In an array A[1...N], the index of the first element is:

A.
B. 1
C. -1
D. N

38 Deleting an element from the end of a linear array takes:

A. O(n)
B. O(1)
C. O(log n)
D. O(n^2)

39 Which case typically determines the Big O complexity of an algorithm?

A. Best Case
B. Average Case
C. Worst Case
D. Null Case

40 Which data structure is static in nature?

A. Linked List
B. Array
C. Stack (Dynamic)
D. Queue (Dynamic)

41 In Bubble Sort, after the first pass, which element is guaranteed to be in its correct position?

A. The smallest element
B. The largest element
C. The middle element
D. No element

42 How many passes are required to sort an array of size n using Insertion Sort in the worst case?

A. n
B. n-1
C. n+1
D. n/2

43 What is the average case time complexity of Linear Search?

A. O(1)
B. O(n/2) which is O(n)
C. O(log n)
D. O(n^2)

44 Space complexity refers to:

A. The amount of hard disk space used
B. The amount of RAM used during execution
C. The number of lines of code
D. The time taken to compile

45 Which of the following algorithms is In-Place?

A. Merge Sort (standard)
B. Insertion Sort
C. Counting Sort
D. Radix Sort

46 For a sorted array, which operation is slower in a Linear Search compared to Binary Search?

A. Finding the first element
B. Finding a random element
C. Traversing
D. None

47 If Base address is 1000, W=2, and Index=5 (0-based indexing), what is the address?

A. 1005
B. 1010
C. 1012
D. 1008

48 Which loop structure primarily characterizes an O(n^2) complexity?

A. A single for loop
B. Two separate for loops
C. Two nested for loops
D. A recursive function dividing input by 2

49 In Selection Sort, the minimum element is swapped with:

A. The adjacent element
B. The last element
C. The element at the beginning of the unsorted subarray
D. The middle element

50 A recursive algorithm's space complexity depends largely on:

A. The number of variables
B. The recursion stack depth
C. The size of the array
D. The loop counter