寄托天下
查看: 1779|回复: 5
打印 上一主题 下一主题

CS Practice Book上的第60题 [复制链接]

Rank: 4

声望
0
寄托币
1521
注册时间
2005-1-12
精华
1
帖子
4
跳转到指定楼层
楼主
发表于 2005-10-31 11:09:36 |只看该作者 |倒序浏览
60. Consider the following possible data structures for a set of n distinct integers.
I. A min-heap
II. An array of length n sorted in increasing order
III. A balanced binary search tree
For which of these data structures is the number of steps needed to find and remove the 7th largest element O(logn) in the worst case?

(A) I only (B) II only (C) I and II (D) I and III (E) II and III

答案:E

为什么会有II?
在数组中找第7大的元素,可以用下标直接找到,删除只要移动6个元素就行了。总共是O(1)的复杂度
GRE作文互动论坛 -> GRE考试综合论坛 -> TOEFL考试讨论专版  -> GRE_SUB -> 美国留学 -> VISA 美国签证 -> 行前准备::飞跃同期声 -> 异乡岁月※海外申请
0 0

使用道具 举报

Rank: 2

声望
0
寄托币
93
注册时间
2005-8-3
精华
0
帖子
0
沙发
发表于 2005-10-31 18:02:16 |只看该作者
I. 如果是max-heap应该也可以做到logn数量级查找第7大元素,对吧!?
II. 最好的是O(1),如果采用二分查找最差也是O(logn)了吧
III. AVL查找最坏是O(logn);删除要麻烦一点,需要重新调整后面6个节点的关系,不需要动前面n-7个节点的树形结构,因为只重构6个节点在树中的位置,代价最坏应该是O(1)

楼主帮忙解释一下III呗!?

感觉这个题挺别扭的

使用道具 举报

Rank: 4

声望
0
寄托币
1224
注册时间
2004-2-18
精华
2
帖子
4
板凳
发表于 2005-10-31 19:35:03 |只看该作者
调用一次minheap是logn,找第七大的话个人感觉需要nlogn

使用道具 举报

Rank: 2

声望
0
寄托币
73
注册时间
2005-6-26
精华
0
帖子
0
地板
发表于 2005-11-1 08:10:25 |只看该作者

It is asking bound , NOT tight bound.

If you check the definition of  Big O, you should know that. If it is asking tight bound, then it's a different story.

Just like 1 <2, of course, it is <3 too.

使用道具 举报

Rank: 4

声望
0
寄托币
1521
注册时间
2005-1-12
精华
1
帖子
4
5
发表于 2005-11-1 10:32:44 |只看该作者
Originally posted by yuren78 at 2005-11-1 08:10
If you check the definition of  Big O, you should know that. If it is asking tight bound, then it's a different story.

Just like 1 <2, of course, it is <3 too.


有道理。发现ETS出的题对基本概念考得很细,做题时要小心啊
GRE作文互动论坛 -> GRE考试综合论坛 -> TOEFL考试讨论专版  -> GRE_SUB -> 美国留学 -> VISA 美国签证 -> 行前准备::飞跃同期声 -> 异乡岁月※海外申请

使用道具 举报

Rank: 2

声望
0
寄托币
73
注册时间
2005-6-26
精华
0
帖子
0
6
发表于 2005-11-1 20:44:46 |只看该作者

Autosea, thank you for your reply to my question on TestMagic.com.

Autosea, thank you for your reply to my question on TestMagic.com.

使用道具 举报

RE: CS Practice Book上的第60题 [修改]

问答
Offer
投票
面经
最新
精华
转发
转发该帖子
CS Practice Book上的第60题
https://bbs.gter.net/thread-356765-1-1.html
复制链接
发送
回顶部