Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ DATA STRUCTURES 8. The following struct is used to represent magnetic animals struct manimal f string name, species: int weight; manimal (string n, string

C++ DATA STRUCTURES

image text in transcribed

8. The following struct is used to represent magnetic animals struct manimal f string name, species: int weight; manimal (string n, string s, int w) { name=n ; species-s ; weight=w; } }; Magnetic animals are to be stored in a Binary Tree, ordered by their names A. Define the necessary struct(s) together with an add method, so that this sample code would correctly build a tree containing six animals ManiTree zoo zoo.add (new manimal ("Lenny", "lion", 320)) zoo.add (new manimal ("Sammy", "seal", 135)) zoo.add (new manimal ("Quacky, "puppy-eating duck", 5)) zoo.add (new manimal ("Timmy", "tiger", 251)) zoo.add (new manimal ("Rosie", "pony", 260)): zoo.add (new manimal ("Geoffrey", "georaffe", 1326)) Draw the tree, showing nodes connected by pointers, as it would be directly fter the sample code is execute Add a method to the tree-of-animals class. It should take an animal's name as its parameter, and return as its result that animal's weight, or -999 if there is no match. Your method should not print the result itself, just return it. So int w zoo.weightof ("Timmy") cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions