1 lab hour per group each week
Group A, 11 - 12 in A116
Group B, 11 - 12 in A306
Group C, 12 - 1 in A116
Group D, 12 - 1 in A306
| Lab Session | Date | Exercises | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Jan 31 |
As revision, attempt the exercises from December's
lab test
2. Some exercises have more than one solution. Note: you need to be comfortable with lists before you get stuck into some of the algorithms we will be looking at shortly. So it is important to complete these exercises. |
||||||||||||
| 2 | Feb 7 |
Implement the following functions in Haskell
|
||||||||||||
| 3 |
Feb 14 |
Do the following:
|
||||||||||||
|
4 |
Feb 21
|
Attempt the following:
isort :: [Int] -> [Int] insert :: Int -> [Int] -> [Int]
|
||||||||||||
|
5 |
Feb 28 |
Start work on the
sorting assignment as
described in class. For the moment get data on
insert sort and selection sort only. You
will need the Haskell code for generating
random lists, for example: rl 100 will generate a random list of size 100. Put the resulting sorting data into a spreadsheet and draw a line chart.
|
||||||||||||
|
6 |
Mar 7 |
Get the results for Quick
Sort and Merge Sort and include them in your spreadsheet charts. Write a polymorphic function duplicate :: [a] -> [a] which duplicates each value in a list. The value in the list are of type a (a is a type variable which could be an Int or Char etc) For example:
|
||||||||||||
7 |
Mar 14 |
|
||||||||||||
8 |
Mar 21 |
Pascal's Triangle Write a function, pascal n, which computes the nth row of the Pascal triangle. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 and so on. Try an old lab test 3. |
||||||||||||
9 |
Mar 28 |
Prepare for next wee lab test with
2010 lab test. Start work on eight_puzzle, see week 11 below.
|
||||||||||||
| 10 | Apr 4 |
Lab Test 3 on today11.00 - 12.00 Group A in A116, Group B in A306 12.00 - 1.00 Group C in A116, Group D in A306
|
||||||||||||
| 11 | Apr 11 |
Have a look at the eight-puzzle program eight_puzzle.hs. It has some predefined starting states such as s1 and s2; and the goal state goal. In Hugs try: s1 // show how state s1 is represaented (as a list) toString s1 // converts state s1 to a string putStr (toString s1) // displays the string created from state s1 go s1 // solve the puzzle starting with state s1.
Satisfy yourself that you understand or get the gist of the core parts of the Haskell implementation of the Eight Puzzle. Open the eight-puzzle code and define a new state, s3 say, which represents the following state of the puzzle.
1. Then in Hugs run:
2. With pen and paper, draw state s1, then work backwards 4 moves from it to get a state 8 moves away from the goal stste. Next using Texpad, represent this state and call it s0. In Hugs try
Does Hugs find a solution path? If so work backwards a few more moves and try out another state.
|
||||||||||||
|
|
||||||||||||||
| Apr 18 |
Easter Break |
|||||||||||||
| Apr 25 |
Easter Break |
|||||||||||||
| 12 | May 2 |
Using the flowchart or pseudocode for the following algorithms, write C
functions for
You can start from skeleton C code in the files:
|
||||||||||||
| 13 | May 9 |
Review week |
||||||||||||
| 14 | May 16 |
Exams |
||||||||||||
| 15 |
Exams |
|||||||||||||
Do the following:
Finally, implement selection sort in C and from the pseudocode. As shown in the tutorial, use MS Excel to draw line charts so that the performance differences between fib and efficFib can be clearly seen. The line chart will show the number of reductions versus n (n could vary from 0, 2, 4, 6, 8, .. 20)
|
||||||||||||||
|
|