Articles for category: Data Structures and Algorithms

Longest Common Prefix

The common prefix between the two most dissimilar strings is the longest common prefix for an array of strings. For instance, there is no common prefix in the array apple, ape, and zebra since the two most distinct strings in the array, “ape” and “zebra,” do not share any initial letters. In this article, we will learn about the ...

Largest Subarray with 0 Sum

Problem Statement Given the array $ar[]$ of size, $n$ has positive and negative integers. From the array $ar[]$, find the length of the largest subarray having a 0 sum. As we have to find the length of the largest subarray. So, first of all, it is required to understand what is a subarray Subarray :A ...

Merge K Sorted Arrays

Problem Statement k number of arrays are given, the task is to merge all the given integer arrays in such a manner that the resultant array is sorted in the runtime only. Note: arrays are of equal size. Example: Output: Explanation The array at the output is sorted by combining elements of all the three ...

How to Sort a Stack ?

Sort a stack involves the task of arranging the elements within a stack in a specific order, either ascending or descending, using only a limited set of stack operations like push, pop, and peek. The goal is to achieve this sorting without utilizing extra data structures, such as arrays or lists. The challenge lies in ...

Huffman Coding

When you want to send files or store the files on a computer, if the size is very huge we generally compress it and store it. One way of compressing these files is using Huffman Coding which is a greedy-based algorithm that is also known as variable-length coding or lossless data compression technique. Introduction to ...

Difference between Search Engine and Web Browser

The terms “web browser” and “search engine” are associated with the Internet. A web browser is an application software used to load HTML files, such as online pages, whereas a search engine is essentially a tool for accessing information on the Internet. Learn more about search engines and web browsers in this article, including how ...

Directed Graph

A graph is a non-linear data structure. It consists of several nodes, also referred to as vertices. The nodes of a graph are connected through edges. A graph in which there’s associated a sense of a specific direction with each edge is referred to as a directed graph. Directed graphs, from graph theory, are extensively used ...

Fizz Buzz Program

The FizzBuzz problem, a common coding exercise, involves iterating from 1 to n. For each integer, print “Fizz” if it’s a multiple of 3, “Buzz” if a multiple of 5, “FizzBuzz” if divisible by both 3 and 5, and the number itself if none of these conditions apply. Creating a FizzBuzz program efficiently handles these ...