Data Journey

International Studies Grad. racing for AI Engineer

Download as .zip Download as .tar.gz View on GitHub
16 January 2021

Binary Heaps: Implementation

by mervyn

Perfect Binary Trees

A perfect binary tree of height h is a binary tree where

perf

Complete Binary Trees

We require binary trees which are

comp

We may store a complete tree using an array:

Array Implementation

A breadth-first traversal yields: If we associate an index-starting at 1-with each entry in the breadth-first traversal, we get:

heapimp

Given the entry at index k, it follows that:

Runtime Analysis

Binary Max Heaps

A binary max-heap is identical to a binary min-heap except that the parent is always larger than either of the children

max

source “K-MOOC 허재필 교수님의 <인공지능을 위한 알고리즘과 자료구조: 이론, 코딩, 그리고 컴퓨팅 사고> 강좌의 9-2 힙 자료구조의 구현 및 복잡도 중(http://www.kmooc.kr/courses/course-v1:SKKUk+SKKU_46+2020_T1)”

back next

tags:

Comments

Post comment
Loading...

Share this: