Lecture 11
Lecture 11
CSE 4303
Data Structure
Asaduzzaman Herok
Lecturer | CSE | IUT
[email protected]
BINARY SEARCH TREES (BST)
A binary search tree, also known as an ordered binary tree, is a variant of binary trees in
which the nodes are arranged in an order.
Since the nodes in a binary search tree are ordered, the time needed to search an
element in the tree is greatly reduced.
Asaduzzaman Herok, Lecturer
30 October, 2023 2
Department of Computer Science and Engineering, IUT
WHY DO WE NEED BST
Binary Search on sorted Array: Binary Search Tree:
● Time complexity O(log(n)). ● Average time complexity O(log(n)).
● Insertion of new element ? ● Insertion of new element ?
○ Need to sort again ○ Still O(log(n))
● Deletion of element? ● Deletion of element?
○ Need to sort again ○ Still O(log(n))
● Searching an element
● Inserting a new element
● Deleting an element
● Deleting the entire tree
● Determining the height of the tree
● Finding the largest element
● Finding the smallest element
● Traversals (Pre-Order, In-Order, Post-Order)
The Pseudocode
Data Structures
Using
c
Reema Thareja