羡慕不来是什么意思| 蝈蝈是什么动物| 辜负是什么意思| asus是什么牌子| 夕颜是什么意思| 食管裂孔疝什么意思| 周围神经病是什么症状| 屎壳郎吃什么| 强肉弱食是什么意思| 天庭的动物是什么生肖| 嗳气是什么原因引起的| 怒发冲冠是什么意思| 骄阳是什么意思| 牙齿上有黄斑是什么原因| 降钙素原检测是查什么的| 发offer是什么意思| 长期腹泻是什么病| 肺主治节是什么意思| 肛裂出血和痔疮出血有什么区别| 银芽是什么菜| 国家一级演员是什么级别| 什么分什么裂| 腰椎退变是什么意思| 翻白草长什么样| 水疱疹什么药最快能治好| 会所是什么意思| 什么肉不含嘌呤| 骨龄偏小意味着什么| 腮腺炎反复发作是什么原因| 血管瘤是什么意思| 吞咽困难是什么原因造成的| 气血不足什么原因引起的| 百叶是什么| 黄精药材有什么功效| 嘎巴拉是什么| 法令纹用什么填充效果最好| 今年天热的原因是什么| 鸟屎掉身上有什么预兆| 什么地站着| 扁桃体发炎了吃什么药| 喝枸杞子泡水有什么好处和坏处| g750是什么金| 迷惑是什么意思| 耳朵疼吃什么药| 29周岁属什么生肖| 疣是什么东西| 寒凝血瘀吃什么中成药| 什么地照着| 一个万一个足念什么| 根是什么意思| 痘痘里面挤出来的白色东西是什么| 清凉的什么| 阴湿是什么病| 人参和什么泡酒能壮阳| 治前列腺炎吃什么药效果最好| 怕吹空调是什么原因| 重度抑郁症吃什么药| 腰间盘突出有什么好的治疗方法| 哥哥的儿子叫什么| f00d中文是什么意思| 佝偻病什么症状| 怀孕喝酒会有什么反应| 9月13日是什么星座| 甲功异常有什么症状| 鲈鱼不能和什么一起吃| 无名指为什么叫无名指| 动物奶油是什么做的| 晚霞是什么意思| 总lge是什么| 尿道口流脓吃什么药| 眼皮浮肿是什么原因| 活动性胃炎是什么意思| 香奈儿属于什么档次| PPm什么意思| 脚跟疼是什么原因| 孩子贫血吃什么补血最快| 牙龈肿痛吃什么水果| 经期缩短是什么原因| 月经前几天是什么期| 凉粉是什么材料做的| 梦见和邻居吵架什么预兆| 欣赏是什么意思| 乳酸菌素片什么时候吃| 授人以鱼不如授人以渔什么意思| 皂基是什么| 咂嘴是什么意思| hcg是什么激素| 喉咙痛吃什么消炎药| 两鬓长白发是什么原因| 对策是什么意思| 菜园中有什么生肖| 疾病是什么意思| 一什么天安门| 钾低吃什么药| 全科是什么科| 广义货币m2是什么意思| 牛奶什么时间喝最好| 黑天天的学名叫什么| 做梦梦到自己拉屎是什么意思| 为什么耳屎是湿的| 贫血吃什么补血效果最好| 南瓜吃多了有什么坏处| 再生牙技术什么时候能实现| 医院总务科是干什么的| 产后拉肚子是什么原因引起的| 什么是认知| 12点到1点是什么时辰| 怀孕嗜睡什么时候开始| 9月21号是什么星座| 天赋异禀什么意思| 白细胞高是什么原因引起的| 84年属于什么生肖| 缺碘吃什么| 什么是九宫格| 共振是什么意思| 老人家脚肿是什么原因引起的| 145是什么意思| 膝盖跪着疼是什么原因| 霉菌性阴炎用什么药好得快| ac是什么基团| 儿童胃肠型感冒吃什么药| 支教是什么意思| 红细胞偏高是什么意思| 高频听力损失意味什么| 窦性心律过缓吃什么药| 麻小是什么意思| 脾胃虚寒能吃什么水果| 梦见亲人去世是什么意思| 鸳鸯戏水是什么意思| 双侧颈部淋巴结可见是什么意思| 经常头痛是什么原因| pb是什么意思| 肠系膜淋巴结炎吃什么药最有效| 小孩测骨龄挂什么科| 肺结节是什么原因| 属兔与什么属相相克| 温文尔雅是什么意思| 大人吃什么排黄疸快| 什么笔不能写字| 去鱼腥味最好的方法是什么| 一吃东西就牙疼是什么原因引起的| 32岁属什么的生肖| 怀孕十天有什么反应| 长溃疡是缺什么维生素| 鸭嘴鱼吃什么食物| 乙肝表面抗原是什么意思| 浮萍是什么植物| 人各有命是什么意思| 肝胃不和吃什么中成药| 牙龈老是出血是什么原因引起的| 心电轴左偏是什么意思| 吃什么能化解肾结石| 为什么经常放屁| 净空是什么意思| 什么可以补肾壮阳| 旅长是什么军衔| 消化不良吃什么药最好| 子宫平滑肌瘤什么意思| 息肌丸是什么| 阴桃花是什么意思| 腾冲有什么好玩的景点| 3f是什么意思| 尧五行属什么| 大熊猫为什么有黑眼圈| 支那是什么意思| 山海经讲的是什么| 吃紫菜有什么好处和坏处| 水浒传主要讲了什么| 脚心发麻是什么原因引起的| 乳酸脱氢酶偏低是什么意思| rpe是什么意思| 牙齿深覆合是什么意思| 发烧感冒吃什么药| 虎是什么意思| 上海副市长什么级别| 什么叫脑梗| 胃疼看病挂什么科| 湿疹可以吃什么| 脾胃虚寒吃什么| neo什么意思| 病理检查是什么意思| 一什么教室| 限购是什么意思| 鸟吃什么食物| 尿液泡沫多是什么原因| 姑爷是什么意思| 3月3日是什么节| 骨龄是什么| 上下眼皮肿是什么原因| 胰腺炎吃什么消炎药| 喝什么缓解痛经最有效| 爱做梦是什么原因应该怎样调理| 呵是什么意思| 什么布料最好| 掌中宝是什么东西| 精索静脉曲张是什么意思| 99年属什么的| 鹿吃什么| 看走眼是什么意思| elisa是什么检测方法| 硒酵母胶囊对甲状腺的作用是什么| 成人受到惊吓吃什么药| 无什么| 开车压到蛇有什么说法| 女性外阴痒用什么药| 什么茶不能喝脑筋急转弯| 玙字五行属什么| 如来佛祖和释迦牟尼是什么关系| 红脸关公代表什么意思| 大拇指疼痛什么原因引起的| 手脚麻木吃什么药| 箭在弦上是什么意思| 腰间盘膨出吃什么药效果好| cea升高是什么意思| 主任医师是什么级别| 为什么大熊猫是国宝| 浮现是什么意思| 清洁度二度是什么意思| 金色葡萄球菌最怕什么| 生旦净末丑分别指什么| 新生儿上户口需要什么资料| 两榜进士是什么意思| 山药有什么功效和作用| 产检请假属于什么假| 2022什么年| 深圳副市长什么级别| 辟谷是什么都不吃吗| 睡前喝蜂蜜水有什么好处| 3月27是什么星座| 211大学是什么意思| 大致正常心电图是什么意思| 喷砂是什么意思| 思是什么生肖| 什么叫社保| 虚岁31岁属什么生肖| 什么叫k线| 暂停服务是什么意思| 鼻涕有血丝是什么原因| 骨关节响是什么原因| 下嘴唇发麻什么病兆| 孙权与孙策是什么关系| 上次闰六月是什么时候| 植物的茎有什么作用| 什么东西能去脸上的斑| 何首乌长什么样| 吃什么能解酒| 常委是什么级别| 孤单的我还是没有改变是什么歌| 腼腆什么意思| 血小板高有什么危害| 拉肚子是什么原因导致的| 氢化植物油是什么| 拉疙瘩屎是什么原因| 临床药学是干什么的| 陈旧性骨折是什么意思| 3月9日什么星座| 蛋糕用什么面粉| 为什么明明很困就是睡不着| 月经结束一周后又出血是什么原因| 为什么会流产| 前列腺钙化是什么病| 坐飞机不能带什么物品| 水漂是什么意思| 央行行长什么级别| 百度

