All Medium Articles
Following questions have been asked in GATE 2012 exam. 1. A process executes the code fork (); fork (); fork (); The total number of… Read More
We have discussed AVL insertion in the previous post. In this post, we will follow a similar approach for deletion. Steps to follow for… Read More
Given a Binary Tree, find the vertical sum of the nodes that are in the same vertical line. Print all sums through different vertical lines.Examples:  … Read More
AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for… Read More
Most of the times declarations are simple to read, but it is hard to read some declarations which involve pointer to functions. For example, consider… Read More
Given two strings str1 and str2, write a function that prints all interleavings of the given two strings. You may assume that all characters in… Read More
Given a string of length n, print all permutations of the given string. Repetition of characters is allowed. Print these permutations in lexicographically sorted order … Read More
Given a Doubly Linked List which has data members sorted in ascending order. Construct a Balanced Binary Search Tree which has same data members as… Read More
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The problem is not actually to perform the multiplications, but… Read More
Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = {… Read More
Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1,… Read More
Given a Binary Tree where each node has the following structure, write a function to populate the next pointer for all nodes. The next pointer… Read More
Write a function to count number of smaller elements on right of each element in an array. Given an unsorted array arr[] of distinct integers,… Read More
Write a function to connect all the adjacent nodes at the same level in a binary tree. Structure of the given Binary Tree node is… Read More
Given two integers k and n, write a function that prints all the sequences of length k composed of numbers 1,2..n. You need to print… Read More
Predict the output of following C program. int main(void) {     struct str     {         int i: 1;         int j: 2;         int k: 3;         int l: 4;… Read More
Given an array A[0 … n-1] containing n positive integers, a subarray A[i … j] is bitonic if there is a k with i <=… Read More
Predict the output of following C programs:Difficulty Level: Rookie Question 1   C #include<stdio.h> int main() {     int arr[] = {10, 20, 30, 40, 50, 60};     int… Read More
Given a string str, find the length of the longest substring without repeating characters.  For “ABDEFGABEF”, the longest substring are “BDEFGA” and “DEFGAB”, with… Read More
In the previous post on trie we have described how to insert and search a node in trie. Here is an algorithm how to delete… Read More