Articles for author: Ramandeep

What is Gray Code?

Gray code is basically a binary number system in which the successive binary numbers differ by exactly one bit. We can write a sequence of binary numbers for any K bits as a grey code sequence.For example, the sequence of 3-bit binary numbers is 000,001,011,010,110,111,101,100 where each consecutive numbers differ by exactly one bit. Unlike ...

Suffix Arrays

Suffix arrays are very powerful data structures in terms of their applications in the field strings and string algorithms like pattern searching, string matching algorithms, the longest common prefix of two strings, counting the number of substrings, and in the field of biology some problems like DNA sequencing which uses suffix arrays to efficiently find the ...

Reverse an Array

Problem Statement Given an array arr[] of length N, print the reverse of it. Example Consider the following example: After reversing this array,we have the new array as Example Explanation The initial array [1,2,3,4,5] when reversed gives [5,4,3,2,1]. Constraints $1 <= N <= 10^5$ There N is the length of the array. Approach 1- Recursive ...

Sparse Matrix

Sparse matrices are very useful entities in computer science, they appear in the fields of computer graphics, recommender systems, machine learning, information retrieval, maps and graph-based applications, social networks to count a few. So sparse matrices are very useful in computer science as they appear so frequently, Hence, we will be addressing questions like what ...

Treap

Treap is a very useful data structure in computer science, it is used to solve various problems like connectivity problems, range query problems and can be used as good alternatives to segment trees/sparse tables and splay trees in some of the scenerios as they are relatively also easier to code.It uses randomization of nodes which ...

2D DP Problems

In this article, we shall discuss the most important and powerful programming technique known as dynamic programming which is quite useful in solving problems in coding contests and comes as an improvement over the brute-force, recursive/backtracking solutions which gives exponential time complexity. Dynamic programming technique indeed improves the time complexity but at the cost of ...

Hamiltonian Path

In graph theory, there are different types of walks, paths, and cycles that can be observed in connected graph components like Hamiltonian Path, Euler’s Path, Euler’s Circuit which is named after Euler as he defined them first. These paths and circuits commonly appear in different problems. Hamiltonian Paths are simply a permutation of all vertices ...

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