`
isiqi
  • 浏览: 16709633 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

算法导论[Exercises 14.2-4]

阅读更多
Exercises 14.2-4:
Start example

Let * be an associative binary operator, and let a be a field maintained in each node of a red-black tree. Suppose that we want to include in each node x an additional field f such that f[x] = a[x1] * a[x2] * ··· * a[xm], where x1, x2,..., xm is the inorder listing of nodes in the subtree rooted at x. Show that the f fields can be properly updated in O(1) time after a rotation. Modify your argument slightly to show that the size fields in order-statistic trees can be maintained in O(1) time per rotation.

1)容易得到不变式 f(x) = f(left[x])*a[x]*f(right[x])]

2)在一次反转过程中,无非是a,b,r三个子树的调整,对于三个子树的f域不需要调整,因为不影响他们内部的顺序,

3)对于求B的f域, f(B) = f(b)*a[B]*f(r)

4)求A的f域f(A) = f(a)*a[A]*f(B)

以上以left-rotate为例,right-roate类似

B A

/ \ -->/ \

A ra B

a b b r

分享到:
评论

相关推荐

    算法导论--Introduction.to.Algorithms

    中文名: 算法导论 原名: Introduction to Algorithms 作者: Thomas H. Cormen Ronald L. Rivest Charles E. Leiserson Clifford Stein 资源格式: PDF 版本: 文字版 出版社: The MIT Press书号: 978-0262033848发行...

    Exercises 1-4.zip

    Exercises 1-4.zip

    Lerner -- Python Workout. 50 Essential Exercises -- 2020.pdf

    4. **Hexadecimal Output** - **Objective:** Convert an integer to its hexadecimal representation. - **Key Concepts:** - Using the `hex()` built-in function. - Understanding hexadecimal number ...

    麻省理工算法导论(完整精辟版)

    麻省理工算法导论 Table of Contents Introduction to Algorithms, Second Edition Preface Part I - Foundations Chapter 1 - The Role of Algorithms in Computing Chapter 2 - Getting Started ...

    麻省理工学院-算法导论

    Reading: Chapters 1–4, excluding §4.4; §28.2; §30.1. Both exercises and problems should be solved, but only the problems should be turned in. Exercises are intended to help you master the course ...

    exercises-js-master.rar

    【标题】"exercises-js-master.rar" 暗示这是一个JavaScript练习项目的压缩文件,很可能包含一系列用于提升JavaScript编程技能的代码挑战或实例。这个标题可能指的是一个开源项目,旨在帮助开发者通过实践来学习和...

    Exercises-and-Tests-源码.rar

    Exercises-and-Tests-源码.rar

    算法导论英文原版第三版 答案

    其中,“Solutions to selected exercises and problems”部分则是对书中习题的解答,对于读者理解和掌握算法至关重要。 在学习算法的过程中,解决书中的习题是提升能力的关键环节。这本书涵盖了排序、搜索、图算法...

    算法导论 CLRS Introduction To Algorithms chm

    算法导论 CLRS Mit Press - Introduction To Algorithms 2Nd Edition Incl Exercises Edition.chm

    [麻省理工学院-算法导论](英文版).chm

    注:下载后,评价时给5星,还你11分 Table of Contents Introduction to Algorithms, Second Edition Preface Part I - Foundations Chapter 1 - The Role of Algorithms in Computing ... List of Exercises

    ACT4E_exercises-7.3.2310261700-py3-none-any.whl.zip

    标题中的"ACT4E_exercises-7.3.2310261700-py3-none-any.whl.zip"是一个软件包文件,它采用的是Python的Wheel(whl)格式,这是一种预编译的Python软件包格式,便于在不同系统上快速安装和分发Python库。"7.3....

    算法导论习题答案

    《算法导论》是计算机科学领域的一本经典著作,它深入浅出地介绍了各种重要的算法,并提供了详尽的分析和实现。这本书对于学习算法、提升编程能力以及理解复杂度分析至关重要。"Solutions to selected exercises and...

    Exercism-exercises-in-Ruby.-ruby.zip

    Exercism_exercises_in_Ruby._ruby.zip Exercism_exercises_in_Ruby._ruby.zip Exercism_exercises_in_Ruby._ruby.zip Exercism_exercises_in_Ruby._ruby.zip Exercism_exercises_in_Ruby._ruby.zip Exercism_...

    【麻省理工大学】算法导论

    Chapter 4 - Recurrences Chapter 5 - Probabilistic Analysis and Randomized Algorithms Part II - Sorting and Order Statistics Chapter 6 - Heapsort Chapter 7 - Quicksort Chapter 8 - Sorting in...

    算法导论开放课程习题集一(英文版)

    - **来源**:《算法导论》(CLRS)第4章问题4.3-4 - **要求**:同上,完成习题并理解其背后的算法原理。 ##### Problem 1-1 - **主题**:渐进符号(Asymptotic Notation) - **要求**:对于下列每一条陈述,判断它...

    Java-Exercises---JetBrains

    从“Java-Exercises---JetBrains-main”这个文件名来看,这很可能是项目的主目录,包含了所有相关的源代码文件、测试文件以及可能的项目配置。在实际的编程练习中,通常会有如下结构: 1. **源代码文件**:Java源...

    现代农林英语-转基因植物-Reading-Exercises翻译-.doc

    【转基因植物:未来的粮食?】 转基因作物,全称为基因修饰作物,近年来在全球范围内引起了广泛关注。这类作物是通过现代生物技术,将外源基因插入到植物的DNA中,以赋予作物新的特性,比如抗虫性、抗病性、耐旱性...

    机器学习十大算法2:K-means

    标题“机器学习十大算法2:K-means”和描述“机器学习十大算法2:K-means,英文原著,需要的同学可下载学习。”表明本文档的重点在于介绍一种名为K-means的机器学习算法,它是十大机器学习算法之一。K-means是一种...

    Pandas_exercises-master.rar

    本篇将基于"Pandas_exercises-master"压缩包,详细介绍通过Pandas进行数据分析的基本操作和技巧,旨在帮助初学者通过实战提升对Pandas的理解。 一、Pandas基础知识 1. DataFrame与Series:Pandas的核心数据结构是...

    Java-Exercises---Methods

    "Java-Exercises---Methods"这个标题暗示了我们即将探讨的是关于Java编程中的一个核心概念——方法。在Java中,方法是封装代码逻辑的单元,它们可以被多次调用,以实现代码的复用和模块化。 1. **方法定义**:在...

Global site tag (gtag.js) - Google Analytics