Unit 5 - Practice Quiz

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

1 In a Max-Heap, what is the relationship between the value of a node and its children?

A. The node is greater than or equal to its children
B. There is no specific relationship
C. The node is equal to its children
D. The node is less than or equal to its children

2 Which data structure is commonly used to implement a Heap efficiently?

A. Stack
B. Linked List
C. Array
D. Queue

3 If a node is stored at index 'i' in an array representation of a binary heap (0-indexed), what is the index of its left child?

A. 2i
B. 2i + 1
C. i / 2
D. 2i + 2

4 What is the time complexity to insert a new element into a binary heap of size N?

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

5 What is the time complexity to find the maximum element in a Max-Heap?

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

6 Which operation is required to restore the heap property after extracting the root element?

A. Sorting
B. Linear Search
C. Bubble Up
D. Heapify (Percolate Down)

7 A binary heap is strictly a __.

A. Complete Binary Tree
B. Binary Search Tree
C. AVL Tree
D. Full Binary Tree

8 What is the parent index of a node at index 'i' in a 0-indexed array heap?

A. (i + 1) / 2
B. i / 2
C. 2i
D. (i - 1) / 2

9 What is the worst-case time complexity of HeapSort?

A. O(log N)
B. O(N log N)
C. O(N^2)
D. O(N)

10 HeapSort is generally considered stable. True or False?

A. True
B. Depends on implementation
C. Only for Min-Heap
D. False

11 Which of the following scenarios is the best use case for a Heap?

A. Finding the median in O(1)
B. Storing sorted data sequentially
C. Searching for an arbitrary element
D. Implementing a Priority Queue

12 What is the time complexity to build a heap from an unsorted array of N elements?

A. O(N log N)
B. O(N)
C. O(log N)
D. O(N^2)

13 In HeapSort, where is the sorted array constructed?

A. In a new array
B. In-place within the same array
C. In a binary search tree
D. In a linked list

14 What is the height of a binary heap with N nodes?

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

15 Which hashing technique allows multiple keys to be stored in the same slot using a data structure like a linked list?

A. Linear Probing
B. Open Addressing
C. Separate Chaining
D. Double Hashing

16 What is a 'Collision' in hashing?

A. When two different keys hash to the same index
B. When the hash table is full
C. When the load factor exceeds 1
D. When a key cannot be hashed

17 In the context of hash tables, what is the Load Factor (alpha)?

A. Time taken to hash
B. Number of buckets / Number of elements
C. Number of elements / Number of buckets
D. Size of the key

18 Which simple hash function is defined as h(k) = k mod m?

A. Folding Method
B. Division Method
C. Multiplication Method
D. Mid-Square Method

19 In Open Addressing, where are colliding elements stored?

A. In the same hash table at a different slot
B. In a separate linked list
C. In a secondary hash table
D. They are discarded

20 What is the probe sequence for Linear Probing?

A. (h(k) + i * h2(k)) % m
B. (h(k) + i^2) % m
C. h(k) % m
D. (h(k) + i) % m

21 What is the main disadvantage of Linear Probing?

A. Complex implementation
B. Primary Clustering
C. Requires extra memory
D. Secondary Clustering

22 Quadratic Probing reduces primary clustering but suffers from which issue?

A. Secondary Clustering
B. Primary Clustering
C. Stack overflow
D. Infinite loops

23 Which collision resolution technique uses a second hash function?

A. Separate Chaining
B. Linear Probing
C. Quadratic Probing
D. Double Hashing

24 In Double Hashing, what property must the second hash function h2(k) have?

A. It must return a string
B. It should never evaluate to 0
C. It must result in 0
D. It must be equal to h1(k)

25 Which hashing method allows the load factor to exceed 1?

A. Separate Chaining
B. Linear Probing
C. Open Addressing
D. Quadratic Probing

26 What is the worst-case search time in a Hash Table using Separate Chaining?

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

