
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1862 Articles for Data Structure

279 Views
The aim of this article is to implement a program to check if a given String is K-periodic for all K in range [1, N]. The aim is to determine whether the supplied string is K-periodic provided the string s and the integer K. If a string repeats the sub-string str[0... k-1], it is said to be k-periodic; for example, the string "ababab" is 2 periods long. Print Yes if the supplied string is k-periodic; otherwise, print No. If a character string can be created by concatenating at least one repeats from another string of length k, it is said ... Read More

146 Views
Problems involving grids and matrices are mostly solved using either BFS or DFS traversal algorithms. Taking a look into the first one, Breadth First Traversal − BFS or Breadth First Traversal is an algorithm for searching a tree or a graph data structure. It starts at the root node and explores all the nodes at the present level before moving on to the next level. Algorithm procedure BFS(G, root) is let Q be a queue label root as explored Q.enqueue(root) while Q is not empty do ... Read More

179 Views
Reducing an array to a single element by repeatedly removing element is done by the following criteria − Select indices i and j such that i < j and arr[i] < arr[j] and convert one of the two elements to 0. Problem Statement Given an array arr[] containing positive integers. Find if the array can be reduced to a single element by repeatedly removing an element from any increasing pair. If possible return true along with the indices chosen and the index of the element that is removed. Sample Example 1 Input arr[] = {5, 7, 10, 2, 4, ... Read More

97 Views
Recurrence Relation − In mathematics, recurrence relation refers to an equation where the nth term of the sequence is equal to some combination of the previous terms. For a recurrence relation where each term equals the product of previous K terms, let’s define N and K along with an array arr[] containing the first K terms of the relation. Thus, the nth term is given by − $$\mathrm{F_N= F_{N−1} ∗ F_{N−2} ∗ F_{N−3} ∗ . . .∗ F_{N−K}}$$ Problem Statement Given two positive integers N and K and an array of integers containing K positive integers. Find the Nth term ... Read More

171 Views
A subarray is a contiguous part of an array i.e. it can be considered as an array inside another array. For example, take the following array, array[] = {1, 2, 3, 4, 5, 6} For the above array, one possible subarray is subarry[] = {2, 3, 4} Problem Statement Given an array arr[] having N positive integers and a positive integer K representing the maximum number that can be added to the elements of the array. The task is to increment the elements of the array by most K increment operations and return the maximum possible ... Read More

136 Views
The N-ary tree is a tree data structure where each node can have a maximum of N children where N is a positive integer (N >= 0). N-ary trees are used in many applications like file systems, organisational charts and syntax trees in programming languages. Example of N-ary tree with N = 4. A / / \ \ B C D E / | \ ... Read More

245 Views
The Shortest Path Faster Algorithm is an improved or more optimized version of the Bellman-Ford Algorithm. It calculates the single source's shortest path in a weighted directed graph. This algorithm is especially suitable for graphs with negatively weighted edges. Algorithm Given a weighted directed graph and a source vertex , the algorithm finds the shortest path from , to each vertex , in the graph. The length of thh shortest path from to is stored in for each vertex . procedure Shortest-Path-Faster-Algorithm(G, s) for each vertex v ≠ s in V(G) ... Read More

186 Views
Even-Odd Tree − A binary tree is called an even-odd tree if all the nodes at the even level (taking root node at level 0) have even values and all the nodes at the odd level have odd values. Problem Statement Given a binary tree. The task is to check if the binary tree is an even-odd tree or not. Sample Example 1 Input 6 / \ 3 7 / \ ... Read More

66 Views
Level of a Binary Tree − In a binary tree, the level of the node refers to its distance from the root node. The root node is considered at level 0, its immediate children are at level 1, their children at level 2 and so on. Levels of a binary tree are explained in the following example, A

92 Views
Array insertion and reversal are one of the most common array manipulation techniques. Array manipulation aims to modify an array's contents to get a desired outcome. Problem Statement Given an input array A[]. The task is to insert the elements of the given array into an existing array where a reversal of the output array follows each insertion. Sample Example 1 − Input: A[] = {1, 2, 3, 4, 5} Output: R[] = {5, 3, 1, 2, 4} Explanation Initially, the output array R[] is empty. Insertion of 1 : R[] = {1} Insertion of 2 : ... Read More