数读中国新闻业最新发展趋势

百度 最终陈巍短节目拿到分(技术分/节目内容分),高居所有选手第一。

In computer science, join-based tree algorithms are a class of algorithms for self-balancing binary search trees. This framework aims at designing highly-parallelized algorithms for various balanced binary search trees. The algorithmic framework is based on a single operation join.[1] Under this framework, the join operation captures all balancing criteria of different balancing schemes, and all other functions join have generic implementation across different balancing schemes. The join-based algorithms can be applied to at least four balancing schemes: AVL trees, red–black trees, weight-balanced trees and treaps.

The join operation takes as input two binary balanced trees and of the same balancing scheme, and a key , and outputs a new balanced binary tree whose in-order traversal is the in-order traversal of , then then the in-order traversal of . In particular, if the trees are search trees, which means that the in-order of the trees maintain a total ordering on keys, it must satisfy the condition that all keys in are smaller than and all keys in are greater than .

History

edit

The join operation was first defined by Tarjan[2] on red–black trees, which runs in worst-case logarithmic time. Later Sleator and Tarjan [3] described a join algorithm for splay trees which runs in amortized logarithmic time. Later Adams [4] extended join to weight-balanced trees and used it for fast set–set functions including union, intersection and set difference. In 1998, Blelloch and Reid-Miller extended join on treaps, and proved the bound of the set functions to be   for two trees of size   and  , which is optimal in the comparison model. They also brought up parallelism in Adams' algorithm by using a divide-and-conquer scheme. In 2016, Blelloch et al. formally proposed the join-based algorithms, and formalized the join algorithm for four different balancing schemes: AVL trees, red–black trees, weight-balanced trees and treaps. In the same work they proved that Adams' algorithms on union, intersection and difference are work-optimal on all the four balancing schemes.

