Complexities of algorithms and data structures

Assignment Help Other Subject
Reference no: EM133870999

Algorithms and Analysis

Dynamic Programming in Action: The Knapsack-Maze Challenge

Learning Outcome 1: Compare, contrast, and apply the key algorithmic design paradigms: brute force, divide and conquer, decrease and conquer, transform and conquer, greedy, dynamic pro- gramming and iterative improvement;

Learning Outcome 2: Define, compare, analyse, and solve general algorithmic problem types: sorting, searching, graphs and geometric;

Learning Outcome 3: Theoretically compare and analyse the time complexities of algorithms and data structures; and

Learning Outcome 4: Implement, empirically compare, and apply fundamental algorithms and data structures to real-world problems.

Overview

Across multiple tasks in this assignment, you will design and implement algorithms that navi-gate a maze to collect treasures. You will address both fully observable settings (where treasure locations are known) and partially observable ones (where treasure locations are unknown), which requires strategic exploration and value estimation when solving the maze. Some of the components ask you to critically assess your solutions through both theoretical analysis and controlled empirical experiments to encourage reflection on the relationship between algorithm design and real-world performance. The assignment emphasizes on strategic thinking and the ability to communicate solutions clearly and effectively.

Assessment details
The assignment is broken up into a number of tasks, to help you progressively complete the project. Please note that although completing one task can assist with subsequent tasks, each task can be attempted independently. Moreover, the tasks are designed in a way that even in cases where your implementation does not fully achieve the expected output, you can still dis- cuss and present the theoretical aspects of your algorithmic design through your report.

Motivation
You are to assist an adventurer searching for treasure. They have heard tales about a maze filled with valuable treasures. The Adventurer's goal is to enter the maze, find and collect as many treasures as they can, and then leave through a different exit. Once they enter, the entrance will close behind them, so they must find another way out! Expert online assignment help in the USA!

Task A: Maximising Knapsack Capacity using Recursion
In order to accomplish the objective, it would probably be prudent to start by planning which treasures are the best to collect. To begin, put together a recursive strategy to find which com- bination of treasures would be best to collect: For the knapsack problem, the algorithm recur- sively calculates the optimal solution to sub-problems by considering each treasure's inclusion and exclusion.

Implementation Task
Implement the below algorithm for recursive knapsack using the skeleton code provided. En- sure that the input and outputs of the function are as described.

Task B: Maximising Knapsack using Dynamic Programming
For Task A, you implemented a recursive algorithm to solve the knapsack problem in order to find the optimal treasures to collect when you enter the maze. As a fail-safe to ensure you have definitely found the best solution, you must implement another method using dynamic programming. If you are correct, both solutions should come to the same conclusion!

Whilst the approach in Task A required recursion to find solutions to sub-problems, dynamic programming allows you to store previous solutions to sub-problems and use them to solve future problems. We do this by filling in a dynamic-programming table such that:

Intuition
For each F(i, j), we consider picking up treasure i for a knapsack with carrying capacity j. We therefore check the last optimal solution where the new treasure would be able to fit in our bag (F(i-1, j -wi)) and see if this value (plus the value of the current treasure vi) exceeds the optimal solution if the treasure is not picket up which is captured by F(i - 1, j). The optimal solution for the subproblem is the maximum of these two values. The index F(|T |, c) will hold the maximum value the knapsack can take for all the treasures.

Implementation Task
In the provided skeleton code, implement the dynamic programming solution to the knapsack problem using memory functions (or lazy/sparse programming). Your function should take in exactly the same input arguments as Task A. It should return a tuple containing the loca- tion for the optimal treasures to take, the total weight of the items in the knapsack and the value (again, just as Task A does). Your function also needs to generate a csv file to save the dynamic programming table where each row correspond to the ith treasure and every col- umn (separated by a comma) corresponds to a capacity between 0 to c (a function to convert a dynamic-programming table to CSV file is provided for you). The snapshot in Figure 3 shows the dynamic programming table using memory functions for the example provided in Fig- ure 1. You can find the relevant information regarding memory functions in the lecture notes and lecture recordings of Week 9.

Report Task
In your report, write the pseudo-code for this problem (use the pseudo-code in Task A as a guide for how to do this). Briefly explain the potential benefits and downsides of this approach against the approach in task A. Total page limit for Task B is one page.

Task C: Analysis of the Complete Problem
Now you are sure which treasures to collect, you can begin finding an optimal path P to enter the maze through the entrance, pick up the optimal treasures, and leave the maze through the exit. Luckily, the mystical map calculates this for you! But you'd like to know how it works...

In this task, you will empirically compare the two algorithms you implemented in Tasks A and B. You are provided with a function findItemsAndCalculatePath in the skeleton code. This function: (1) Takes as input the maze structure, entrances, exits, treasure layout and knapsack strategy (recursive or DP); and (2) executes a path-finding solution to find the shortest possible path from an entrance to an exit while collecting all the treasures that result in the optimal output. Your task is to (i) understand this function and to (ii) conduct a meaningful empirical analysis of your two strategies in Task A and B.

Implementation Task
While you are required to implement and run tests as part of this task, no marks are awarded for the implementation itself. Marks will be given based solely on the quality of your analysis, experimental design, and discussion in the report (see bellow).

