7. Session 6 : Putting Functional Patterns to Work - Pseudo Code#

7.1. Session Overview#

The objectives of this session are

  • study an algorithm

  • code the algorithm

  • use pattern 1 and/or pattern 2

  • use pattern 5

  • use pattern 6

  • write pseudo code for the algortihm

  • write pseudo code in LaTeX

Note - details and examples of using the patterns can be found in the session 2 notes.

The objectives can be achieved by undertaking the exercises provided in this session.

7.2. Exercises#

7.2.1. Exercise 1#

Study the algorithm provided here for solving the checkerboard problem and consider the questions from session 5 (repeated below)

  • What data structures are employed

  • What are the inputs

  • What are the expected outputs

  • Are there any edge cases

7.2.2. Exercise 2#

Code the algorithm to solve the checkerboard problem using python.

Is there any scope for using patterns 1 or pattern 2 in your solution ?

7.2.3. Exercise 3#

In the details of the checkerboard problem there is a discussion regarding “overlapping” solutions and their impact on efficiency. A possible solution for this problem is also proposed.

Try using pattern 5 to produce a different approach to solving this problem.

7.2.4. Exercise 4a#

Investigate how the python method min works when applied to tuples.

7.2.5. Exercise 4b#

Investigate how the python method + workes when applied to lists

7.2.6. Exercise 4c#

In the details of the checkerboard problem there is a discussion regarding how the path corresponding to the minimum cost could be stored and processed.

Can you think of a way of using your answers to exercises 4a and 4b to do this in a simpler way.

7.2.7. Exercise 5#

Generate a large random checkerboard and solve it using your solution to exercise 3.

How might you parallise your method for large checkerboards ?

7.2.8. Exercise 6#

Draft some pseudocode to describe the algorithm you used for solving the checkerboard problem. Pencil and paper is fine, but you can go straight to exercise 6 if you prefer.

7.2.9. Exercise 7#

There are several LaTeX packages available for typesetting pseudocode. Some details for how to use them can be found here.

Use one of these packages to typset your pseudocode from exercise 6.

7.3. Extra Exercises#

7.3.1. Exercise 8#

If you have time, do some research into how you might share the code for your IPD strategies with someone else. They should be able to use your strategies in their IPD simulation code.