Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik.
-
Upload
valentina-zane -
Category
Documents
-
view
255 -
download
13
Transcript of Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik.
![Page 1: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/1.jpg)
Data StructuresLesson10
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
Binary Trees &
Search Trees
![Page 2: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/2.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INTRODUCTION • Ordered Tree: The sequence of
node is important • Unordered Tree: The sequence of
node is not important • Equal Tree: if two unordered trees
have the same subsets, then they are equal; but as ordered trees, they won’t be equal unless their equal subtrees are in the same order.
![Page 3: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/3.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INTRODUCTION (2)• A binary tree is an ordered tree in
which every internal node has degree 2 (left sub tree and right sub tree)
• An empty left sub tree is different from an empty right sub tree.
• Complete Binary Tree: Either a full binary tree or one that is full except for a segment of missing leaves on the right side of the bottom level.
• Forest: Sequence of disjoint ordered trees.
![Page 4: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/4.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
EXAMPLEUnequal Ordered Tree:
Unequal Binary Tree:
![Page 5: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/5.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
EXAMPLE (2)Complete binary trees:
![Page 6: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/6.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
MAPPINGA COMPLETE BINARY TREE
INTO AN ARRAY
![Page 7: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/7.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
MAPPINGA COMPLETE BINARY TREE
INTO AN ARRAY (2)
![Page 9: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/9.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
SEARCH TREE
mlow = smallest key in the M (middle) subtreerlow = smallest key in the R (right) subtree
![Page 10: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/10.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
SEARCH TREE EXAMPLE
Five-Way Search Tree
![Page 11: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/11.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INSERTING INTOFIVE-WAY SEARCH TREE
![Page 12: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/12.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INSERTING INTOFIVE-WAY SEARCH TREE (2)
![Page 13: Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik.](https://reader033.fdocuments.in/reader033/viewer/2022061618/56649c755503460f94928750/html5/thumbnails/13.jpg)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INSERTING INTOFIVE-WAY SEARCH TREE (3)