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

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

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

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

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

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

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

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. 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(n log n)
B. O(1)
C. O(n)
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. Selection Sort
C. Insertion Sort
D. Merge Sort

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

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

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

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

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

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

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

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

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

15 What is the time complexity of Binary Search?

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

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

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

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

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

18 What is the space complexity of Bubble Sort?

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

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

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

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

A. Heap Sort
B. Bubble Sort
C. Quick 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!)
D. O(n^2)

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

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

A. O(log(M + N))
B. O(1)
C. O(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. Diagonally
B. Randomly
C. Column by column
D. Row by row

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

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

28 Linear search is highly inefficient for:

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

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

A. Number of iterations
B. Number of variables
C. Input size
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. 4 times
C. 8 times
D. 2 times

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

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

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

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

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

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

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 cannot handle duplicates
C. It uses extra space
D. Its time complexity depends on the initial order of elements

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

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

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

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

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

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

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

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

40 Which data structure is static in nature?

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

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

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

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

44 Space complexity refers to:

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

45 Which of the following algorithms is In-Place?

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

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. 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. 1005
C. 1012
D. 1008

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. A single for loop
D. Two nested for loops

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

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

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

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