Articles for category: Data Structures and Algorithms

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 ...

Line Sweep Algorithm

The line sweep algorithm is based on the idea of using a vertical imaginary line that moves in the rightward direction upon the occurrences of certain events defined by the current problem at hand. The line sweep algorithm is used to solve problems such as closest pair, line segment intersections, the union of rectangles, convex hull, Manhattan ...

Isomorphic graph

This article explains the concept of isomorphism in graph data structures. A pair of given graphs are said to be isomorphic graphs if they are structurally equivalent. It means there exists a mapping(bijection) between the vertices of the two graphs. Using this mapping, one graph can be converted into the other by replacing its vertices ...

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 ...

How to Convert Infix to Prefix Notation?

An infix expression is one that we use regularly. A single letter or operator followed by one infix string and another infix string makes up an infix expression such as A, A + B, and (A + B) + (C – D). Therefore, there are operators between operands in this. If the operator appears in an expression before the ...