Find kth largest element in running stream of numbers
Given a running stream of numbers and a positive number k. Write code to print the kth largest element at any time:
Binary Heap
Binary heap is used to implement Priority queue. It is an array object, visualized as an almost complete binary tree. Binary heap comes in two flavours Max-Heap Min-Heap A max-heap is an almost complete binary tree, where, value at each node is greater than the value of its children. Similarly, a min-heap is an almost complete binary tree where […]
Almost complete Binary Tree
A complete Binary tree of height h has 2h-1 nodes. Out of these 2h-1 are leaf nodes and rest (2h-1-1 are non-leaf. Read more about complete binary trees here or watch video. Below are all complete binary trees: