Unit 1 - Practice Quiz

CSE205 50 Questions
0 Correct 0 Wrong 50 Left
0/50

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

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

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

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

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

A. Big O Notation
B. Theta Notation
C. Little o Notation
D. Omega 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. Algorithms always require equal time and space
C. Reducing time complexity often increases space complexity
D. Time and space complexity are unrelated

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) = W + B * (k - LB)
B. Address(k) = B + W * (k + LB)
C. Address(k) = B + W * (k - LB)
D. Address(k) = B + (k - LB) / W

6 Which of the following is a linear data structure?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

15 What is the time complexity of Binary Search?

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

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

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

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

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

18 What is the space complexity of Bubble Sort?

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

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

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

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

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

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

A. O(n log n)
B. O(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(log n)
C. O(n^2)
D. O(1)

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

A. Merge Sort
B. Insertion Sort
C. Selection Sort
D. Bubble 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. Searching for an element
B. Deleting an element
C. Sorting the array
D. Accessing each element exactly once

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

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

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

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

28 Linear search is highly inefficient for:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

40 Which data structure is static in nature?

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

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/2
B. n-1
C. n
D. n+1

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

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

44 Space complexity refers to:

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

45 Which of the following algorithms is In-Place?

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

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

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

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

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

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

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

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

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

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

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