Report Task - 8 marks
Your report should include:
Algorithm Complexity Analysis: Strongly justify (perhaps with reference to the equa- tions and/or pseudo-code):
the theoretical time complexities of both knapsack solutions from Tasks A and B; and
the theoretical time complexity for the function findItemsAndCalculatePath.
Empirical Design: Highlight which variables you believe are important when calcu- lating the algorithmic complexity of the function findItemsAndCalculatePath with the recursive/dynamic-programming knapsack solution. Explain why this is the case, and why you chose to ignore other variables (if any).

Empirical Analysis: Provide a thorough analysis using one or more plots to compare the running time of findItemsAndCalculatePath with the two different knapsack strategies from Task A and B. How would you interpret your observation?
Reflection: Discuss whether your empirical results align with your theoretical complex- ity predictions. If there are discrepancies, explain possible causes - e.g., implementation details, constant factors, etc.

Task D: Maximizing Knapsack Value without Having the Map
In this task, we consider a scenario where The Adventurer explores a maze to collect treasures without knowing their exact locations. The full maze structure (maze layout) is known in advance, but the locations of treasures are not. The adventurer only knows:
The total number of treasures, |T |, present somewhere in the maze; and
the total combined value of all treasures, v; and
treasures combined weight w and minimum weight 1.

The Adventurer assumes that (i) there is only one entrance and one exit in the maze, and (ii) all cells have equal chance to have a treasure. In other words, the initial probability of a cell containing a treasure is equal to |T | . On top of all this, the maze is full of terrors - The Adventurer wishes to minimise exploration (where possible). They must navigate the maze and search the cells strategically to collect treasures and maximize the net reward objective:

Reward = knapsack value - cells explored
Your task is to design and implement an algorithm to employ a treasure search after entering the maze which aims to maximize collected treasure value while minimizing the number of cells

explored. Your solution must strategically decide which cells to explore, taking into account the trade-off between the value of potential treasures and the exploration cost associated with entering additional cells. The implementation should use the prior knowledge of the maze's layout, total treasure count, cumulative treasure value, and weight distribution, to effectively balance exploration and exploitation.

Implementation Task
Implement your solution in the provided code skeleton for Task D. Your solution receives as input, the maze, T , v and w, and outputs the sequence of cells explored from the entrance to the exit (repetitions are allowed, i.e. re-entering a cell you have already visited does not count as a new explored cell) as well as the selected treasures. Your solutions will be tested against our own solution, and marks will be awarded based on a weighting system in terms of the total Reward gained.

For a solution to be valid, it must:
have a path P that begins at the entrance;
have a path P that ends at the exit;
have a path P such that each sequential element is adjacent, so if Pk = (i, j) then:
Pk+1 = (i + 1, j) or (i - 1, j) or (i, j + 1) or (i, j - 1)
and Pk+1 and Pk do not have a wall between them.
the weight of the items in the knapsack must not exceed its capacity; and
the solution cannot use prior knowledge of item locations - a cell can only be checked for an item after it has been visited (and so must be added to the path P).

Report Task

The written report must include:
Algorithms Design: Regardless of whether or not you have implemented your solution, in your report describe your exploration and treasure-selection strategy. Include pseudo- code and explain how your approach balances between expected treasure value and cell cost. Clearly discuss the complexity of your solution with regard to the input;

Assumptions Explain how your algorithm handles different probability models for trea- sure placement. Clearly discuss if and how your solution can handle cases where there is a spatial bias in the distribution of the treasures, e.g., the probability of having a treasure is higher for cells that are more distant from the entrance and exits. See Figure 6 for some potential examples. Please note that your answer does not need to focus on finding a solution for a specific probability distribution. You are only required to discuss if and how your solution could be impacted by the change in the initial assumption.

Attachment:- Dynamic Programming in Action.rar

Reference no: EM133870999

Questions Cloud

Explain key points in processing crime and incident scenes : Explain the key points in processing crime and incident scenes. Also, discuss the process of acquiring, securing, and validating digital evidence.
What are some examples of primary use of healthcare data : What are some examples of primary use of healthcare data? What are some examples of secondary use of healthcare data?
How was the assessment tool developed : Clinical Institute Withdrawal Assessment for Alcohol, revised the history. How was the assessment tool developed? What countries use the assessment tool?
States often have their own laws and regulations : At the state and local levels, states often have their own laws and regulations that align with or extend the ADA's protections.
Complexities of algorithms and data structures : Define, compare, analyse, and solve general algorithmic problem types: sorting, searching, graphs and geometric and Implement, empirically compare
Which explanation for the test does the nurse provide : The health-care provider prescribes a magnetic resonance imaging (MRI) of the client's head. If asked, which explanation for the test does the nurse provide?
Folks with criminal records should serve on juries : Do you think folks with criminal records should serve on juries? Why or why not? Does this help in the search for justice (being judged by a jury of your peers)
Which mechanism does the nurse suspect behind the change : The nurse is assessing blood glucose levels of a client at regular intervals. Which mechanism does nurse suspect behind change in glucose levels in the client?
Advocating for emotionally and financially abused party : You are a social worker advocating for an emotionally and financially abused party.

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd