## Data Structures | Queue | Question 3

How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.… Read More »

How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.… Read More »

Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity? (A) Insertion Sort (B) Quick Sort… Read More »

What does the following function do for a given binary tree? (A) Counts leaf nodes (B) Counts internal nodes (C) Returns height where height is… Read More »

What is the time complexity of Build Heap operation. Build Heap is used to build a max(or min) binary heap from a given array. Build… Read More »

Which of the following is correct recurrence for worst case of Binary Search? (A) T(n) = 2T(n/2) + O(1) and T(1) = T(0) = O(1)… Read More »

Which of the following is not a stable sorting algorithm in its typical implementation. (A) Insertion Sort (B) Merge Sort (C) Quick Sort (D) Bubble… Read More »

Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using… Read More »

What is recurrence for worst case of QuickSort and what is the time complexity in Worst case? (A) Recurrence is T(n) = T(n-2) + O(n)… Read More »

Consider the following code. The function myStrcat concatenates two strings. It appends all characters of b to end of a. So the expected output is… Read More »

Which of the following page replacement algorithms suffers from Belady’s anomaly? (A) FIFO (B) LRU (C) Optimal Page Replacement (D) Both LRU and FIFO Answer:… Read More »

What is the value of following recurrence. T(n) = 5T(n/5) + , T(1) = 1, T(0) = 0 (A) Theta (n) (B) Theta (n^2) (C)… Read More »

To calculate time taken by a process, we can use clock() function which is available time.h. We can call the clock function at the beginning… Read More »

We have introduced segment tree with a simple example in the previous post. In this post, Range Minimum Query problem is discussed as another example… Read More »

It’s not every day that you come across a person who has achieved so much in life at a very young age which others can… Read More »

What is the value of following recurrence. T(n) = T(n/4) + T(n/2) + cn^2 T(1) = c T(0) = 0 Where c is a positive… Read More »