Articles for category: Data Structures and Algorithms

In Simple Chaining, What Data Structure is Appropriate?

Simple chaining (sometimes referred to as Separate chaining), is a collision resolution strategy followed in the concept of Hashing. As per the simple chaining strategy whenever there is a collision in HashTable, instead of looking for any other slot we prefer putting the data in the initial bucket i.e.i.e. generated by the hash function. So we would require some sort ...

Implementation of Queue Using Array

Problem Statement Write a program that implements the operations of queue using an array Implementation of Queue using Array Operations The queue is the linear data structure that works on the principle of FIFO( First In First Out). In queue insertion and deletion of elements takes place at two different ends. The addition of an element ...

Kosaraju Algorithm

Problem Statement Find all strongly connected components in O(V+E) time using Kosaraju’s algorithm. Strongly connected Component(SCC) – In a directed graph a strongly connected component is a component of the graph in which there is a path between every pair of vertices. Example Example of strongly connected component in a graph : Example Explanation In the above Example diagram ...

Huffman Coding

When you want to send files or store the files on a computer, if the size is very huge we generally compress it and store it. One way of compressing these files is using Huffman Coding which is a greedy-based algorithm that is also known as variable-length coding or lossless data compression technique. Introduction to ...

How to Sort a Stack ?

Sort a stack involves the task of arranging the elements within a stack in a specific order, either ascending or descending, using only a limited set of stack operations like push, pop, and peek. The goal is to achieve this sorting without utilizing extra data structures, such as arrays or lists. The challenge lies in ...

Difference Between Stack and Queue Data Structures

There are many data structures like arrays, linked lists, and trees that are used to organise the data in a particular manner. A stack and a queue are two other data structures that are used to organise data. Both of them are linear data structures, which means they store and retrieve the elements in a sequencial manner from the structure when required. Stack ...

Dynamic Data Structures

A data structure is a way of storing, organizing, and efficiently maintaining data concerning both time and space. Data structures can be of two types, static and dynamic data structures. Static data structures are the ones in which the size of the structure is predefined and fixed. On the other hand, dynamic data structures are the ones whose size ...

Graph Representation

Graphs, as non-linear data structures comprising nodes and edges, represent relationships between entities. Three classic graph representation in data structure include Adjacency Matrix, Adjacency List, and Incidence Matrix. While Adjacency Matrix offers fast edge retrieval but consumes more space, Adjacency List is space-efficient but slower for edge retrieval. Incidence Matrix is rarely used due to its inefficient space utilization and slower ...