Presentation is loading. Please wait.

Presentation is loading. Please wait.

Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik.

Similar presentations


Presentation on theme: "Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik."— Presentation transcript:

1 Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik

2 A heap is a complete binary tree which the keys along any path from root to leaf are descending. A heap is a complete binary tree which the keys along any path from root to leaf are descending. Every parent is older than its children. Every parent is older than its children. Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik

3

4

5 Elements are inserted into a heap next to its right-most leaf at the bottom level. Elements are inserted into a heap next to its right-most leaf at the bottom level. Move the new element up the tree until it is no longer “older” than its parent. Move the new element up the tree until it is no longer “older” than its parent. On each iteration, the child is swapped with its parent On each iteration, the child is swapped with its parent

6 Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik

7 Always removes the root element from the tree. Always removes the root element from the tree. Moving the last leaf element into the root element. Moving the last leaf element into the root element. Moving the new root element down the tree until it is no longer “younger” than its children Moving the new root element down the tree until it is no longer “younger” than its children

8 Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik

9

10 BIFO: Best In First Out BIFO: Best In First Out Each element is assigned a priority number. Each element is assigned a priority number. The element with the highest priority comes out first. The element with the highest priority comes out first. Example: shared printer queue Example: shared printer queue

11 Author: Takdir, S.ST. (takdir@stis.ac.id) © Sekolah Tinggi Ilmu Statistik


Download ppt "Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik."

Similar presentations


Ads by Google