# Tagged: binary-search-tree

## Print nodes at k level from the root in a binary tree

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”] Given a binary tree, level k, print all the nodes at level k. For example, 4, 7, 8 are at level 2.   1...

## Find the in-order successor of a given node in a binary search tree

Note: We can do in-order traversal, which will give us a sorted array and then find the in-order successor very easily. But the time complexity of in-order traversal in O(n). Where as finding the...

## Determine if a binary tree is a binary search tree

Binary tree and Binary search tree are defined as follows : Binary tree is a tree data structure in which each node has at most two child nodes. A binary search tree (BST) is...

## Withdraw all money from bank account

Problem : You have some money in your bank account, the only function to withdraw money is Withdraw(value), if the value is greater than the money you have it returns 0, otherwise it withdraws...

## Create a minimal height binary search tree from given sorted array of unique integers

Problem description : Given a sorted (increasing order) array with unique integer elements, create a binary search tree (BST) with minimal height. Input : A sorted array with unique integer elements // [0, 1,...

## Determine if a binary tree is balanced

A balanced tree is defined to be a tree such that the heights of the two subtrees of any node never differ more than one. Input : The root of a binary tree Output...

## Binary tree traversal

Problem description : Tree traversal (a.k.a tree search) is a form of graph traversal and refers to the process of visiting each node in a tree data structure, exactly once, in a systematic way....

## Create a binary search tree in javascript

Create a simple binary search tree data structure in javascript. Binary tree : It is a tree data structure in which each node has at most two children, which are referred to as the...