Articles for category: Data Structures and Algorithms

Balanced Parentheses

Check for balanced parentheses in the expression Scope This article tells how to check balanced parentheses using stack. In this article we will learn implementation in different programming language. In this article we will learn time complexity of the stack approach. Takeaways Balanced parentheses means that each opening symbol has a corresponding closing symbol and ...

Height of Binary Tree

Given with the binary tree, find the height of the tree. Height of the binary tree is one more than the largest number of edges in the path from the root node to the lowest level leaf node. Problem Statement We are given a binary tree as input and we need to find the height ...

Graph Traversal in Data Structure

A graph, a non-linear data structure represented by vertices (nodes) and edges, is defined as an ordered set (V, E) where V represents the set of vertices and E represents the set of edges connecting these vertices. Every pair of vertices is connected by one edge. Graph traversal, a fundamental operation in graph theory and ...

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

Flood Fill Algorithm

The main purpose of the flood fill algorithm is to trace out the bounded area with the same color. In this article, we will learn the working and implementation of the flood fill algorithm. Takeaways Flood fill is an algorithm mainly used to determine a bounded area connected to a given node in a multi-dimensional array. ...

Maximum Product Subarray

Problem Statement You are given a list of integers. Your task is to find and print the contiguous non-empty subarray that produces the largest product when multiplied together. A subarray is a sequence of consecutive and uninterrupted elements within an array. Example If Array = { -2, 6, 4 } All the possible non-empty contiguous subarrays of ...

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

Applications of Data Structure

To efficiently organize, analyze, store, and retrieve information from a computer, data structures are a specific manner of grouping data in a specialized format. They are a method of handling data that makes it simple to use. The foundation of every program, piece of software, or application of data structure is made up of two elements: algorithms and data. ...

What is Traversing in Data Structure?

Traversing in the data structure is a very important operation that can be performed on any data structure. Traversing in Data Structure means systematically visiting every element of it. Traversing is a process in which each element of a data structure is accessed. Accessing an element of data structure means visiting every element at least once. ...

Prefix Sum

Given an array arr of size n, the prefix sum is another array (say prefixSum) of same size such that for each index 0 <= i < n prefixSum[i] denotes a[0] + a[1] .... + a[i]. Scope This article tells about the prefix sum. In this article we will learn different approaches to find the ...