Articles for author: Ayush Kumar

Diagonal Traversal of Binary Tree

Problem Statement Given a binary tree $A$ containing $n$ nodes, consider diagonals (lines with a slope of $-1$) passing between the nodes and print all the diagonal elements in the binary tree belonging to the same line. Note: The diagonals with a slope of $-45\text{ degree}$ angle, will be like a $\backslash$. This question has ...

Which Data Structure May Produce an Overflow Error?

Overflow error is an error that happens when a program receives a number, value or variable outside the scope of its ability to handle. Takeaways A linear queue can throw an Overflow error even if it has empty spaces for elements in it. Which Data Structure May Produce an Overflow Error? Correct Answer a. A Linear Queue can produce an ...

Manacher’s Algorithm

Manacher's algorithm is used to find the longest palindromic substring in any string. It is required to solve sub-problems of some very hard problems. The problem statement it solves is: Given a string 's' with the length of 'n'. Find the longest palindromic substring in the given string. A string is a palindrome when it ...

Primality Test

The Primality test is an algorithm for determining whether a given positive integer is a prime number or not.There are many methods to check whether a number is prime or not, like, the School Method, Trial Division Method, Fermat Primality test, and Miller-Rabin Primality test. Scope of the Article Takeaways Algorithm for determining whether a ...

Longest Consecutive Subsequence

Problem Statement We are given an unsorted integer array nums, and we have to find the length of the longest consecutive sequence of elements in it. The order of elements in the array shouldn’t matter as we are looking for a subsequence and not a subarray. For example, the longest consecutive subsequence in the array [8, 2, ...