# Lecture 11 Binary Search Tree Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.

## Presentation on theme: "Lecture 11 Binary Search Tree Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1."— Presentation transcript:

Lecture 11 Binary Search Tree Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1

» Structure » Terminology » Tree Variation » Action » Insert » Traverse » Search » Delete » Exercises 2 © Sekolah Tinggi Teknik Surabaya

3

4 5 5 3 3 8 8 2 2 4 4 9 9

5

6 Subtree 5 5 3 3 8 8 2 2 4 4 9 9 root leaf

© Sekolah Tinggi Teknik Surabaya 7

» Binary Search Tree » Ternary Search Tree » Red Black Tree » AVL Tree (Adelson-Velskii dan Landis) » etc 8 © Sekolah Tinggi Teknik Surabaya

9

» Insert » Traverse  Show all elements » Search  Find its element » Delete 10 © Sekolah Tinggi Teknik Surabaya

11

» If root is null ˃New node is root » Else ˃Find empty position ˃Locate New Node to there » In a binary tree, a small number will go on the left, while a large number will be entered in the right 12 © Sekolah Tinggi Teknik Surabaya

13

» Breadth First Search ˃Search Widens ˃Using Queue » Depth First Search ˃Search Depth ˃Do recursively ˃There are 3 types: +Pre-order traversal +In-order traversal +Post-order traversal 14 © Sekolah Tinggi Teknik Surabaya

15

» Done by utilizing the Traverse action. 16 © Sekolah Tinggi Teknik Surabaya

17

» Find the node to be deleted, reffered to as del_node » If del_node don’t have children, remove immediately » But if del_node had one child, point the pointer parent to a child of del_node » But if del_node had two children: ˃Option 1: find the rightmost child of the left subtree, referred to as the replacer; ˃Option 2: find the leftmost child of the right subtree, referred to as the replacer; ˃Replace del_node with replacer 18 © Sekolah Tinggi Teknik Surabaya

19

Implement Binary Search Tree in C#.NET 20 © Sekolah Tinggi Teknik Surabaya

» Andrew Troelsen, Pro C# and The.Net 4.5 Framework (Sixth Edition), Apress, 2012 » http://en.wikipedia.org/wiki/Binary_tre e http://en.wikipedia.org/wiki/Binary_tre e 21 © Sekolah Tinggi Teknik Surabaya

Download ppt "Lecture 11 Binary Search Tree Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1."

Similar presentations