author: takdir, s.st. ([email protected]) © sekolah tinggi ilmu statistik
TRANSCRIPT
Data StructuresLesson10
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
Binary Trees &
Search Trees
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.
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.
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
EXAMPLEUnequal Ordered Tree:
Unequal Binary Tree:
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
EXAMPLE (2)Complete binary trees:
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
MAPPINGA COMPLETE BINARY TREE
INTO AN ARRAY
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
MAPPINGA COMPLETE BINARY TREE
INTO AN ARRAY (2)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
EXPRESSION TREE
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
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
SEARCH TREE EXAMPLE
Five-Way Search Tree
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INSERTING INTOFIVE-WAY SEARCH TREE
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INSERTING INTOFIVE-WAY SEARCH TREE (2)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INSERTING INTOFIVE-WAY SEARCH TREE (3)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
B-TREE
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
EXAMPLE OF B-TREE ORDER 5
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
INSERTING INTO B-TREE
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
BINARY SEARCH TREES (BST)
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
BUILDING BST
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
AVL TREE
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
NON-AVL TREE
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
BUILDING AVL TREE
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
BUILDING AVL TREE EXAMPLE
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
AVL TREE ROTATION
Author: Takdir, S.ST. ([email protected]) © Sekolah Tinggi Ilmu Statistik
THANK YOU