comp2123 Assignment 4

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

comp2123

Assignment 4

s1 2025

This assignment is due on May 13 and should be submitted on Gradescope.

All submitted work must be done individually without consulting someone else’s solutions in accordance with the University’s “Academic Dishonesty and Plagia– rism” policies.

Before you read any further, go to the last page of this document and read the Written Assignment Guidelines section.

Problem 1. (20 points)

Let G = (V, E) be an arbitrary connected graph with weighted edges.

m = |E| is the number of edges in the graph, and n = |V| is the number of vertices.

a) Prove or disprove:  The minimum spanning tree of G includes the mini– mum weight edge in every cycle in G.

b) If the graph edge weights are distinct, then obviously the minimum span– ning tree will be unique.  But is the inverse also true?  Prove or disprove: If a graph has two edges with the same weight value, multiple minimum spanning trees must exist.

c) Describe  an  O(m log n) time  algorithm to  determine whether  or not  a graph has a unique minimum spanning tree, or if multiple minimum span– ning trees exist.

d) Prove the correctness of your algorithm.

e) Analyse the time complexity of your algorithm.

Problem 2. (20 points)

Vector Raceris a game where players take turns to move racecars around a track. Each car starts with initial velocity (0, 0) representing the velocity in the x and y directions (the change in position).  On each turn, the player may choose to increment or decrement by 1 any component of their velocity, or both, and then their racecar moves to the next position by that vector from its current position.

You are given the layout of the race track as an n × n boolean matrix where each cell track[i][j] is True if that position is part of the track, or False if it is out of bounds. If your car goes out of bounds, it will crash.

Figure 1: An example race sequence.  Note that this may not be the path with the least steps.

The starting area is the first column on the matrix, and the finish line is the last column of the matrix. The goal is to be the first to cross the finish line, while always maintaining your car’s position within the track.

Note:

• Multiple cars can share the same position, so you don’t need to consider the presence or absence of other racers.

• A car can jump over out of bounds if its velocity vector would still end up on a cell within the track.

• You must land on the finish line, overshooting the finish line counts as crashing.

Your task is to:

a) Design an efficient algorithm that will compute the minimum number of turns required to reach the finish line from the starting area, without crash– ing out of bounds.

b) Argue the correctness of your algorithm.

c) Analyse the time complexity of your algorithm.

Problem 3. (20 points)

Helen is planning a road trip from Sydney to Tamworth and she has a large map which is a road network modelled as a simple undirected connected graph G  =  (V, E) with vertices representing towns  or cities, and edge lengths l(e) representing the length of roads between them. She plans her journey originally as P, the shortest path between Sydney and Tamworth where |P| is the number of edges in it.

However, Helen knows there are planned roadworks occurring, where ex– actly one road might be closed, but at the time she is planning her trip she doesn’t know what it is.  She plans to check online just before she departs, but for the time being she would like to know the shortest distances from Sydney to Tamworth in every case – that is, what is the shortest path in G′ \ {e} for every edge e ∈ P where G′ = (V′, E′) is a subgraph induced from the vertices in the original shortest path.

In other words, Helen doesn’t want to take any detours to cities or towns that would otherwise not have been visited at any point in her original journey.

a) Design an algorithm to solve this problem that runs in O(|E|log |V|) time. Your result should be a list of |P| distances, one for each case where an edge e ∈ P was removed from the graph.

b) Prove the correctness of your algorithm.

c) Analyse the time complexity.

Written Assignment Guidelines

• Assignments should be typed and submitted as pdf (no pdf containing text as images, no handwriting).

• Start by typing your student ID at the top of the first page of your submis– sion. Do not type your name.

• Submit only your answers to the questions. Do not copy the questions.

• When asked to give a plain English description, describe your algorithm as you would to a friend over the phone, such that you completely and unambiguously describe your algorithm, including all the important (i.e., non–trivial) details.  It often helps to give a very short (1–2 sentence) de– scription of the overall idea, then to describe each step in detail. At the end you can also include pseudocode, but this is optional.

• In particular, when designing an algorithm or data structure, it might help you (and us) if you briefly describe your general idea, and after that you might want to develop and elaborate on details.  If we don’t see/under– stand your general idea, we cannot give you marks for it.

• Be careful with giving multiple or alternative answers. If you give multiple answers, then we will give you marks only for "your worst answer", as this indicates how well you understood the question.

• Some of the questions are very easy (with the help of the slides or book). You can use the material presented in the lecture or book without proving it. You do not need to write more than necessary (see comment above).

• When giving answers to questions, always prove/explain/motivate your answers.

• When giving an algorithm as an answer, the algorithm does not have to be given as (pseudo–)code.

• If you do give (pseudo–)code, then you still have to explain your code and your ideas in plain English.

• Unless otherwise stated, we always ask about worst–case analysis, worst– case running times, etc.

• As done in the lecture, and as it is typical for an algorithms course, we are interested in the most efficient algorithms and data structures, though slower solutions may receive partial marks.

• If you use further resources (books, scientific papers, the internet,...)  to formulate your answers, then add references to your sources and explain it in your own words. Only citing a source doesn’t show your understanding and will thus get you very few (if any) marks.  Copying from any source without reference is considered plagiarism.


发表评论

电子邮件地址不会被公开。 必填项已用*标注