27 What is the average-case search time for a well-implemented hash table?

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

28 What technique is used to handle deletions in Open Addressing tables?

A. Physical deletion
B. Lazy deletion (Tombstones)
C. Rehashing immediately
D. Shifting elements

29 When choosing a table size 'm' for the Division Method (h(k) = k % m), 'm' should preferably be:

A. A multiple of 10
B. An even number
C. A prime number
D. A power of 2

30 In the Mid-Square method of hashing, which part of the squared key is usually taken as the hash?

A. The first digits
B. The last digits
C. The sum of all digits
D. The middle digits

31 What happens when the load factor of a hash table becomes too high?

A. Nothing changes
B. Collisions increase and performance degrades
C. Performance improves
D. The table automatically deletes elements

32 The process of increasing the size of a hash table and re-inserting all existing elements is called:

A. Rehashing
B. Resizing
C. Refactoring
D. Restructuring

33 Which probing method uses the formula H(k, i) = (h(k) + c1i + c2i^2) % m?

A. Quadratic Probing
B. Double Hashing
C. Random Probing
D. Linear Probing

34 What is 'Perfect Hashing'?

A. A technique with no collisions
B. A technique for dynamic datasets
C. A hashing technique with O(N) access
D. A technique that uses minimal memory

35 If we have a Max-Heap array: [100, 80, 90, 40, 50, 70], what is the left child of 80?

A. 40
B. 70
C. 50
D. 90

36 In a Min-Heap, the root node always contains:

A. The median value
B. A random value
C. The minimum value
D. The maximum value

37 Which of the following is NOT a requirement for a good hash function?

A. It should minimize collisions
B. It must be cryptographically secure
C. It should distribute keys uniformly
D. It should be easy to compute

38 In Open Hashing (Separate Chaining), if the table size is 10 and we insert 20 elements, the load factor is:

A. 10
B. 2.0
C. 0.5
D. 20

39 What is the relationship between Open Hashing and Closed Addressing?

A. Open Hashing is Separate Chaining; Closed Addressing is Open Addressing
B. They are synonyms
C. They are unrelated
D. Open Hashing is Open Addressing; Closed Addressing is Separate Chaining

40 In Linear Probing, search for a key stops when:

A. We have searched the entire table
B. We encounter an empty slot
C. All of the above
D. We find the key

41 Which operation is typically faster in a Hash Table compared to a Binary Search Tree (BST)?

A. Finding the minimum element
B. Finding the maximum element
C. In-order traversal
D. Exact match search

42 When performing HeapSort on an array in ascending order, which type of heap is typically used?

A. Min-Heap
B. Fibonacci Heap
C. Binomial Heap
D. Max-Heap

43 In the folding method of hashing, the key is:

A. Partitioned into parts and added together
B. Divided by a prime
C. Squared
D. Multiplied by a constant

44 What is the primary benefit of Double Hashing over Quadratic Probing?

A. Simpler implementation
B. Guaranteed to find an empty slot in 1 step
C. No secondary clustering
D. Requires less memory

45 If a hash table using Open Addressing is full, what is the time complexity to insert a new item?

A. Infinite loop (until resized or error)
B. O(log N)
C. O(1)
D. O(N)

46 For string keys, a common hashing approach involves:

A. Adding ASCII values
B. Taking the first character only
C. Using a polynomial rolling hash
D. Multiplying the length by the first character

47 Which heap operation decreases the value of a key and restores the heap property?

A. Increase-Key
B. Decrease-Key
C. Delete
D. Extract-Min

48 In a hash table with size m = 10 and hash function h(k) = k % 10, where does key 23 go?

A. 5
B. 0
C. 2
D. 3

49 Using Linear Probing with h(k) = k % 10, if slots 2 and 3 are occupied, where does key 12 go?

A. 2
B. 4
C. 5
D. 3

50 What is the space complexity of a binary heap?

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