20

IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

Embed Size (px)

Citation preview

Page 1: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya
Page 2: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

IS5000xx

Foundations of Problem Solving

Dr Lahen Ouarbya

Page 3: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

3

Content of the course 

– At the end of the problem solving part of the course, the student will be able to: – Understand basic problem solving algorithms and

corresponding data structures – Devise algorithms and build programs that solve concrete

problems – Perform test on algorithms and programs and correct

faults – Discuss and criticise basic programming principles – Read and understand simple programs and present them

to others in a workshop setting– Different algorithm will be examined during this course

Page 4: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

4

Delivery of the course

The course will be taught via lectures only – One 2-hour lecture per week

Page 5: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

5

Assessment

Two courses and one exam– Coursework 1 (first term) is worth 20%– Coursework 2 (second term) is worth 20%– Exam (end of the year (May)) is worth 60%

Page 6: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

6

Resources

– We will start by working through the textbook How to think like a programmer by Paul Vickers.

– The course web page on learn.gold will contain:– Lecture slides– Assignments and model solutions– Any important news about the course– Discussion forum

Page 7: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

7

About the title of this course– What is the relationship between

programming and problem solving?

Page 8: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

8

About the title of this course– A computer program is a solution to a problem.– It is not the computer that solves a problem: it is

you, the programmer who solves it by:– Identifying the problem– Understanding the problem– Identifying what factors are known and

unknown– Figuring out a systematic procedure for finding

the unknown values, given the known ones– Telling the computer what to do.

Page 9: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

9

From problem solutions to programs (I)Programming involves distinct skills such as– Ability to code in one or more programming

languages; understanding concepts such as variables, loops, conditionals; knowing where to put brackets, arrows, semi-colons, quote marks etc; knowing how to run programs on different computers

– Ability to analyse problems and formulate solutions which are explicit, unambiguous and systematic, so that they can be coded in a programming language

– This strand of lectures focusses on the second skillset.

Page 10: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

10

From problem solutions to programs (II)

– Human beings are very good at solving problems, we do it all the time:– Getting from your home to this room– Cooking dinner for 6 people– Making sure you can pay your bills every

month– What we are sometimes less good at is

explaining and reasoning about problem solutions.

Page 11: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

11

From problem solutions to programs (III)– We will start by taking a closer look at

“everyday” problems that we usually solve with very little thought, and see what is involved in analysing them as computational problems

– This may involve trying out different ways of formulating or visualising problems

– We will gradually introduce computational concepts such as variables, loops, conditionals etc

– We will cover different ways of representing solutions such as flowcharts and pseudocode.

Page 12: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

12

Class exercise

– Suppose your cousin from the country is staying at your house. He has never been to London before or travelled on an underground train. You have decided to meet in Trafalgar Square after the class.

– Get together in groups of 3 or 4 and compose a list of instructions for your cousin, which will ensure that he reaches Trafalgar Square by the agreed time without getting lost, run over or arrested.

Page 13: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

13

Class exercise: discussion

Some discussion points:– Does the problem naturally break down into

sub-problems?– What kind of terminology have you used? Can

you be sure your cousin will have understood it?– Are any of your instructions vague or

ambiguous? For instance, could your cousin have taken the wrong exit from a tube station?

– What assumptions have you made?

Page 14: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

14

Class exercise: discussion (cont)– Are there multiple solutions? If so, how do you evaluate

them and choose the best one?– For example, solutions could include:

– Walking all the way– Taking a taxi– Getting a lift all or part of the way– Hiring a chauffeur-driven Rolls-Royce– Cycling– Using public transport– Flying to Paris and taking the train through the

Channel Tunnel– What constraints might influence your choice of

solution?

Page 15: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

15

Complicating the problem

– Your cousin doesn’t speak English– However, you can speak and write his

language– Will your previous solution still work?– If not, what will have to change?

Page 16: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

16

The How to think like a programmer (HTTLAP) approach1. Understand the problem2. Devise a plan to solve the problem3. Carry out the plan4. Assess the result5. Describe what you have learned6. Document your solution

An extended version can be downloaded fromhttp://www.cengage.co.uk/vickers/students/Vickers_CH02_019-036.pdf

Page 17: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

17

1. Understanding the problemA poor understanding of a problem can prevent you

finding an optimal solution, or any solution at all.Two examples:1. An ant is at the corner of the ceiling and wants to

get to a bowl of sugar, which is on the floor at the far corner of the room. How would you calculate the shortest path it can follow?

2. Two trains are 100 miles apart on a single track, and heading towards each other at 60mph and 40mph respectively. A bird is flying back and forth between them at 70mph. How far will the bird have travelled before they collide?

Please do NOT shout out the answers; give everyone a chance to think it through.

Page 18: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

18

Summary of today’s lecture– Practicalities of the course– Relation between programming and problem

solving– Starting to look at everyday problems in a

computational way– A first look at the HTTLAP strategy (more next

time)

Page 19: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya

19

Activity for week 1

– Download and read through the HTTLAP strategy.

– Think about how you could apply it to the following problem:– You have a friend who comes from a very wealthy

family. He is reasonably intelligent and well-educated, but has never had to do anything for himself around the house or seen the inside of a kitchen. Write out precise and explicit instructions he can follow to make a pot of coffee and pour a cup, using an electric filter machine.

– Make a list of discussion points for next week’s lecture

Page 20: IS5000xx Foundations of Problem Solving Dr Lahen Ouarbya