1. [LO 1, LO 2, LO 3 & LO 4, Treasure Hunter Description You are in front of a cave that has treasures. The cave can be represented in a grid which has rows numbered from 1 to , and columns numbered from 1 to . For this problem, define (x,y ) as a tile that is in the the-x row and the y-row. There is a character in each tile, which indicates the type of that tile. Tiles can be floors, walls, or treasures which are represented respectively by the characters '.' (period), '#' (hashmark), and '*' (asterisk). You can go through the floor tiles and treasures, but you can't get past the wall tiles. Initially, you are in a tile (??, Sy). You want to visit all the treasure squares, and retrieve the treasure. When you visit a treasure tile, the treasure is instantly retrieved, and the tile turns into a floor. In a move, if you are on a tile (?,y), then you can move to the right tile above (?-1,y), right (?,y + 1), down (? + 1, ), and left (?, 1) of the current tile. The tile you visit must not be off the grid, and must not be a wall tile. Determine the minimum number of steps you can take to retrieve all the treasures. Input Format The first line contains 3 integers, N, M, and T. The second line contains 2 integers, Sx and Sy. It is guaranteed that this tile is a floor tile. The next N lines contain M characters. The characters in the i-th row and j-th column represent the tile type. Guaranteed that there are exactly T characters '*' in the grid. Output Format A line containing the minimum number of steps to retrieve all treasures. If you cannot retrieve all the treasures, remove 1. Example Input and Output Input Example Output Example 1 6 5 1 3 **.*** 7 5 5 2 2 1 ##### ....# #.#*# #*..# ##### 6 5 7 4 1 2 #.##### #*...*# #..#### ##.#..# #.....# #*.#.*# ####### 19 3 5 2 1 2 #.### #*#*# ##### -1 Explanation Example In the first sample test case, you can perform the following sequence of steps: 1. walk left towards (1, 2) and pick up the treasure, 2. walk left towards (1,1) and pick up the treasure, 3. walk right towards (1, 2), 4. walk right towards (1, 3), 5. walk to the right towards (1, 4) and pick up the treasure, 6. walk right towards (1,5) and pick up the treasure, and 7. Walk to the right towards (1, 6) and pick up the treasure. Task     You are asked to create an algorithm that can solve a given problem. Provide an analysis of why your algorithm is correct, and write down the time complexity of your algorithm. Note that you are not asked to program, but you may attach your code as supporting evidence for your algorithm. NOTE LO1: Explain fundamental concept of analysis arithms.  LO2: Apply algorithm techniques and methods. LO3: Solve a problem using specific algorithm. LO4: Compare several algorithm design methods. Please answer the bottom question, and please don't reject. I need it in 60-90 minutes, thanks

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

1. [LO 1, LO 2, LO 3 & LO 4, Treasure Hunter Description

You are in front of a cave that has treasures. The cave can be represented in a grid which has rows numbered from 1 to , and columns numbered from 1 to . For this problem, define (x,y ) as a tile that is in the the-x row and the y-row. There is a character in each tile, which indicates the type of that tile. Tiles can be floors, walls, or treasures which are represented respectively by the characters '.' (period), '#' (hashmark), and '*' (asterisk). You can go through the floor tiles and treasures, but you can't get past the wall tiles.
Initially, you are in a tile (??, Sy). You want to visit all the treasure squares, and retrieve the treasure. When you visit a treasure tile, the treasure is instantly retrieved, and the tile turns into a floor.
In a move, if you are on a tile (?,y), then you can move to the right tile above (?-1,y), right (?,y + 1), down (? + 1, ), and left (?, 1) of the current tile. The tile you visit must not be off the grid, and must not be a wall tile.
Determine the minimum number of steps you can take to retrieve all the treasures.

Input Format
The first line contains 3 integers, N, M, and T.
The second line contains 2 integers, Sx and Sy. It is guaranteed that this tile is a floor tile.
The next N lines contain M characters. The characters in the i-th row and j-th column represent the tile type. Guaranteed that there are exactly T characters '*' in the grid.

Output Format
A line containing the minimum number of steps to retrieve all treasures. If you cannot retrieve all the treasures, remove 1.

Example Input and Output

Input Example

Output Example

1 6 5

1 3

**.***

7

5 5 2

2 1 #####

....# #.#*# #*..# #####

6

5 7 4

1 2 #.##### #*...*# #..#### ##.#..# #.....# #*.#.*#

#######

19

3 5 2

1 2 #.###

#*#*# #####

-1

Explanation Example
In the first sample test case, you can perform the following sequence of steps:
1. walk left towards (1, 2) and pick up the treasure,
2. walk left towards (1,1) and pick up the treasure,
3. walk right towards (1, 2),
4. walk right towards (1, 3),
5. walk to the right towards (1, 4) and pick up the treasure,
6. walk right towards (1,5) and pick up the treasure, and
7. Walk to the right towards (1, 6) and pick up the treasure.

Task
    You are asked to create an algorithm that can solve a given problem. Provide an analysis of why your algorithm is correct, and write down the time complexity of your algorithm. Note that you are not asked to program, but you may attach your code as supporting evidence for your algorithm.

NOTE

LO1: Explain fundamental concept of analysis arithms. 

LO2: Apply algorithm techniques and methods.

LO3: Solve a problem using specific algorithm.

LO4: Compare several algorithm design methods.

Please answer the bottom question, and please don't reject. I need it in 60-90 minutes, thanks

Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY