Difference between Stack and Queue Data Structures

Stack A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the… Read More »

Difference between Singly linked list and Doubly linked list

Introduction to Singly linked list : A singly linked list is a set of nodes where each node has two fields ‘data’ and ‘link’. The… Read More »

Maximum number of leaf nodes that can be visited within the given budget

Given a binary tree and an integer b representing budget. The task is to find the count of maximum number of leaf nodes that can… Read More »

Johnson’s algorithm for All-pairs shortest paths | Implementation

Given a weighted Directed Graph where the weights may be negative, find the shortest path between every pair of vertices in the Graph using Johnson’s… Read More »

FIFO (First-In-First-Out) approach in Programming

FIFO is an abbreviation for first in, first out. It is a method for handling data structures where the first element is processed first and… Read More »

FIFO vs LIFO approach in Programming

Prerequisite – FIFO (First-In-First-Out) approach in Programming FIFO is an abbreviation for first in, first out. It is a method for handling data structures where… Read More »

Sentence that contains all the given phrases

Given a list of sentences and a list of phrases. The task is to find which sentence(s) contain all the words in a phrase and… Read More »

Check if two trees have same structure

Given two binary trees. The task is to write a program to check if the two trees are identical in structure. In the above figure… Read More »

UGC-NET | UGC NET CS 2018 July – II | Question 70

Consider a hash table of size seven, with starting index zero, and a hash function (7x+3) mod 4. Assuming the hash table is initially empty,… Read More »

Advantages of vector over array in C++

We have already discussed arrays and vectors. In this post, we will discuss advantages of vector over normal array. Advantages of Vector over arrays :… Read More »

Data Structures and Algorithms | Set 37

Que – 1. For 8 keys and 6 slots in a hashing table with uniform hashing and chaining, what is the expected number of items… Read More »

Data Structures and Algorithms | Set 36

Que – 1. The function shiftNode() which takes as input two linked lists- destination and source. It deletes front node from source and places it… Read More »

Data Structures | Heap | Question 12

Which of the following Binary Min Heap operation has the highest time complexity? (A) Inserting an item under the assumption that the heap has capacity… Read More »

Data Structures | Linked List | Question 17

Consider the following function to traverse a linked list. filter_none edit close play_arrow link brightness_4 code void traverse(struct Node *head) {    while (head->next != NULL)… Read More »

Data Structures | Balanced Binary Search Trees | Question 13

Which of the following operations are used by Red-Black trees to maintain balance during insertion/deletion? a) Recoloring of nodes b) Rotation (Left and Right) (A)… Read More »