# Category Archives: Binary Search Tree

## Overview of Data Structures | Set 2 (Binary Tree, BST, Heap and Hash)

We have discussed Overview of Array, Linked List, Queue and Stack. In this article following Data Structures are discussed. 5. Binary Tree 6. Binary Search… Read More »

## Count inversions in an array | Set 2 (Using Self-Balancing BST)

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If an array is already sorted then inversion… Read More »

## Check if a given array can represent Preorder Traversal of Binary Search Tree

Given an array of numbers, return true if given array can represent preorder traversal of a Binary Search Tree, else return false. Expected time complexity… Read More »

## Check if a given Binary Tree is Heap

Given a binary tree, we need to check it has heap property or not, Binary tree need to fulfill the following two conditions for being… Read More »

## Amazon Interview Experience | Set 233 (1 Year Experienced for SDE-1)

I recently had interviews with Amazon.com, Bangalore. Here’s my interview experienceCoding round (1 hour): 1. Find minimum number of coins that make a given value… Read More »

## How to check if a given array represents a Binary Heap?

Given an array, how to check if the given array represents a Binary Max-Heap. Examples: Input: arr[] = {90, 15, 10, 7, 12, 2} Output:… Read More »

## Accolite Interview Experience | Set 7 (On-Campus)

Accolite visited our campus for full time Software development. First round: MCQ round consists of 30 questions 30 minutes. Questions on C aptitude, four to… Read More »

## Print Common Nodes in Two Binary Search Trees

Given two Binary Search Trees, find common nodes in them. In other words, find intersection of two BSTs. Example: Recommended: Please solve it on “PRACTICE”… Read More »

## Walmart Labs Interview Experience | Set 5 (On-Campus)

Recently walmart labs came to our campus for campus recruitment. Here is my interview experience: Round 1 (MCQ + Coding Questions) This round was conducted… Read More »

## How to implement decrease key or change key in Binary Search Tree?

Given a Binary Search Tree, write a function that takes following three as arguments: 1) Root of tree 2) Old key value 3) New Key… Read More »

## Amazon Interview Experience | Set 228 (On-Campus for Internship)

Amazon came to our campus a week back and procedure was as follows: Round-1- 20 easy MCQ 2 coding questions: (a)- Find next greater number… Read More »

## MakeMyTrip Interview Experience | Set 8 (On-Campus)

MakeMyTrip recently visited our campus. There were 4 rounds. Online Round ( 1 Hour ) This round consisted of 20 aptitude questions and 3 coding… Read More »

## Construct all possible BSTs for keys 1 to N

In this article, first count of possible BST (Binary Search Trees)s is discussed, then construction of all possible BSTs. How many structurally unique BSTs for… Read More »

## K’th smallest element in BST using O(1) Extra Space

Given a Binary Search Tree (BST) and a positive integer k, find the k’th smallest element in the Binary Search Tree. For example, in the… Read More »

## Count BST subtrees that lie in given range

Given a Binary Search Tree (BST) of integer values and a range [low, high], return count of nodes where all the nodes under that node… Read More »