Lecture 7-8

[toc]

Lecture 7-8

P4.Binary tree

  • 二叉树的基本操作

P5.Binary search tree

  • 什么是balance search tree、大小关系、给出一个不平衡的->平衡
  • 练习题:p28

P20.Tree balance

  • 如何判断一棵树是否平衡
  • We say that a binary tree is balanced if the height difference between the right and left subtree of all its nodes is not greater than one.

P29.Inserting

  • 要会操作

P30.Splay trees(肯定考)

  • 考步骤、会插入删除

threes types of rotations(题目中会给出)

[图片上传失败...(image-6fde52-1547562446283)]

  • 在zig-zig中先转哪个得先看清楚

P58.Red-black trees(肯定考)

  • 掌握四条定义、会判断是否是红黑树
  1. Every is either red or black
  2. The root and NILs are all black
  3. If a node is red, its children should be black.
  4. 每一条路径上的黑色的节点个数都相同. Every path from a node to a leaf must contain the same number of black nodes.

如果parent为黑色,直接插入即可;否则根据以下规则进行变换。

               O  grandparent
              / \
      uncle  O   O   parent
                /
              Z

新增的节点都是赋予红色的。(一次变换后,还需要进行检查)

  1. Z = root --- recolor (只有这种情况新增节点变颜色)
  2. Z.uncle = Red --- recolor(parent+grandparent+uncle)
  3. Z.uncle = Black(triangle) --- rotate parent 转到一条线上
  4. Z.uncle = Black(line) --- rotate grandparent + recolor(parent+grandparent)

suffix tree

  • suffix 有很多

    • s = abaaba$
      • $
      • a$
      • ba$
      • aba$
      • aaba$
      • baaba$
      • abaaba$
  • suffix trie 树

    • 可以得到三个信息
      • 有没有
      • 有几个
      • 分别从哪边开始


        Image.jpg
  • 两个字符串判断公共的子串
    • 分别先往子串后面加上符号
    • 最后标上每一层X or Y or XY,找XY层数最多的,字符最长的,把边读出来就是最长子串


      Image2.jpg
Image3.jpg
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Brief news: from usatoday March 23 ,2018 Former officer c...
    江南_fyjk阅读 692评论 0 0
  • 有人说,小的时候,你哭,别人都会围过来安慰你;高中的时候,你哭,只有好朋友会关心你;上了大学以后,你哭,没有人会问...
    Dear小怪兽阅读 166评论 0 0
  • 当往事已成过去 我深深地遗憾 为你 为我 为那并不美的结局 当逝去的风吹过 我在回忆里排版 为你 为我 为那残缺的...
    在路上Cici阅读 396评论 0 2
  • 某些时候,对待一座城市的感情,就像爱情。因为熟悉所以厌倦,也是因为熟悉,所以依赖,所以不愿离开。 ――题记 ...
    却无岁月可回头阅读 530评论 9 9
  • 这个故事是关于我的一个自信的讲师朋友,她以前可以没有那么自信,是经历了一些事情后她才有了些变化的。 事情是这样的,...
    柚孑君阅读 326评论 0 9