Join 75,000+ students acing their exams with Studygenie
Unlimited practice
Flashcards, multiple choice and written questions, as many as you want.
Study sets in seconds
Turn your notes and files into a set with AI.
See your progress
Always know what you've learned and what's left.
Questions in this set (10)
what does a priority queue ADT consists of?
data and associated number as priority
is hash table good data structure to implement priority queue?
inserting takes O(1) while finding highest priority takes O(n). Its not good because multiple entries could have same priority while the keys in hash table are unique
time complexity of heap?
for both inserting and retrieveMax is O(logn)
Whats a full tree?
every row except the last has exactly 2 children. has 2^h+1 - 1 nodes
whats a complete tree?
if all rows before the last are full and nodes in the last row are arranged in the far left
what's the height of complete tree that contains n nodes?
its heigh < log2 n. heigh of complete binary tree is O(logn)
index of left/right child and parent?
left: 2i + 1
right: 2i +2
parent: round to lowest [(i - 1)/2] unless i = 0
What is heapify?
process of swapping root entry with the larger of 2 child and repeat