Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Student Name: Jihad Hossain Jisan.

Course code CSE 211


SECTION : 05
Facu lty Name : Md.Jahidul Hasan Jahid
Answer of question 01:

Preorder: ABDGICEHJKF
In order: BIGDAEJHKCF
Post order: IGDBJKHEFCA

Answer of question 02:

Post order: IDKMHBAFNOLJGEC


Root = c

Answer of question 03:

O(n) O(n)

O(log n) O(n)

O(log n) O(n)
O(log n) O(n)

PAGE 1
Answer of question 04

30
/ \
23 40
/ \ \
11 26 58
\ /
13 48

Answer of question 05
After deleting the elements(65,16,12,42) .The new Tree looks like:

53 53
/ \ / \
8 60 22 60
/ \ / / /
2 22 57 19 57
/ /
19 8
/
2
Figure-1 figure-2

PAGE 2
Answer of question 06:
a) maximum height of a binary search tree that contains n items

is :- h = n-1 (when each node only has a left child or only has a right child, resulting in a linear structure.)

b) Minimum height of a binary search tree that contains n items is:-


h=log2(n+1)-1

c) A balanced Binary Search Tree (BST) is crucial because it guarantees


optimal performance for operations such as search, insert, and delete. These
operations run in O(log n) time in a balanced BST, where n is the number of
nodes. However, in an unbalanced BST, these operations can degrade to O(n)
in the worst case, which is no better than a linked list. Therefore, maintaining
a BST in a balanced state ensures that we benefit from the logarithmic time
complexity advantages that trees offer over linear data structures. This is why
balancing algorithms like AVL or Red-Black trees are used in practice. They
automatically ensure that the tree remains balanced after insertions or
deletions, thus guaranteeing that operations always run in logarithmic time.
BST is important because it ensures optimal performance for operations like search, insert, and
delete

PAGE 3

You might also like