Articles for author: Taneesha Mathur

Longest Palindromic Substring

Problem Statement The Longest Palindrome in a String in one of the most classic problems in DSA. The problem statement goes like this: Given a string, find the maximum length substring of it that is a palindrome. Input: String Output: String Before we move on to examples and the solution to this problem, make a note of the ...

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

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

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

Sieve of Eratosthenes

The Sieve of Eratosthenes is a classic method for efficiently finding prime numbers up to a given limit, crucial in cryptography for securing data like credit card numbers. This ancient algorithm sieves out non-prime numbers, leaving behind the primes. By understanding this algorithm, we unlock a powerful tool for various mathematical applications, from fraction conversion ...

Topological Sorting

Topological sorting arranges vertices in a Directed Acyclic Graph (DAG) linearly, ensuring for every edge u-v, u precedes v. Crucially, this sorting is exclusive to DAGs; cyclic graphs defy this ordering. Integral to graph theory, the Topological Sort Algorithm finds applications in project scheduling, dependency management, and compiling. This method’s exploration unveils its mechanics and ...

1-D Dynamic Programming Problem

1 dimensional dynamic programming(DP) problems are problems that can be solved with the use of DP on a 1-D (1-dimensional) array. Scope of Article Takeaways Approach to solving 1-D DP problems: What is a 1-D Dynamic Programming Problem? Before we move to discussing a 1D dp problem, let’s define dp -- dynamic programming. Dynamic programming ...

Minimum Number of Jumps to Reach End

You are given with the array of positive integers and asked to find the minimum number of steps or jumps required to reach the end. Takeaways Excellent problem to learn time and space complexity optimization in dynamic programming problem. Problem Statement The problem statement that is given to us, is — You are given an array ...

The Knuth-Morris-Pratt (KMP) Algorithm

The Knuth-Morris-Pratt (KMP) algorithm revolutionized string matching by achieving linear time complexity, denoted as O(n). Introduced in 1970 by Knuth, Morris, and Pratt, this algorithm efficiently identifies patterns within text by employing a ‘Prefix Table,’ alternatively known as the LPS (Longest Proper Prefix which is also Suffix) Table. Unlike traditional methods, KMP avoids redundant comparisons, ...

Median and Order Statistics

The median is essentially the “halfway point” of the set of data. Order statistics are sample values placed in ascending order. The study of order statistics deals with the applications of these ordered values and their functions. Takeaways The distribution function for the Yi order statistic derived using the binomial distribution is Introduction to Median and Order Statistics On normal occasions, would ...