How do you insert a new item in a binary search tree?
Answer / Santosh Shaw
To insert a new item into a binary search tree, follow these steps:
1. Perform an initial search to find the appropriate location for the new node.
2. If the searched location is null (empty), create a new node with the input value and assign it to that location.
3. If the searched location already contains a value, compare the input value with the current value. If the input value is less than the current value, repeat the search process on the left subtree. Otherwise, repeat the search process on the right subtree.
| Is This Answer Correct ? | 0 Yes | 0 No |
What are the complexity of binary search?
Explain the principle of quicksort. What is its complexity?
If we add enum constants to a sorted collection ( treemap , treeset ), what will be the order in which they will be maintained?
Is int a data structure?
What is Doubly link list?
Explain about set and their types in a collection?
Does arraylist have index?
What is meant by linked list?
Given an unsorted linked list, and without using a temporary buffer, write a method that will delete any duplicates from the linked list?
Advanced problems related to Data Structures were asked
What are hash tables good for?
Which process places data at the back of the queue?