## Implement Queue Using Stacks

Objective: We know that Queue is FIFO (First-in-First-Out) and Stack is LIFO ( Last-in-First-Out). Here our objective is to implement queue using stacks. Approach: Take 2 Stacks, stack1 and stack2. stack1 will be used...

Skip to content# Category: Google Interview

## Implement Queue Using Stacks

## Merge Sort in a Linked list

## Construct a binary tree from given Inorder and Level Order Traversal

## Construct Binary Search Tree from a given Preorder Traversal Using Stack (Without Recursion)

## Construct Binary Search Tree from a given Preorder Traversal using Recursion

## Given an array arrA[], find the maximum j – i such that arr[j] > arr[i].

## Find All Elements in an Array which appears more than N/K times, N is Array Size and k is a Number.

## Print All The Nodes Which are X distance from the Given Node

## Find the Distance between Two Nodes of a Binary Tree.

## Lowest Common Ancestor in a Binary Tree (Not Binary Search Tree).

## Lowest Common Ancestor in a Binary Search Tree.

## Make a Binary Tree from Given Inorder and Preorder Traveral.

## Convert a Sorted Doubly Linked List to Balanced BST.

## Find the number of occurrences of a number in a given sorted array.

## Inorder Successor in Binary Search Tree without Using Parent link

@tutorialhorizon

Objective: We know that Queue is FIFO (First-in-First-Out) and Stack is LIFO ( Last-in-First-Out). Here our objective is to implement queue using stacks. Approach: Take 2 Stacks, stack1 and stack2. stack1 will be used...

Objective: Given a Linked List, Sort it using merge sort. Example: ->9->3->4->2->5->1 Sorted List: ->1->2->3->4->5->9 Approach: Reference : Merge Sort in array As it Merge sort, we apply the same logic , Divide and...

Objective: – Given a inorder and level order traversal, construct a binary tree from that. Input: Inorder and level order traversal Approach: int[] inOrder = { 4, 2, 5, 1, 6, 3, 7 };...

Objective: – Given a preorder traversal, construct BST from that, without using recursion. Input: Preorder traversal Similar Problem : This problem is similar to the Construct Binary Search Tree from a given Preorder Traversal...

Objective: – Given a preorder traversal, construct BST from that. Input: Preorder traversal Similar Problem : This problem is similar to the – Construct Binary Search Tree from a given Preorder Traversal Using Stack...

Objective: Given an array arrA[], find the maximum j – i such that arr[j] > arr[i]. Example: int[] arrA = { 12, 3, 1, 5, 6, 4, 10, 9, 8, 0 }; Output: Max(j-i)...

Objective: Given an array of size of N and number k. Find all elements in an Array which appears more than N/K times. Input: Array [] and number k. Example: int[] arrA = {...

Objective: – Given Binary Tree, Print All The Nodes Which are X distance from the Given Node. Example : Approach: Quite Tricky solution, i will explain using the example given in the picture.

Objective: – Given nodes in a binary tree, find the distance between them. Example : Approach:

Objective: – Find the Lowest Common Ancestor of two given nodes in a Binary Tree What is Lowest Common Ancestor In a given binary tree, The lowest common ancestor of two nodes n1 and...

Objective: – Find the Lowest Common Ancestor of two given nodes in a Binary Search Tree What is Lowest Common Ancestor In a given binary tree, The lowest common ancestor of two nodes n1...

Objective: – Given a inorder and preorder traversal, construct a binary tree from that. Input: Inorder and preorder traversals Similar Problem: Construct a binary tree from given Inorder and Postorder Traversal Approach: int []...

Objective: Given a sorted doubly linked list, convert it into Balanced binary search tree Input: A Doubly Linked List Example: Approach:

Objective: Given a sorted(ascending order) arrays of integers, find out the number of occurences of a number in that array Input: A sorted array arrA[] and a number x. Output: number of occurrences of...

Objective: Given a Binary Search tree, find the inorder successor of a node. What is Inorder Successor: Inorder successor of a node is the next node in the inorder traversal of the tree. For...

%d bloggers like this: