Articles for category: Data Structures and Algorithms

What is the Structure or Format of Data Called?

The structure or format of data is called the Syntax, which is defined by various combinations of pre-defined symbols in a programming language. What is Syntax? A Syntax in a programming language is the set of rules that defines a particular language, by defining the correct arrangements of the symbols which are pre-defined in a particular language eg: “;” , “->” , ...

What is Hamming code?

When we are transmitting data from sender to receiver, there might be a chance of error in the data while transmitting, Hamming code is the set of codes that helps in error detection as well as error correction in the data during transmission. The prerequisite for understanding the basics of error detection and correction can ...

What are Data Structures in C?

Data Structures in C is a way of storing and organizing data in the computer memory so that it can be processed efficiently. Using the data structures in C, we can make our program to be able to utilize the memory efficiently as well as improve it’s performance. Depending on how the elements are organized ...

Types of Binary Tree

Binary trees are a fundamental data structure with various types. The two primary types of binary tree are full binary trees, where each node has either two children or no children, and complete binary trees, which are filled from left to right at each level. Additionally, there are balanced types of binary tree, such as ...

Triplet Sum in Array

Problem Statement An array of integers and a target sum are given, find out if there is any triplet whose sum is equal to the given target sum exists in the array or not, print the triplet, if a triplet sum in array is present and return true. Otherwise, return false. Example Input-1 Output-1 Explanation ...

Uniform-Cost Search Algorithm

The Uniform Cost Search Algorithm is a search algorithm to find the minimum cumulative cost of the path from the source node to the destination node. It is an uninformed algorithm i.e. it doesn’t have prior information about the path or nodes and that is why it is a brute-force approach. What is the Uniform ...

Wave Array

Problem Statement Sort an unsorted array arr of length n in a waveform. An array is said to be in wave form if it satisfies the following conditions: Example Example Explanation Input: arr = [7, 7, 11, 3, 4, 5, 15] Output: [4, 3, 7, 5, 11, 7, 15] or any other array in wave form. Explanation: In the ...

Two Pointer Algorithm

A reference to an object is a pointer. In some circumstances, memory-mapped computer hardware or another value located in computer memory is the value that is stored in that object’s memory address. To put it another way, a variable with an array’s address is likewise a pointer. As an example, we estimated the size of ...

Trapping Rain Water Problem

Problem Statement The width of each and every bar on to an elevation map is 1. Determine how much water it can hold after it rains by computing the heights of the elevation map bars, which are represented by n non-negative integers. Example Input: Output: Example Explanation Representation of above input heights is given below in ...

Ugly Numbers

Problem Statement We are provided with a number n. We need to print the n-th ugly number. An ugly number is a number whose prime factors are 2, 3, or 5 only. Note: $1$ is considered as an ugly number (conventionally). Refer to the Example and Explanation sections for more details and the Approach section ...