In this post, we will discuss various methods to dynamically allocate memory for 3D array in C using Single Pointer and Triple Pointer.
Given an array of integers, find equilibrium index in it.
Given an array containing only 0’s, 1’s and 2’s, sort the array in linear time and using constant space.
Given a Binary Tree, determine if it is a BST or not. This problem has a simple recursive solution. The BST property “every node on the right subtree has to be larger than the current node and every node on the left subtree has to be smaller than the current node” is the key …
Given a binary tree, write an efficient algorithm to find maximum sum root to leaf path i.e. maximum sum path from root node to any leaf node in it.
Given a binary tree, write iterative and recursive solution to traverse the tree using pre-order traversal in C++ and Java. Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (pre-order, in-order, and post-order) or breadth-first order …
Given a binary tree, write an efficient algorithm to convert binary tree to its mirror.
Given a binary tree, in-place convert it to its sum tree. In a sum tree, value at each node is equal to the sum of all elements present in its left and right subtree. The value of an empty node is considered as 0.
Given a binary tree, print its nodes level by level in reverse order. i.e. all nodes present at last level should be printed first followed by nodes of second-last level and so on.. All nodes for any level should be printed from left to right.
In this post, we will see how to detect cycle in a a linked list using Hashing and Floyd’s Cycle Detection Algorithm.
Given a linked list and a positive integer K, find K’th node from the end in a linked list.
Given a linked list, reverse every adjacent group of k nodes in it where k is given positive integer.