Questions
Questions

COMP10002_2025_SM2 Exam: Foundations of Algorithms (COMP10002_2025_SM2)- Requires Respondus LockDown Browser

Single choice

Sorted arrays and binary search trees can both be used as a dictionary data structure. Suppose that a dictionary is required to store n items that will be inserted in a randomized order. Which statement is not correct?

Options
A.Insertion into a sorted array takes O(n) time in the worst case, and insertion into a binary search tree also takes O(n) time in the worst case
B.Search in a sorted array takes O(log n) time in the average case, and search in a binary search tree also takes O(log n) time in the average case
C.Search in a sorted array takes O(log n) time in the worst case, whereas search in a binary search tree takes O(n) time in the worst case
D.Insertion into an sorted array takes O(n) time in the average case, whereas insertion into a binary search tree takes O(log n) time in the average case
E.Search in a sorted array takes O(n) time in the worst case, and search in a binary search tree also takes O(n) time in the worst case
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
Question restatement: A dictionary storing n items inserted in random order can be implemented with a sorted array or a binary search tree (BST). Which statement is not correct? Option 1: Insertion into a sorted array takes O(n) time in the worst case, and insertion into a binary search tree also takes O(n) time in the worst case. - Sorted array insertion requires shifting elements to make space for the new item, which is indeed O(n) in the worst case. - BST insertion in the worst case (when the tree is degenerate, e.g., a linked list due to insert order) also incurs O(n) time. - This option is intern......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!