Divya Sahni has Published 42 Articles

Check if a path exists for a cell valued 1 to reach the bottom right corner of a Matrix before any cell valued 2

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 13:28:50

84 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 ... Read More

Reduce the array to a single element by repeatedly removing an element from any increasing pair

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 13:26:49

90 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. ... Read More

Nth term of given recurrence relation having each term equal to the product of previous K terms

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 13:24:35

44 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 ... Read More

Maximize the length of a subarray of equal elements by performing at most K increment operations

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 13:18:47

71 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} ... Read More

Difference between sums of odd level and even level nodes in an N-ary Tree

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 13:12:30

51 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 ... Read More

Detect a negative cycle in a Graph using the Shortest Path Faster Algorithm

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 13:07:40

106 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 ... Read More

Check if a Binary Tree is an Even-Odd Tree or not

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 13:01:21

111 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 ... Read More

Check if a Binary Tree contains node values in strictly increasing and decreasing order at even and odd levels

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 12:51:49

30 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 ... Read More

Array obtained by repeatedly reversing array after every insertion from the given array

Divya Sahni

Divya Sahni

Updated on 25-Oct-2023 12:50:05

37 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 ... Read More

Sum of an array using pthreads

Divya Sahni

Divya Sahni

Updated on 28-Sep-2023 15:20:41

561 Views

Pthreads is an execution model that helps use multiple processors to work at the same time for solving a problem. It is independent of the programming language. Problem Statement Given an array of integers. Find the sum of all the elements of the array using pthreads. Need for Multithreading for ... Read More

Advertisements