The goal of this assignment is to reinforce the tree data structure in C++. Spec
ID: 3600077 • Letter: T
Question
The goal of this assignment is to reinforce the tree data structure in C++. Specifically, the assignment is to do the following:
- Construct a function that will display a binary tree by levels (each level on a separate line). If there is no node at a position in a level, then the function should display NULL. Only levels that contain at least 1 datum should be displayed.
--------------------------------------
Bintree.h
--------------------------------------
--------------------------------------
node2.h
--------------------------------------
---------------------------------------
node2.template
---------------------------------------
---------------------------------------
bintree.template
----------------------------------------
Explanation / Answer
steps :
> Put root in queue.
> Put NULL in queue.
> While Queue is not empty
> x = fetch first element from queue
> If x is not NULL
> x->rpeer <= top element of queue.
> put left and right child of x in queue
> else
> if queue is not empty
> put NULL in queue
> end if
> end while
> return
thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.