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

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

A. O(n)
B. O(1)
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. Reducing time complexity often increases space complexity
B. Improving time complexity always improves 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 + W * (k - LB)
B. Address(k) = B + (k - LB) / W
C. Address(k) = W + B * (k - LB)
D. Address(k) = B + W * (k + LB)

6 Which of the following is a linear data structure?

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

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

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

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

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

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

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

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

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

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

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

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

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

15 What is the time complexity of Binary Search?

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

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

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

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

18 What is the space complexity of Bubble Sort?

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

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

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

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

A. Selection Sort
B. Heap Sort
C. Quick Sort
D. Bubble 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(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. Insertion Sort
B. Merge Sort
C. Bubble 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(log(M + N))
C. O(M + N)
D. O(1)

25 Traversing an array means:

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

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

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

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

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

28 Linear search is highly inefficient for:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

40 Which data structure is static in nature?

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

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

A. The largest element
B. The middle element
C. The smallest 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(n/2) which is O(n)
B. O(log n)
C. O(n^2)
D. O(1)

44 Space complexity refers to:

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

45 Which of the following algorithms is In-Place?

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

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

A. Finding a random element
B. None
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. 1005
C. 1012
D. 1010

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

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

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

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

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

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