CPSC 259 FInal

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions
Get a hint
Hint

Binary Heap

1 / 17

flashcard set

Earn XP

Description and Tags

please let me pass

18 Terms

1

Binary Heap

Complete Binary Tree

New cards
2

Hashing Formula

knowt flashcard image
New cards
3

Binary Heap: Min Heap

Value of a node is no greater than its childrens values

New cards
4

Binary Heap: Max Heap

Value of a node is at least as large as its childrens values

New cards
5

Perfect tree

full and complete

New cards
6

full tree

every node has 0 or 2 childrena binary tree where every node has either zero or two children

New cards
7

complete tree

all leaves are full except last level

New cards
8

max nodes in a tree

n = (k^h-1)/(k-1)
n = max nodes

k = #ary

h = height

New cards
9

min heap formulas

child >= parent

<p>child &gt;= parent</p>
New cards
10

remove min/max for heap

  1. replace root with last in array

  2. bubble down

    1. for min heap swap with smaller child (child >= parent)

    2. max heap swap with bigger child (parent >= child)

New cards
11

insertion for heaps

  • Add the new element to the end of the heap (next available position).

  • Bubble up the new element to restore the heap property:

New cards
12

PreOrder Traversal

knowt flashcard image
New cards
13

InOrder Traversal

knowt flashcard image
New cards
14

PostOrder Traversal

knowt flashcard image
New cards
15

max nodes in a tree

knowt flashcard image
New cards
16

height of a tree

knowt flashcard image
New cards
17

max size of a tree

knowt flashcard image
New cards
18

setting up a dummy node with malloc

struct listNode* result = = (struct ListNode*)malloc(sizeof(struct ListNode));

New cards
robot