Join algorithms

edit

The function join  considers rebalancing the tree, and thus depends on the input balancing scheme. If the two trees are balanced, join simply creates a new node with left subtree t1, root k and right subtree t2. Suppose that t1 is heavier (this "heavier" depends on the balancing scheme) than t2 (the other case is symmetric). Join follows the right spine of t1 until a node c which is balanced with t2. At this point a new node with left child c, root k and right child t2 is created to replace c. The new node may invalidate the balancing invariant. This can be fixed with rotations.

The following is the join algorithms on different balancing schemes.

The join algorithm for AVL trees:

function joinRightAVL(TL, k, TR)
    (l, k', c) := expose(TL)
    if h(c) ≤ h(TR) + 1
        T' := Node(c, k, TR)
        if h(T') ≤ h(l) + 1
            return Node(l, k', T')
        else
            return rotateLeft(Node(l, k', rotateRight(T')))
    else 
        T' := joinRightAVL(c, k, TR)
        T := Node(l, k', T')
        if h(T') ≤ h(l) + 1
            return T
        else
            return rotateLeft(T)

function joinLeftAVL(TL, k, TR)
    /* symmetric to joinRightAVL */

function join(TL, k, TR)
    if h(TL) > h(TR) + 1
        return joinRightAVL(TL, k, TR)
    else if h(TR) > h(TL) + 1
        return joinLeftAVL(TL, k, TR)
    else
        return Node(TL, k, TR)

Where:

  •   is the height of node  .
  •   extracts the left child  , key  , and right child   of node   into a tuple  .
  •   creates a node with left child  , key  , and right child  .

The join algorithm for red–black trees:

function joinRightRB(TL, k, TR)
    if TL.color = black and ?(TL) = ?(TR)
        return Node(TL, ?k, red?, TR)
    else 
        (L', ?k', c'?, R') := expose(TL)
        T' := Node(L', ?k', c'?, joinRightRB(R', k, TR))
        if c' = black and T'.right.color = T'.right.right.color = red
            T'.right.right.color := black
            return rotateLeft(T')
        else
            return T'

function joinLeftRB(TL, k, TR)
    /* symmetric to joinRightRB */

function join(TL, k, TR)
    if ?(TL) > ?(TR)
        T' := joinRightRB(TL, k, TR)
        if (T'.color = red) and (T'.right.color = red)
            T'.color := black
        return T'
    else if ?(TR) > ?(TL)
        /* symmetric */
    else if TL.color = black and TR = black
        return Node(TL, ?k, red?, TR)
    else
        return Node(TL, ?k, black?, TR)

Where:

  • ? ? is the black height of node  .
  •   extracts the left child  , key  , color  , and right child   of node   into a tuple  .
  • ? ? creates a node with left child  , key  , color  , and right child  .

The join algorithm for weight-balanced trees:

function joinRightWB(TL, k, TR)
    (l, k', c) := expose(TL)
    if w(TL) =α w(TR)
        return Node(TL, k, TR)
    else 
        T' := joinRightWB(c, k, TR)
        (l1, k1, r1) := expose(T')
        if w(l) =α w(T')
            return Node(l, k', T')
        else if w(l) =α w(l1) and w(l)+w(l1) =α w(r1)
            return rotateLeft(Node(l, k', T'))
        else
            return rotateLeft(Node(l, k', rotateRight(T'))

function joinLeftWB(TL, k, TR)
    /* symmetric to joinRightWB */

function join(TL, k, TR)
    if w(TL) >α w(TR)
        return joinRightWB(TL, k, TR)
    else if w(TR) >α w(TL)
        return joinLeftWB(TL, k, TR)
    else
        return Node(TL, k, TR)

Where:

  •   is the weight of node  .
  •   means weights   and   are α-weight-balanced.
  •   means weight   is heavier than weight   with respect to the α-weight-balance.
  •   extracts the left child  , key  , and right child   of node   into a tuple  .
  •   creates a node with left child  , key   and right child  .

Join-based algorithms

edit

In the following,   extracts the left child  , key  , and right child   of node   into a tuple  .   creates a node with left child  , key   and right child  . " " means that two statements   and   can run in parallel.

Split

edit

To split a tree into two trees, those smaller than key x, and those larger than key x, we first draw a path from the root by inserting x into the tree. After this insertion, all values less than x will be found on the left of the path, and all values greater than x will be found on the right. By applying Join, all the subtrees on the left side are merged bottom-up using keys on the path as intermediate nodes from bottom to top to form the left tree, and the right part is asymmetric. For some applications, Split also returns a boolean value denoting if x appears in the tree. The cost of Split is  , order of the height of the tree.

The split algorithm is as follows:

function split(T, k)
    if (T = nil)
        return (nil, false, nil)
    else
        (L, m, R) := expose(T)
        if k < m
            (L', b, R') := split(L, k)
            return (L', b, join(R', m, R))
        else if k > m
            (L', b, R') := split(R, k)
            return (join(L, m, L'), b, R'))
        else
            return (L, true, R)

Join2

edit

This function is defined similarly as join but without the middle key. It first splits out the last key   of the left tree, and then join the rest part of the left tree with the right tree with  . The algorithm is as follows:

function splitLast(T)
    (L, k, R) := expose(T)
    if R = nil
        return (L, k)
    else
        (T', k') := splitLast(R)
        return (join(L, k, T'), k')

function join2(L, R)
    if L = nil
        return R
    else
        (L', k) := splitLast(L)
        return join(L', k, R)

The cost is   for a tree of size  .

Insert and delete

edit

The insertion and deletion algorithms, when making use of join can be independent of balancing schemes. For an insertion, the algorithm compares the key to be inserted with the key in the root, inserts it to the left/right subtree if the key is smaller/greater than the key in the root, and joins the two subtrees back with the root. A deletion compares the key to be deleted with the key in the root. If they are equal, return join2 on the two subtrees. Otherwise, delete the key from the corresponding subtree, and join the two subtrees back with the root. The algorithms are as follows:

function insert(T, k)
    if T = nil
        return Node(nil, k, nil)
    else
        (L, k', R) := expose(T)
        if k < k'
            return join(insert(L,k), k', R)
        else if k > k'
            return join(L, k', insert(R, k))
        else
            return T

function delete(T, k)
    if T = nil
        return nil
    else
        (L, k', R) := expose(T)
        if k < k'
            return join(delete(L, k), k', R)
        else if k > k'
            return join(L, k', delete(R, k))
        else
            return join2(L, R)

Both insertion and deletion requires   time if  .

Set–set functions

edit

Several set operations have been defined on weight-balanced trees: union, intersection and set difference. The union of two weight-balanced trees t1 and t2 representing sets A and B, is a tree t that represents AB. The following recursive function computes this union:

function union(t1, t2)
    if t1 = nil
        return t2
    else if t2 = nil
        return t1
    else
        (l1, k1, r1) := expose(t1)
        (t<, b, t>) := split(t2, k1)
        l' := union(l1, t<) || r' := union(r1, t>)
        return join(l', k1, r')

Similarly, the algorithms of intersection and set-difference are as follows:

function intersection(t1, t2)
    if t1 = nil or t2 = nil
        return nil
    else
        (l1, k1, r1) := expose(t1)
        (t<, b, t>) = split(t2, k1)
        l' := intersection(l1, t<) || r' := intersection(r1, t>)
        if b
            return join(l', k1, r')
        else
            return join2(l', r')

function difference(t1, t2)
    if t1 = nil
         return nil
    else if t2 = nil
         return t1
    else
        (l1, k1, r1) := expose(t1)
        (t<, b, t>) := split(t2, k1)
        l' = difference(l1, t<) || r' = difference(r1, t>)
        if b
            return join2(l', r')
        else
            return join(l', k1, r')

The complexity of each of union, intersection and difference is   for two weight-balanced trees of sizes   and  . This complexity is optimal in terms of the number of comparisons. More importantly, since the recursive calls to union, intersection or difference are independent of each other, they can be executed in parallel with a parallel depth  .[1] When  , the join-based implementation applies the same computation as in a single-element insertion or deletion if the root of the larger tree is used to split the smaller tree.

Build

edit

The algorithm for building a tree can make use of the union algorithm, and use the divide-and-conquer scheme:

function build(A[], n)
    if n = 0
        return nil
    else if n = 1
        return Node(nil, A[0], nil)
    else
        l' := build(A, n/2) || r' := (A+n/2, n-n/2)
        return union(L, R)

This algorithm costs   work and has   depth. A more-efficient algorithm makes use of a parallel sorting algorithm.

function buildSorted(A[], n)
    if n = 0
        return nil
    else if n = 1
        return Node(nil, A[0], nil)
    else
        l' := build(A, n/2) || r' := (A+n/2+1, n-n/2-1)
        return join(l', A[n/2], r')

function build(A[], n)
    A' := sort(A, n)
    return buildSorted(A, n)

This algorithm costs   work and has   depth assuming the sorting algorithm has   work and   depth.

Filter

edit

This function selects all entries in a tree satisfying a predicate  , and return a tree containing all selected entries. It recursively filters the two subtrees, and join them with the root if the root satisfies  , otherwise join2 the two subtrees.

function filter(T, p)
    if T = nil
        return nil
    else
        (l, k, r) := expose(T)
        l' := filter(l, p) || r' := filter(r, p)
        if p(k)
            return join(l', k, r')
        else
            return join2(l', R)

This algorithm costs work   and depth   on a tree of size  , assuming   has constant cost.

Used in libraries

edit

The join-based algorithms are applied to support interface for sets, maps, and augmented maps [5] in libraries such as Hackage, SML/NJ, and PAM.[5]

Notes

edit

References

edit
  1. ^ a b Blelloch, Guy E.; Ferizovic, Daniel; Sun, Yihan (2016), "Just Join for Parallel Ordered Sets", Symposium on Parallel Algorithms and Architectures, Proc. of 28th ACM Symp. Parallel Algorithms and Architectures (SPAA 2016), ACM, pp. 253–264, arXiv:1602.02120, doi:10.1145/2935764.2935768, ISBN 978-1-4503-4210-0
  2. ^ Tarjan, Robert Endre (1983), "Data structures and network algorithms", Data structures and network algorithms, Siam, pp. 45–56
  3. ^ Sleator, Daniel Dominic; Tarjan, Robert Endre (1985), "Self-adjusting binary search trees", Journal of the ACM, Siam
  4. ^ Adams, Stephen (1992), "Implementing sets efficiently in a functional language", Implementing sets efficiently in a functional language, Citeseer, CiteSeerX 10.1.1.501.8427.
  5. ^ a b Blelloch, Guy E.; Ferizovic, Daniel; Sun, Yihan (2018), "PAM: parallel augmented maps", Proceedings of the 23rd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, ACM, pp. 290–304
edit
  • PAM, the parallel augmented map library
  • Hackage, Containers in Hackage
类风湿因子高是什么原因 什么值得买怎么用 什么叫肿瘤 梦到吃花生是什么意思 6月12日是什么节日
带状疱疹是什么 大户人家什么意思 2040年是什么年 手掌发红是什么原因 群青色是什么颜色
纺锤形是什么形状 荷花是什么季节开放的 什么是纤维 呼吸内科主要看什么病 蛋清加蜂蜜敷脸有什么好处
脑膜瘤钙化意味着什么 吃什么对头发有好处 贞操带是什么 尿蛋白定量高说明什么 正规医院减肥挂什么科
HPV高危亚型52阳性什么意思hcv7jop9ns1r.cn snoopy是什么意思hcv7jop5ns4r.cn 阻生齿是什么hcv8jop2ns4r.cn xxoo什么意思hcv9jop5ns0r.cn 脚踝扭伤挂什么科hcv7jop6ns5r.cn
胚轴发育成什么hcv7jop6ns8r.cn 牙痛是什么原因引起的bfb118.com 喝咖啡困倦是什么原因liaochangning.com 吹泡泡是什么意思hcv8jop7ns4r.cn 两女一杯是什么hcv8jop8ns7r.cn
血红蛋白偏高是什么原因hcv8jop6ns4r.cn 技校是什么hcv9jop5ns4r.cn 二月二十是什么星座hcv7jop6ns1r.cn 左卡尼汀口服溶液主要治疗什么bfb118.com 二月二是什么节hcv9jop3ns9r.cn
梦见水里有蛇是什么意思hcv8jop7ns4r.cn 老人反复发烧预示什么hcv7jop6ns1r.cn 中午十二点是什么时辰hcv9jop7ns3r.cn 怀孕查雌二醇什么作用hcv8jop8ns7r.cn 凝血四项是检查什么的hcv9jop2ns4r.cn
百度