Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik
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. © Sekolah Tinggi Ilmu Statistik
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
Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik
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
Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik
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
Author: Takdir, S.ST. © Sekolah Tinggi Ilmu Statistik