- Recursive traversal adds every animal in the dingo family to the zoo.
Animal and Zoo classes as specified in the diagram below.
Animal constructor.AddChild method, add the passed-in animal to the animal's list of children if the animal is not null.Reproduce method, use the AddChild method to add the baby to the mother animal's list of children after creating the baby.Animal brutus = new Dingo("Brutus", 3, 36.0, Gender.Male);
Animal coco = new Dingo("Coco",7, 38.3, Gender.Female);
coco.AddChild(brutus);
Animal toby = new Dingo("Toby", 4, 42.5, Gender.Male);
Animal steve = new Dingo("Steve", 4, 41.1, Gender.Male);
Animal maggie = new Dingo("Maggie", 7, 34.8, Gender.Female);
maggie.AddChild(toby);
maggie.AddChild(steve);
Animal lucy = new Dingo("Lucy", 7, 36.5, Gender.Female);
Animal ted = new Dingo("Ted", 7, 39.7, Gender.Male);
Animal bella = new Dingo("Bella", 10, 40.2, Gender.Female);
bella.AddChild(coco);
bella.AddChild(maggie);
bella.AddChild(lucy);
bella.AddChild(ted);
List<Animal> tempList = new List<Animal>();
tempList.Add(bella);
tempList.Add(new Dingo("Max", 12, 46.9, Gender.Male));
AddAnimalsToZoo method at the end of the zoo's constructor. Pass in the temporary list of animals.AddAnimalsToZoo method, use recursion to loop through the passed-in collection of animals and add each animal to the zoo.AddAnimal).AddAnimalsToZoo, passing in the current animal's list of children.AddAnimalsToZoo method.AddAnimal and AddAnimalsToZoo.This time when the breakpoint hits, ensure that the animal in the list is just Brutus (Coco's child).
Ensure that all of the dingos were added to the zoo. Note that the dingos are added in the order of the parents, then their children, then the children's children.

ConsoleHelper class as specified in the diagram below.
ProcessShowCommand method for "children". In it, call the ShowChildren method.ShowChildren method, find the animal with the passed-in name (use FindAnimal).Then call the WalkTree method and pass in the animal and an empty string.
WalkTree methodWalkTree (recursion) and pass in the animal and the prefix with two spaces attached to it.animal 1
first child of animal 1
first child of first child of animal 1
second child of first child of animal 1
second child of animal 1
first child of second child of animal 1
animal 2Run the "show children" command for Bella. The result should look like the image below.

Quick Sort: The quick sort find a pivot value (often the first, last or middle value in the list) and moves other items in the list to the appropriate side of the pivot value. It then uses recursion to sort the smaller lists on either side of the now correctly placed pivot value. Because it is recursive, the algorithm continually finds pivot values and sorts the ever-smaller sections of the overall list until the entire list is sorted.


QuickSortByWeight method to the SortHelper as specified in the diagram below.
QuickSortByWeight method.leftPointer and rightPointer and initialize them to the values of the leftIndex and rightIndex respectively.The pointer values will change throughout the method while the index values will stay the same.
Animal variable named pivotAnimal and assign it to the animal in the animals list that is at half of the sum of the rightIndex and leftIndex.Animal pivotAnimal = animals[(leftIndex + rightIndex) / 2];
// Gets the animal between the index points.false.false the while loop should execute.leftPointer index is less than the pivotAnimal weight. In it, increment the leftPointer and the sortResult's CompareCount.// "Woah there's something bigger than you in this section".pivotAnimal is less than the animal at the rightPointer index. In it, decrement the rightPointer and increment the sortResult's CompareCount.// "Woah there's something smaller than you in this section."leftPointer is less than or equal to the rightPointer, call the Swap method and pass in the animals list, the leftPointer and the rightPointer. Increment the SwapCount of the sortHelper and the leftPointer, and decrement the rightPointer.// "We have to get these animals in the right section! Let's swap them! Then let's close in on a smaller section."leftPointer is greater than the rightPointer, set the done variable to true (breaking the loop).// "Have we completed this section or do we need to check again?"leftIndex is less than then rightPointer, call the QuickSortByWeight method, passing in the animals list, the leftIndex, rightPointer and the sortResult.// If the LEFT "section" of the list isn't sorted, sort it.rightIndex is greater than the leftPointer, call the QuickSortByWeight method, passing in the animals list, the leftPointer, rightIndex, and sortResult.// If the RIGHT "section" of the list isn't sorted, sort it.sortResult's Animals to the animals parameter.sortResult."quick" to the zoo's SortAnimals method."quick" caseSortResult variable.sortValue and add a case for weight.QuickSortByWeight method and pass in the animals list, the start index (0), the end index (the count of the animals list - 1), and the SortResult variable.SortResult's EllapsedMilliseconds to the stopwatch's elapsed total milliseconds.Dingo family from the Zoo constructor to make debugging easier.QuickSortByWeight method.'sort quick weight'leftPointer, rightPointer, leftIndex, rightIndex and pivotPosition.Toby should swap with Ted because Toby doesn't have an animal with a weight higher than his on the left of him BUT has an animal with a weight lower than his on the right of him.
This time the leftPointer is higher than the rightPointer, indicating that the section from 6 to 8 is sorted correctly.
Since the leftPointer is less than the rightIndex the Sort method will be called with a new set of indexes (section).
Ensure that the animals are sorted from lightest to heaviest, the swap count is 8 and the compare count is 21.
QuickSortByName method to the SortHelper class as specified in the diagram below.
SortAnimals method, call the QuickSortByName method in the "quick" case if the sortValue is "name".It is the same as the algorithm for weight, but it compares the name values instead of the weight values.
"sort quick name." The animals should be sorted by name in alphabetical order.The swap count should be 8 and the compare count should be 20.
© 2026 Northcentral Technical College