Data Structure Lecture Note (Week 7, Lecture 20)

(Finally) The end of the course!

(2, 4) tree

Multi-way search tree:

an ordered tree such that:

  • each interval node has at least two children and stores d-1 key-element items k i , o i k_i, o_i ki,oi, where d d d is the number of children
  • for a node with children v 1 , v 2 , . . . , v d v_1, v_2,...,v_d v1,v2,...,vd storing keys k 1 , k 2 , . . . , k d − 1 k_1, k_2, ..., k_{d-1} k1,k2,...,kd1
    • keys in the subtree of v 1 v_1 v1 are less than k 1 k_1 k1
    • keys in the subtree of v i v_i vi are between k i − 1 k_{i-1} ki1 and k i k_i ki (i=2,…d-1)
    • keys in the subtree of v d v_d vd are greater than k d k_d kd

An inorder traversal of a multi-way search tree visits the keys in increasing order.

A (2, 4) Tree:

  • Node-Size property: each internal node has at most 4 children
  • Depth property: all the external nodes have the same depth.

Theorem: Height of a (2,4) tree is O(log N)

relation with Red-Black tree:

2–3–4 trees are an isometry of red–black trees, meaning that they are equivalent data structures. In other words, for every 2–3–4 tree, there exists at least one red–black tree with data elements in the same order. Moreover, insertion and deletion operations on 2–3–4 trees that cause node expansions, splits and merges are equivalent to the color-flipping and rotations in red–black trees. Introductions to red–black trees usually introduce 2–3–4 trees first, because they are conceptually simpler. 2–3–4 trees, however, can be difficult to implement in most programming languages because of the large number of special cases involved in operations on the tree. Red–black trees are simpler to implement,[2] so tend to be used instead.

Reference

https://en.wikipedia.org/wiki/2%E2%80%933%E2%80%934_tree

Red-Black Tree

A red-black tree is a representation of a (2, 4) tree by means of a binary tree whose nodes are colored red or black.

In comparision with its associated (2, 4) tree, a red-black tree has:

  • Same logarithmic time performance
  • Simpler implementation with a single node type.

Property:

  • Root is black
  • Leaf is black
  • Children of a red node is black
  • all leaves have the same black depth
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值