How to implement O(logn) decreasekey operation for minheap based Priority Queue?
Date : March 29 2020, 07:55 AM
With these it helps You can do following: store a hashmap inside your heap that maps your heap values to heap indexes. Then you should extend your usual heaplogic just a bit: on Swap(i, j):
map[value[i]] = j;
map[value[j]] = i;
on Insert(key, value):
map.Add(value, heapSize) in the beginning;
on ExtractMin:
map.Remove(extractedValue) in the end;
on UpdateKey(value, newKey):
index = map[value];
keys[index] = newKey;

balanced binary tree, order and between operation in O(logn)
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further But I ran into a challenge when I took an exam some days ago. , How to find the order of one given element? find(x, node)
if node is null return error
if node is x return node
if node < x return find(x, left(node)) else return find(x, right(node))
order(x, node, acc)
if node is null return acc
if node is x return acc + count(left(x))
if node < x return order(x, left(node), acc)
else return order(x, right(node) , acc + 1 + count(left(node)) )

Why is the merge function of binomial heaps O(logN) rather than O(logN * logN)?
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You probably don't understand the algorithm. When we have two trees of same order, we don't "merge (O (1)) it and insert (O (log N))". You think that when we get such "merged" tree we leave it and at the end, we insert it node by node, right? Then to make it O (logN): When you have two trees of order k, you merge them and get one tree of order k+1. Now, depending on how many k+1 order trees you have from heaps you are merging, you have one, two or tree k+1 order trees: if 1 this tree is just a part of the merged heap

Why is code like i=i*2 considered O(logN) when in a loop?
Date : March 29 2020, 07:55 AM
will be helpful for those in need Look at 1024 = 210. How many times do you have to double the number 1 to get 1024? Times 1 2 3 4 5 6 7 8 9 10
Result 2 4 8 16 32 64 128 256 512 1024

Analyze BIg O relation between weird math expressions (logN)^logN and n/logN
Tag : math , By : user130518
Date : March 29 2020, 07:55 AM

