Question: In c# Write a method that looks for an egg. The egg is the value zero and it might be somewhere in an array of

In c# Write a method that looks for an egg. The egg is the value zero and it might be somewhere in an array of integers. To make it more difficult, you must start with the first item in the array. If the first item isn't the egg, then print the value of the first item, and use that value as the index of the next element. This continues until you find the egg, or . (think of the different ways to end the search for the egg). The method accepts an array of integers and returns the number of places you looked for the egg. Example: array contains 3 2 4 2 0 The method prints 3 2 4 and returns 3. It looked in array[0] but did not find the egg so it looked in position 3 since 3 was stored in array[0]. In array[3] it found 2 so it looked in array[2]. Array[2] has 4 so it then looked in array[4] and found the egg.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!