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

Spread the post

Binary search tree print Odd level data using queue

Time complexity of this program O(n)

Accepted Output

Given BST tree node is:

498, 478, 591, 477, 480, 579, 411, 400, 470, 466

Result

View Tree Click Here

498591579478477411470400466480

Odd level node data is : 478 591 411 466

Another example

Given BST tree node is:

551 401 552 400 484 568 438 490 562 427

Edit Tree Click Here

551552401484438490427400568562

Result

Odd level is : 401 552 438 490 562

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
 Odd level node data is :  30  70  10  85  100
 Free Memory of Queue

 Free BST nodes
 

Spread the post