Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fill in the code to the right in c++ and follow all constraints/examples/directions. 1 Finclude cmap> #include 3 include Problem Statement s string kitten path(int

image text in transcribed

Fill in the code to the right in c++ and follow all constraints/examples/directions.

1 Finclude cmap> #include 3 include Problem Statement s string kitten path(int kitten, mapcint, vectorkint>> tree) Ouch! A kitten got stuck on a tree. Fortunately, the tree's branches are numbered. Given a description of a tree and the position of the kitten, can you write a program to help the kitten down? /I fill in code here The input is a description of a single tree, and the location of the kitten in the tree. The parameter kitten denotes the branch on which the kitten got stuck. Next is mapcint, vectorcint>> tree The tree parameter describes the tree in terms of its branches: each map entry key identifies a limb by its number, with the map entry value beinga vector of the branches coming off of it. The kitten can reach the limb s coming off of the limb, thus moving closer to the root of the tree. The root of the tree is always numbered a You are asked to trace a simple path from the kitten to the root of the tree by returning a string containing the numbers of each branch the kitten will visit on its way down the tree, separated by spaces. Constraints Each branch will appear in exactly one value vactor in tree All branch numbers are in the range 1..100, though not .You are guaranteed that there is a path from every listed branch 1Input: 2. Input kitten- tree ffe,(1, 2, 3, 4 Returns: 48 3. Input kitten-9 tree - ((e2.3.4 Returns: 9648 4. input kitten-14 tree ffa (24 4.3, 1, 2 13 9, 4,11). (10 . {20 3, 7)). (32 (10, 23)) (23 (13, 19, 32, 22)). 1912, 5, 14,17, 3e 14- (6.15, 16)) 38 18, 31. 29 (24 (23, 26)). (26 (27, 28))) Returns: 14 19 23 24 e 17 18 31

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions