Articles for author: Paras Yadav

Kargers Algorithm for Minimum Cut

In graph theory, a cut is a set of edges removal of which divides a connected graph into two non-overlapping (disjoint) subsets. The minimum cut (or min-cut) is defined as the minimum number of edges, when removed from a graph, divide the graph into two disjoint sets. A randomized contraction algorithm $i.e.$ Karger's Algorithm is ...

Open Addressing

Open Addressing, also known as closed hashing, is a simple yet effective way to handle collisions in hash tables. Unlike chaining, it stores all elements directly in the hash table. This method uses probing techniques like Linear, Quadratic, and Double Hashing to find space for each key, ensuring easy data management and retrieval in hash ...

Kruskal’s Algorithm

Kruskal's algorithm is a greedy algorithm in graph theory that is used to find the Minimum spanning tree (A subgraph of a graph $G(V,E)$ which is a tree and includes all the vertices of the given graph such that the sum of the weight of the edges is minimum) of a given connected, weighted, undirected ...

Fenwick Tree | Binary Indexed Tree

The Binary Indexed Tree, also known as the Fenwick tree, provides an efficient way to calculate prefix sums of a series of numbers, especially in scenarios where the values are mutable.Unlike prefix sum arrays, which excel in answering prefix sum queries but struggle with frequent updates, Fenwick trees offer a balance between efficient query answering ...

Queue

The Queue in data structure is an ordered, linear sequence of items. It is a FIFO (First In First Out) data structure, which means that we can insert an item to the rear end of the queue and remove from the front of the queue only.A Queue is a sequential data type, unlike an array, ...

Extended Sieve

Sieve of Eratosthenes is an ancient algorithm of mathematics that is used to calculate prime numbers belonging to a certain range of positive integers. The Extended sieve is a modification to the standard Sieve algorithm using which one can calculate prime numbers present in a larger range of numbers efficiently. Scope Takeaways Time complexity is ...

Sliding Window Maximum

Problem Statement Given an array aa, and an integer kk, find the maximum element for every contiguous subarray of size kk. Examples Example 1 Input : Output : Explanation : Example 2 Input : Output : Explanation : Constraints Approach 1: Brute Force The first approach that comes to our mind while reading the problem, is to run ...

Longest Palindromic Subsequence

Problem Statement Given a string ‘S’, your objective is to identify the length of the longest palindromic subsequence. In simpler terms, you’re tasked with finding the longest sequence of characters in ‘S’ that can be read the same forwards and backwards, but not necessarily in consecutive order. Example Approach-1: Using Recursive Solution Dry Run: Code ...

Maximum Flow and Minimum Cut

The max-flow min-cut theorem is a network flow theorem that draws a relation between maximum flow and minimum cut of any given flow network. It sates that maximum flow through any graph is exactly equal to minimum cut of the same graph. Due to which its application in a variety of areas, like in computing ...

A* Algorithm in AI

Search algorithms retrieve elements from data structures, essential for accessing specific items. Pathfinding, integral to this, determines optimal routes from one point to another. The A* algorithm stands out in artificial intelligence and computer science, efficiently finding optimal paths. Understanding A* is vital due to its pivotal role across various applications. What is A* Algorithm ...