Let us discuss a popular interview question-related DSA. The question is about ‘finding the minimum number of…
A binary array sorted in decreasing order is given. We need to count the number of 1’s in it.
Examples:
Input: arr[] = {1, 1…
Given two queues with their standard operations (enqueue, dequeue, isempty, size), implement a stack with its standard operations (pop, push, isempty, size).
enqueue
dequeue
isempty
size
pop
push
Let us start with the heapsort algorithm:
heap_sort(int Arr[]){ int heap_size = n;
build_maxheap(Arr); for(int i = n; i >= 2 ; i--) { swap(Arr[1], Arr[i])…
build_maxheap(Arr); for(int i = n; i >= 2 ; i--) { swap(Arr[1], Arr[i])