Unit 1: Introduction, Arrays, Sorting and Searching - Practice Quiz

CSE205 — Data Structures And Algorithms 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. Big O 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(log n)
B. O(n^2)
C. O(n)
D. O(1)

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

A. Theta Notation
B. Little o Notation
C. Big 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. Reducing time complexity often increases space complexity
C. Algorithms always require equal time and space
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) = B + (k - LB) / W
B. Address(k) = W + B * (k - LB)
C. Address(k) = B + W * (k + LB)
D. Address(k) = B + W * (k - LB)

6 Which of the following is a linear data structure?

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

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

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

A. Bubble Sort
B. Insertion Sort
C. Selection 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. Hashing
B. Breadth-First Search
C. Binary Search
D. Linear Search

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

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

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. Little o
B. Omega
C. Theta
D. Big O

15 What is the time complexity of Binary Search?

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

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

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

18 What is the space complexity of Bubble Sort?

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

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. Bubble Sort
C. Selection Sort
D. Quick Sort

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

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

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

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

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

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

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

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

25 Traversing an array means:

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

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

A. Row by row
B. Randomly
C. Diagonally
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
B. 1.5n
C. 2n
D. n^2

28 Linear search is highly inefficient for:

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

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

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

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

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

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

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

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

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

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

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

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

A. Its time complexity depends on the initial order of elements
B. It uses extra space
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. Sorting an array
B. Printing all elements
C. Finding a path in a maze
D. Debugging code (bisecting)

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

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

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

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

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

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

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

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

40 Which data structure is static in nature?

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

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

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

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

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

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

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

44 Space complexity refers to:

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

45 Which of the following algorithms is In-Place?

A. Radix Sort
B. Merge Sort (standard)
C. Counting Sort
D. Insertion 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. Finding the first element
D. Traversing

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

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

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

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

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 loop counter
B. The recursion stack depth
C. The size of the array
D. The number of variables