您的位置:首页 > 其它

算法导论学习笔记-2

2005-10-26 21:22 274 查看
1 stack FIRST IN, LAST OUT 写一个小程序,通过array来完成stack的push , pop操作。注意检查underflow , overflow情况2 queue FIRST IN, FIRST OUT 注意,When head[Q] = tail[Q] + 1, the queue is full 写一个小程序,通过array完成ENQUEUE(Q, x) , DEQUEUE(Q)。注意检查underflow , overflow情况

3 hash It is a method that accesses an element in a Set with constant time. a : hash(k)=x , x point to the element , the key of the element is k b : when hash(k1)=hash(k2)=x , then collision happens. Because the two elements have the same pointer [address] a popular method to resolves a collision is chaining—chaining the elements that have the same the hash values.Chapter 11 introduces hash tables, which support the dictionary operations INSERT,DELETE, and SEARCH. In the worst case, hashing requires Θ(n) time to perform a SEARCH operation, but the expected time for hash-table operations is O(1). The analysis of hashing relies on probability, but most of the chapter requires no background in the subject.-----------------------------------

Binary search trees, which are covered in Chapter 12, support all the dynamic-set operations

listed above. In the worst case, each operation takes Θ(n) time on a tree with n elements, but

on a randomly built binary search tree, the expected time for each operation is O(lg n). Binary

search trees serve as the basis for many other data structures.-----------------------------------

Red-black trees, a variant of binary search trees, are introduced in Chapter 13. Unlike ordinary binary search trees, red-black trees are guaranteed to perform well: operations take

O(lg n) time in the worst case. A red-black tree is a balanced search tree; Chapter 18 presents

another kind of balanced search tree, called a B-tree. Although the mechanics of red-black

trees are somewhat intricate, you can glean most of their properties from the chapter without

studying the mechanics in detail. Nevertheless, walking through the code can be quite

instructive.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: