Advanced Data Structures and Implementation

12.1 Top-Down Splay Trees

这里写图片描述
这里写图片描述

An example of the top-down splaying algorithm is shown in Figure 12.4.
这里写图片描述

这里写图片描述

How to insert an item into a tree?

A new node is allocated(if necessary), and if the tree is empty, a one-node tree is created. Otherwise, we splay root around the inserted value x. If the data in the new root is equal to x, we have a duplicate; instead of reinserting x, we preserve newNode for a future insertion and return immediately. If the new root contains a value larger than x, then the new root and its right subtree become a right subtree of newNode, and the root’s left subtree becomes the left subtree of newNode.

The deletion in spray trees is easy, because a splay will place the target of the deletion at the root.

12.2 Red-Black Trees

Operations on red-black trees take O(logN) time in the worst case. And compared with AVL trees, a careful nonrecursive implementation can be done relatively effortlessly.
A red-blace tree is a binary search tree with the following coloring properties:
1. Every node is colored either red or black.
2. The root is black.
3. If a node is red, its children must be black.
4. Every path from a node to a null reference must contain the same number of black nodes.

A consequence of the coloring rules is that the height of a red-black tree is at most
2log(N+1) .

12.2.1 Bottom-up Insertion

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数据结构原本,大一统,外文书原版 Data structures Contents Articles Introduction 1 Data structure 1 Linked data structure 3 Succinct data structure 6 Implicit data structure 8 Compressed data structure 9 Search data structure 10 Persistent data structure 11 Concurrent data structure 18 Abstract data types 21 Abstract data type 21 List 29 Stack 32 Queue 61 Deque 63 Priority queue 66 Map 70 Bidirectional map 73 Multimap 74 Set 75 Tree 80 Arrays 85 Array data structure 85 Row-major order 91 Dope vector 93 Iliffe vector 94 Dynamic array 95 Hashed array tree 98 Gap buffer 99 Circular buffer 101 Sparse array 111 Bit array 112 Bitboard 117 Parallel array 121 Lookup table 123 Lists 129 Linked list 129 XOR linked list 145 Unrolled linked list 147 VList 149 Skip list 151 Self-organizing list 157 Binary trees 162 Binary tree 162 Binary search tree 170 Self-balancing binary search tree 180 Tree rotation 182 Weight-balanced tree 185 Threaded binary tree 186 AVL tree 191 Red-black tree 195 AA tree 210 Scapegoat tree 215 Splay tree 219 T-tree 234 Rope 237 Top Trees 242 Tango Trees 246 Van Emde Boas tree 268 Cartesian tree 272 Treap 277 B-trees 281 B-tree 281 B+ tree 292 Dancing tree 297 2-3 tree 298 2-3-4 tree 299 Queaps 301 Fusion tree 305 Bx-tree 309 Heaps 312 Heap 312 Binary heap 315 Binomial heap 321 Fibonacci heap 326 2-3 heap 331 Pairing heap 331 Beap 334 Leftist tree 335 Skew heap 338 Soft heap 341 d-ary heap 343 Tries 346 Trie 346 Radix tree 353 Suffix tree 358 Suffix array 363 Compressed suffix array 367 FM-index 368 Generalised suffix tree 371 B-trie 372 Judy array 372 Directed acyclic word graph 374 Multiway trees 376 Ternary search tree 376 And–or tree 379 (a,b)-tree 380 Link/cut tree 381 SPQR tree 381 Spaghetti stack 384 Disjoint-set data structure 385 Space-partitioning trees 389 Space partitioning 389 Binary space partitioning 390 Segment tree 395 Interval tree 399 Range tree 404 Bin 406 k-d tree 408 Implicit k-d tree 416 min/max kd-tree 419 Adaptive k-d tree 420 Quadtree 421 Octree 427 Linear octrees 429 Z-order 429 UB-tree 434 R-tree 435 R+ tree 441 R* tree 442 Hilbert R-tree 445 X-tree 452 Metric tree 452 vP-tree 453 BK-tree 454 Hashes 455 Hash table 455 Hash function 468 Open addressing 476 Lazy deletion 479 Linear probing 479 Quadratic probing 480 Double hashing 484 Cuckoo hashing 486 Coalesced hashing 491 Perfect hash function 494 Universal hashing 496 Linear hashing 501 Extendible hashing 502 2-choice hashing 508 Pearson hashing 508 Fowler–Noll–Vo hash function 509 Bitstate hashing 511 Bloom filter 512 Locality preserving hashing 523 Morton number 524 Zobrist hashing 529 Rolling hash 530 Hash list 531 Hash tree 532 Prefix hash tree 534 Hash trie 535 Hash array mapped trie 535 Distributed hash table 536 Consistent hashing 542 Stable hashing 544 Koorde 544 Graphs 547 Graph 547 Adjacency list 549 Adjacency matrix 551 And-inverter graph 554 Binary decision diagram 556 Binary moment diagram 560 Zero-suppressed decision diagram 562 Propositional directed acyclic graph 563 Graph-structured stack 564 Scene graph 565 Appendix 570 Big O notation 570 Amortized analysis 581 Locality of reference 582 Standard Template Library 585 References Article Sources and Contributors 596 Image Sources, Licenses and Contributors 605 Article Licenses License 610
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值