题目
COMP10002_2025_SM2 Exam: Foundations of Algorithms (COMP10002_2025_SM2)- Requires Respondus LockDown Browser
单项选择题
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?
选项
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
查看解析
标准答案
Please login to view
思路分析
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登录即可查看完整答案
我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。
类似问题
What statement accurately describes the difference between a list and a dictionary?
A data structure is a simple unit that consists of one chunk of data only.
A data structure, such as a tuple, list or dictionary, controls the flow of logic in a module?
In a Queue ADT, which operation removes an element from the Queue?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!