• Keine Ergebnisse gefunden

Algorithms & Data Structures Homework 0 HS 18

N/A
N/A
Protected

Academic year: 2022

Aktie "Algorithms & Data Structures Homework 0 HS 18"

Copied!
3
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Eidgen¨ossische

Technische Hochschule Z¨urich

Ecole polytechnique f´ed´erale de Zurich Politecnico federale di Zurigo

Federal Institute of Technology at Zurich

Departement of Computer Science 24. September 2018

Markus P¨uschel, David Steurer

Algorithms & Data Structures Homework 0 HS 18

Exercise 0.1 Find the Shortest Path.

Consider a hypothetical floor plan such that the area is organized in hexagonal cells as shown in Figu- re 1. We begin at the cell markedstart, and we want to reach the cell markedend. We can travel from one cell to another, if the two cells are neighbouring, i.e. they share an edge. Each time we cross from one cell to a destination cell, we consider the move as a single step and the destination cell as visited.

We want to find the shortest path from the start to the end, minimizing the number of steps.

START

END Figure 1: Floor plan Consider the following algorithm:

1. We consider the start cell as visited, and we write the number zero on the cell.

2. If a cell has the numbernwritten on it, we can visit all neighbouring cells, writing the number n+ 1on it if either:

• the neighbouring cell has not been visited before, or

• the neighbouring cell has been visited before and holds the numbermsuch thatm > n+ 1. 3. We stop the execution of the algorithm when we can no longer execute 2.

Your tasks:

(2)

1. Execute the algorithm on the floor plan given in Figure 1, writing numbers on each cell.

2. How many steps do we need to reach the end cell?

3. For a given plan withN cells including the start and the end cell, how many steps do we need to reach the end cell, starting from the start cell, in the worst case scenario?

Exercise 0.2 Induction.

1. Prove via mathematical induction, that the following holds for any positive integern: 12+ 22+ 32+. . .+n2 = (n)(n+ 1)(2n+ 1)

6

• Base Case.

• Induction Hypothesis.

• Inductive Step.

2. Prove via mathematical induction that for any positive integern,2n3+ 3n2+nis divisible by6.

• Base Case.

• Induction Hypothesis.

• Inductive Step.

2

(3)

Exercise 0.3 Coloring a Map.

Given is a map that is divided byn(pairwise different) straight lines. You want to color the regions on the map (i.e., the areas bordered by the lines), such that no two neighbouring regions (i.e., regions that share a common segment of a line as a border) get the same color.

Prove by mathematical induction onn, that you can color every such map with 2 colors.

• Base Case.

• Induction Hypothesis.

• Inductive Step.

Homework:This homework does not have to be submitted and will be discussed in the first exercise session on 24.9.2018

3

Referenzen

ÄHNLICHE DOKUMENTE

nung aufgelöst und die letzten Rechnungen des Verstorbenen noch nicht bezahlt“, sagt Wrede und stellt die Frage: „Warum gibt es in dieser Branche ei­. gentlich so wenig

Solution: The worst case scenario is having a floor plan in which each cell has only two neigh- bouring cells, such that the two neighbouring cells do not share an edge, and the

Hint: Suppose you start with a map with two vertical lines, dividing the map into three regions, colored red, blue, and red from right to left.. What happens if you draw a vertical

There must be such a vertex to remove because the tree is acyclic and connected and non-trivial (See Exercise 1.2.4).. Add the leaf node back to

In this exercise, we ask you to prove that a connected graph contains an Eulerian tour if and only if it does not contain a vertex of odd degree.. Prove that every connected

For the following code fragment, count the number of times the function f is invoked and express this in Θ-notation as concisely as possible. For the following code fragment,

Determine the best search strategy for the floor where the phone breaks and give the number of drops in big-Θ notation.. Starting from the first block we drop the first phone from

The maximum possible difference of the depths of two leaves in the tree (with height h ) is therefore 1 greater than the maximum difference of the depths of two leaves in the