Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def crop(map, r1, c1, r2, c2): Given a map and two locations, create and return the map that only contains rows from r1 to r2

def crop(map, r1, c1, r2, c2): Given a map and two locations, create and return the map that only contains rows from r1 to r2 (inclusive), and columns from c1 to c2 (inclusive). If r1>r2 or c1>c2, the answer has no rows/columns (we return []). Similar to how slicing works, if more rows or columns are requested than exist, just return the parts that do exist. Remember, you must not modify the original map. Assume: map is a map as defined above, and r1, r2, c1, and c2 are int values. crop(map1,1,1,3,3) [[1,1,1],[1,3,1],[1,3,1]] crop(map5,3,1,3,4) [[3,5,12,4]] crop(map2,1,1,90,90) [[0,0,10,0,0,1],[0,1,3,1,1,1]] crop(m1,2,2,1,3) []

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 Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions