資料結構中的最大堆插入
我們將在此處瞭解如何插入元素到二進位制最大堆資料結構中。假設初始樹形結構如下 −

插入演算法
insert(heap, n, item) − Begin if heap is full, then exit else n := n + 1 for i := n, i > 1, set i := i / 2 in each iteration, do if item <= heap[i/2], then break heap[i] = heap[i/2] done end if heap[i] := item End
示例
假設我們要向堆中插入 30 −

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP