Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class Position { public: int& operator * ( ) ; Position parent ( ) const; PositionList children ( ) const; bool isRoot ( ) const;

class Position { public: int& operator*(); Position parent() const; PositionList children() const; bool isRoot () const; bool isExternal () const; } class Tree { public: class Position { public: int& operator*(); Position parent() const; PositionList children() const; bool isRoot () const; bool isExternal () const; } std::list PositionList; public: Tree(); int size() const; bool empty() const; Position root () const; PositionList positions() const; void add (const Tree& T, const string& mn, float p, float m, const string& t); void preOrderPrint (const Tree& T, const Position& p); void postOrderPrint (const Tree& T, const Position& p); } Solve the following exercise: 1. Implement class Tree assuming the linked structure for a general tree shown in Figure 7.5 in the textbook. Each node stores the same information as class Vehicle of the previous exercise as well as one additional field called type (string) indicating if a vehicle is a Sedan, Truck, or Electric. 2. The main program should interactively ask for a character, and then execute the following actions depending on the received input character: a. A adds a new vehicle to the tree after reading the following information for the vehicle: manufacturer, price, milage, and type. b. L lists in preorder all vehicles with a price less than value V. Value V is read from the input. c. M - lists in postorder all vehicles newer than the manufacturing year Y. Value Y is read from the input. d. I lists the number of vehicles in the inventory. Page 5 Implement all the methods that are needed to realize the four actions above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Name three clusters of customers who might shop at Walmart.

Answered: 1 week ago