Learn basic concept of c , c++ and python programming in regularcodes.com

Spread the post

Print BST keys given Range using queue

Time complexity of this program O(n)

Accepted Output

Given BST tree node is:

444, 406, 516, 435, 474, 577, 447, 483, 554, 477

View Tree Click Here

444406516474577483435554477447

Data between (400 to 480) 406 435 444 447 474 477

Given BST tree node is:

540, 466, 597, 423, 497, 575, 433, 467, 529, 465

View Tree Click Here

540466597423433497465467529575

Data between (450 to 550) 465 466 467 497 529 540

Below in C implementation of this problem. Iterative approach.

Output
  BST inserted Data is :   50   30   70   20   35   60   90   10   85   100   15   80
 Data of between [70 - 100] is :   70  90  85  100  80
 Data of between [0 - 70] is :   50  30  70  20  35  60  10  15
 Free Memory of Queue

 Free BST nodes
 

Spread the post