Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2. An alien is lost on earth and wants to return home. The only way for the alien to return is to retrieve a

image text in transcribed

Problem 2. An alien is lost on earth and wants to return home. The only way for the alien to return is to retrieve a key to the space shuttle. The key is hidden in one of the cells of an, n x n, rectangular grid. Each cell in this rectangular grid contains a unique integer. One of these integers will help him retrieve the key. A kind soul feels bad for him and comes to his rescue by giving him three important pieces of informatiorn: the integer that would retrieve the key. that the numbers are stored in the increasing order from the top down in each column and left to right in each row that he should start from the bottom left cell and try to reach the top right cell. Even with this information the alien still has to find the cell that contains the integer and hence the key to the space shuttle. In order to find the cell containing his key the alien would have to compare the integer given to him with the number stored in a given cell. You are supposed to answer the following: 1. Describe the most optimal strategy (or pseudocode) in a sentence or two for the alien to find the cell that contains the key. What is the runtime of your approach? 2. Find the number of comparisons in the worst case as a function of n if a single comparison returns whether the integer he knows, is smaller, larger, or the same as the number stored in the cell 3. Find the number of comparisons in the worst case as a function of n if two comparisons are needed to return whether the integer he knows, is smaller, larger, or the same as the number stored in the cell. 4. If the alien's life decreases by 1 every time a comparison is made, how big a grid (2D) would the alien survive starting with a life of 50, for the case with one comparison (part 2 above) and the case with two comparisons (part 3 above). You may assume a square rid

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_2

Step: 3

blur-text-image_3

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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

9.7 List and briefly discuss four management development methods.

Answered: 1 week ago