Articles for category: Data Structures and Algorithms

Best First Search

Best First Search is a heuristic search algorithm that selects the most promising node for expansion based on an evaluation function. It prioritizes nodes in the search space using a heuristic to estimate their potential. By iteratively choosing the most promising node, it aims to efficiently navigate towards the goal state, making it particularly effective ...

What Are Static and Dynamic Data Structures?

In static data structures memory is allocated at the compiler time for static data structures and user cannot change their size after being compiled but, we can change the data which is stored in them. In case dynamic data structure memory is allocated at the run time for dynamic data structure and the size of the dynamic data structures ...

Connect Nodes at Same Level

Given a Binary Tree, The task is to connect all the adjacent nodes at the same level starting from the left-most node of that level, and ending at the right-most node Scope This article help us know about how to Connect Nodes at Same Level. In this article we will learn connect nodes using the ...

Polish Notation

In this article, we will study polish notation in the data structure. Polish Notation in the data structure is a method of expressing mathematical, logical, and algebraic equations universally. This notation is used by the compiler to evaluate mathematical equations based on their order of operations. When parsing mathematical expressions, three types of notations are ...

Difference Between Array and Linked List

Arrays and Linked Lists are linear data structures that store data in memory. An array stores data elements in contiguous memory locations, thus allowing faster access using array indexes. In contrast, a Linked list contains a sequence of data elements where each element is linked to its next element with the help of pointers. In this article, we ...

Matrix Chain Multiplication

The number of multiplication steps required to multiply a chain of matrices of any arbitrary length $n$ highly depends on the order in which they get multiplied. As multiplication of two numbers/integers is a costly operation, it is very much needed to find the optimal order of multiplying a chain of matrices to minimize the ...

Segmented Sieve

Given a number N, print all the prime numbers less than N. Prime numbers are the numbers which are divisible by 1and itself only. Example: Input: Output: Example Explanation: The given input number is 12, and prime numbers which are smaller than 12 are only 2, 3, 5, 7, 11. So, they are printed. Constraints: ...

Digit DP

Digit Dp as the name suggests, is a technique of dynamic programming wherein we use the digits of the numbers to reach the final solution. This technique solves those problems which concern the digits between two specified integers. To find the solution, we try building all the integers between the two given integers and compute ...

Longest Consecutive Subsequence

Problem Statement We are given an unsorted integer array nums, and we have to find the length of the longest consecutive sequence of elements in it. The order of elements in the array shouldn’t matter as we are looking for a subsequence and not a subarray. For example, the longest consecutive subsequence in the array [8, 2, ...

Load Factor and Rehashing

Load factor is defined as (m/n) where n is the total size of the hash table and m is the preferred number of entries that can be inserted before an increment in the size of the underlying data structure is required. Rehashing is a technique in which the table is resized, i.e., the size of the table ...