Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is an interview question. In other words, it is your time to explore and feel what to expect in a job interview. For this

This is an interview question. In other words, it is your time to explore and feel what to expect in a job interview. For this question, you have a garden that is represented by a 2D array, and we are placing a hungry rabbit in the middle of the garden. The values of the array represent the carrot count that is available for the rabbit in each square within the garden. In case the garden does not have an exact center, the rabbit begins in the square that is closest to the center with the highest carrot count. On a given turn, the rabbit will eat the carrots that are available on the square he is on, then the rabbit moves up, down, left, or right choosing the square that has the highest number of carrots. If there are no carrots left on any of the adjacent squares (i.e., up, down, left, or right), the rabbit will go to sleep. You may assume that the rabbit will never have to choose between two squares with the same number of carrots. Your program must have a function that takes a garden matrix and returns the total number of carrots the rabbit eats. The matrix cannot be populated with negative integers. As a note, you must have the array within your program. In other words, the program should not ask the user to input an array. You must test your program with the following array. You will lose 20% of your score if you dont test the program with the following array. 10159764321121223416781000176253602349051214244222216116255069853761261231020689142213159654110121021 Submission You must submit your complete code along with a screenshot showing that you tested your program with the matrix above. Your code must be in C++, or you will get zero. Additionally, you must provide a .cpp or .txt file for me to be able to copy your code and run it.**Needs to be in C++
And the total carrots eaten by the rabbit should be 91 carrots

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

Explain the steps of XYZ analysis. AppendixLO1

Answered: 1 week ago

Question

5. Describe cultural differences in relational development.

Answered: 1 week ago