Articles for category: Data Structures and Algorithms

Analysis of Algorithm

An algorithm is a step-by-step set of instructions, which are meaningful and used to solve any particular problem. To perform every process, there is a set of Algorithms, which lets us know how to proceed with the problem and solve it in some steps. The analysis of an algorithm is a technique that measures the performance of an ...

Delete a Node from Linked List

A linked list is a linear data structure that consists of nodes where each node has two fields. The first field is the data field, and the second field is the address field, which is a reference(link) to the next node. We can perform various functions in a linked list, like insertion, deletion, searching, sorting, and many ...

Arithmetic Progression

A progression is a sequence of numbers that shows a pattern. The arithmetic progression is the most widely used mathematical progression, and it occurs when the difference between every two consecutive terms in a series is same. It is also known as an arithmetic sequence. Let’s say we have a series of even numbers (2, ...

Types of Trees in Data Structures

A tree represents a hierarchical arrangement of nodes, forming a non-linear data structure. Each node in the tree holds a value and points to its child nodes, creating a branching structure akin to a natural tree. This hierarchical organization facilitates efficient storage and retrieval of data. Types of Trees in Data Structure According to the ...

How to Reverse a Stack Using Recursion?

Given a stack, write a program to reverse the order of the elements inside the stack using recursion. The element at the top should be moved to the bottom and so on. This program must use only standard stack operations – push(item), pop(), top(), size(), and isEmpty(). Example: Input: $23, 56, 82, 90$ Output: $90, ...

Strassen’s Matrix Multiplication

Problem Statment Consider two matrices X and Y each of the size N*N. We want to calculate the resultant matrix Z which is formed by multiplying the given two matrices i.e, X and Y. Example Let’s consider the below matrices for multiplication. Matrix A has a size N*M and matrix B has a size A*B. ...

Suffix Arrays

Suffix arrays are very powerful data structures in terms of their applications in the field strings and string algorithms like pattern searching, string matching algorithms, the longest common prefix of two strings, counting the number of substrings, and in the field of biology some problems like DNA sequencing which uses suffix arrays to efficiently find the ...

Remove Duplicates from an Unsorted Linked List

Problem Statement Write a program to delete duplicate nodes present in an unsorted linked list. Print the original linked list, and the linked list obtained after the deletions. Example Consider the following linked list : After you remove duplicates from the linked list : Example Explanation The given unsorted linked list is : There are multiple occurrences ...

Subarray with Given Sum

Problem Statement An unsorted array nums and an integer sum k is given. Array has non- negative integers in it. Find out the continuous subarray which elements sums up to the given sum. There can be multiple such subarray with given sum, print out the first such subarray with given sum. If the subarray with ...