Heap and Deap Flashcards

1
Q

what is Heap?

A

a complete binary tree based data structure that satisfies heap property. lebih MUDAH pake ARRAY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

jenis heap property?

A
  1. min heap, yang paling kecil diatas

2. max heap, yang paling besar diatas

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

implement heap dengan?

A

dapat dengan linked-list, tapi lebih mudah pake array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Heap Sort complexity?

A

O(n.lg(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Heap applications?

A

Priority Queue

djikstra, prim

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Heap merupakan implementasi yang efisien dari?

A

Priority Queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Heap, root di index keberapa?

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

array implementation pada Heap. parent(x), left-child(x), right-child(x) apa rumusnya?

A
parent(x) = x / 2
left-child(x) = 2 * x
right-child(x) = 2 * x + 1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Heap Complexity?

A
find-min = O(1)
insert = O(log(n))
delete-min = O(log(n))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Min-Max Heap?

A

Root merupakan smallest element. largest element bisa sebelah kiri atau kanan anak dari root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Deap adalah?

A

double ended heap. mirip dengan min-max heap. algorithm lebih simple dari min-max heap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Deap properties?

A
  1. root contains no element
  2. left sub-tree of root is a min heap
  3. right sub-tree of root is a max heap
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Pengaplikasian Heap?

A
  1. priority queue
  2. selection algorithm (finding min/max element, median, k-th largest element)
  3. dijkstra algorithm
  4. prim algorithm
  5. heap sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

upheapmax?

A

compare current node with its grandparent value, if current node larger = swap. continue upheapmax from the granparent node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

upheapmin?

A

compare current node with its grandparent value, if current node smaller = swap. continue upheapmin from the granparent node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

new node in min-level, INSERTION MIN-MAX?

A

if new node parent smaller than swap their value and UPHEAPMAX from its parent.
else UPHEAPMIN

17
Q

new node in max-level, INSERTION MIN-MAX?

A

if new node parent larger than swap their value and UPHEAPMIN from its parent
else UPHEAPMAX