Anda di halaman 1dari 2

Tutorial 5

FIT 1029 Algorithmic Problem Solving


27 March 2014 Prepared by Julian Garca
The objectives of this tutorial are:
To deepen the understanding of modules and how they work
To use the concept of decomposition and understanding how it relates to modules
To get familiar with the divide and conquer strategy
Activity 1
Two different mobile phone companies named A mobile and B mo-
bile have decided to join efforts and become a single company AB
mobile. Each company has their own database of clients. As a result
of the merger the rst task of the IT team is to create a new database
without duplicated information. The new database also needs to
have the ability to be searched and sorted. This is complex task and
so the problem is best addressed by using decomposition, i.e., break-
ing the problem down into different components.
Make groups of 3 or 4 students, and discuss the components that
are needed to accomplish the task effectively. Discuss what the
modules should be, including their name, description, input and
ouput. Together, decide on a list of modules that will be used solve
the problem.
Now each one of you will take care of one module at the time.
We tackle the task as a team, in para parallel, 1 person takes care
of a module by writing down the pseudocode for each one of the
modules involved.
After all the modules have been designed. Meet up and discuss
how your modules can work together to solve the task. Together,
write down a main algorithm that uses all the modules in order to
solve the task.
Task 1
In groups of two students use the methodology of Activity 1 to solve
the Traveling Salesman Problem using the Brute Force approach.
Discuss what the components of the problem are, and what are the
modules that should be designed.
tutorial 5. fit 1029 algorithmic problem solving 2
Write down the pseudocode for each module and then write down
a main algorithm that uses the modules in order to solve the prob-
lem.
List other possible real-world applications of the traveling sales-
man problem and think about how your components should
change (if necessary) for each application
1
.
1
A nice read of contemporary appli-
cations of the TSP can be found here:
http://j.mp/moderntsp
Task 2
Suppose you have been given a formula to calculate the amount of
water in a tank during a day. Using this formula you calculate that
at 6am it will be 10% full, while at 12 noon it will be 90%. Describe
an algorithm that will nd a time when the tank is exactly at half its
capacity.
Task 3
Suppose you have an algorithm which can compute a continuous real
valued function, f (x), at any real value, x. Moreover, suppose you
know that for two values, a and b, f (a) > 0 and f (b) < 0. Describe an
algorithm that can nd a point c, to any accuracy, such that f (c) = 0.
Task 4
Consider an equilateral triangle, with side of length 4. Show how
you can cover the blank triangles with non-overlapping trapezia
made from three triangles.
Discuss the approach of an algorithm that would cover with non-
overlapping trapezia any equilateral triangle of length 2
N
, with the
topmost triangle already covered.
Task 4
Consider the 8 Queen problem, and the method of solution given in lectures. Identify the modules
you need, and their input and output. Write algorithms for these modules.
Task 5
Suppose you have been given a formula to calculate the amount of water in a tank during a day.
Using this formula you calculate that at 6am it will be 20% full, while at 12 noon it will be 80%.
Describe an algorithm that will find a time when the tank is 50% full.
Task 6
Suppose you have an algorithm which can compute a continuous real valued function, f(x), at any
real value, x. Moreover, suppose you know that for two values, a and b, f(a) > 0 and f(b) < 0.
Describe an algorithm that can find a point c, to any accuracy, such that f(c) = 0.
Task 7
Consider an equilateral triangle, with side of length 4. Show how you can cover the blank triangles
with non-overlapping trapezia made from three triangles. Describe an algorithm that for any
equilateral triangle of length 2
N
where the topmost triangle is covered, covers the remaining blank
triangles with non-overlapping trapezia
FACULTY OF INFORMATION TECHNOLOGY FIT1029 ALGORITHMIC PROBLEM SOLVING 2013
PAGE 2 OF 2
Figure 1: Covering the white triangles.

Anda mungkin juga menyukai