Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Remove Ads TOTALAdblock 1 3 . 7 LAB: Iterable 2 - 3 - 4 tree In this lab, the Tree 2 3 4 class is
Remove Ads
TOTALAdblock
LAB: Iterable tree
In this lab, the Tree class is extended to support iteration with a rangebased for loop. Such support is provided via the implementation of an iterator that can iterate through the tree's keys in ascending order.
An iterator is an object that maintains a pointer to a specific element in a collection and can move to the next element. Ex: A Tree iterator points to the tree's minimum key upon construction. The iterator can then move to the second to minimum key, then the third to minimum, and so on After moving past the tree's last key, the iterator can move no further.
Overview of iterable objects in
This lab requires implementation of a simplified iterator that:
implements the dereference operator to return the key that the iterator currently points to
implements the preincrement operator to advance to the next key,
supports copy construction and copy assignment, and
supports equality and inequality comparison.
Rangebased for loops work on any class that implements the begin and end member functions such that each returns an iterator. So Tree implements begin and end Trees begin member function returns an instance of Treelterator object representing the inclusive starting point of iteration: the tree's minimum key. Trees end member function returns an instance of Treelterator object representing the exclusive ending point of iteration: one beyond the tree's maximum key.
Step : Inspect the Nodeh file
Inspect the Nodeh file. Access Nodeh by clicking on the orange arrow next to main.cpp at the top of the coding window. Node his read only and has a complete implementation of a Node class for a tree node. Member variables are protected and so must be accessed through the provided getter and setter functions.
Step : Inspect the TreeIterator.h file
Inspect the Treelterator.h file. The Treelterator class is declared, but required member functions are not implemented. The
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started