Binary Search Tree Flashcards

1
Q

What is a Binary Search Tree?

A

a tree data structure in which nodes are arranged according to the BST property. The left node is less than the node, and the right node is greater than the node. If the left child node or right child node is non-existent, then it will contain null value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you insert data into a Binary Search Tree?

A

We start from the root node and compare the new value to be inserted with the current node’s value. We continue this comparison until we find a null position.

NOTE: We want to avoid linear binary search trees as it voids the value of using a Binary Search Tree – which is speed in search operation since we can immediately ignore have of the tree. A linear structure makes the time complexity O(n), whereas non-linear we can achieve a time complexity of O(logn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you search a Binary Search Tree?

A

similar to the process for inserting data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly