Programming Practicum

21
Programming Practicum Day 1: Introduction and Problem Solving Aaron Tan NUS School of Computing

description

Programming Practicum. Day 1: Introduction and Problem Solving Aaron Tan NUS School of Computing. Contents. Why are You here? What is Computer Science? What is Problem Solving? What is Algorithmic Problem Solving?. Why are You here?. What are your objectives? - PowerPoint PPT Presentation

Transcript of Programming Practicum

Page 1: Programming  Practicum

Programming Practicum

Day 1: Introduction and Problem SolvingAaron Tan

NUS School of Computing

Page 2: Programming  Practicum

2

Contents Why are You here? What is Computer Science? What is Problem Solving? What is Algorithmic Problem Solving?

[Programming Practicum, December 2009]

Page 3: Programming  Practicum

3

Why are You here? What are your objectives? What is your level of programming skills? What you think programming is about?

3[Programming Practicum, December 2009]

Page 4: Programming  Practicum

4

What is Computer Science? (1/2) Computing Curricula 2001 (Computer Science) Report

identifies 14 knowledge focus groups Applications within and outside of Computing

Discrete Structures (DS) Programming Fundamentals (PF) Algorithms and Complexity (AL) Architecture and Organization (AR) Operating Systems (OS) Net-Centric Computing (NC) Programming Languages (PL)

Human-Computer Interaction (HC) Graphics and Visual Computing (GV) Intelligent Systems (IS) Information Management (IM) Social and Professional Issues (SP) Software Engineering (SE) Computational Science (CN)

4[Programming Practicum, December 2009]

Page 5: Programming  Practicum

5

What is Computer Science? (2/2) Some recommended readings

How to Think about AlgorithmsJeff Edmonds, Cambridge, 2008

Algorithmics: The Spirit of ComputingDavid Harel, 2nd ed, Addison-Wesley (3rd ed. available)

Introduction to AlgorithmsT.H. Cormen, C.E. Leiserson, R.L. Rivest, C. Stein, 2nd ed, MIT Press

The New Turing Omnibus: 66 Excursions in Computer ScienceA.K. Dewdney, Holt

5[Programming Practicum, December 2009]

Page 6: Programming  Practicum

6[Programming Practicum, December 2009]

Problem Solving Process (1/5) Analysis Design Implementation Testing

Determine the inputs, outputs, and other components of the problem.

Description should be sufficiently specific to allow you to solve the problem.

Page 7: Programming  Practicum

7

Problem Solving Process (2/5) Analysis Design Implementation Testing

Describe the components and associated processes for solving the problem.

Straightforward and flexible

Method – process

Object – component and associated methods

[Programming Practicum, December 2009]

Page 8: Programming  Practicum

8

Problem Solving Process (3/5) Analysis Design Implementation Testing

Develop solutions for the components and use those components to produce an overall solution.

Straightforward and flexible

[Programming Practicum, December 2009]

Page 9: Programming  Practicum

9

Problem Solving Process (4/5) Analysis Design Implementation Testing

Test the components individually and collectively.

[Programming Practicum, December 2009]

Page 10: Programming  Practicum

10

Problem Solving Process (5/5)

Testing

Design

Analysis

Implementation

Determineproblem features

Describe objectsand methods

Produce theclasses and code

Examine forcorrectness

Rethink asappropriate

[Programming Practicum, December 2009]

Page 11: Programming  Practicum

11

Problem Solving Exercises The exercises in the next few slides are of

varied nature, chosen to illustrate the extent of general problem solving.

Different kinds of questions require different domain knowledge and strategies.

Apply your problem solving skills and creativity here!

[Programming Practicum, December 2009]

Page 12: Programming  Practicum

12

Exercise #1: Bear A bear, starting from the point P, walked one

mile due south. Then he changed direction and walked one mile due east. Then he turned again to the left and walked one mile due north, and arrived at the point P he started from. What was the colour of the bear?

[Programming Practicum, December 2009]

Page 13: Programming  Practicum

13

Exercise #2: Silver chain A traveller arrives at an inn and intends to

stay for a week. He has no money but only a silver chain consisting of 7 links. He uses one link to pay for each day spent at the inn, but the innkeeper agrees to accept no more than one broken link. How should the traveller cut up the chain in order to settle accounts with the innkeeper on a daily basis?

[Programming Practicum, December 2009]

Page 14: Programming  Practicum

14

Exercise #3: Glasses of milk Six glasses are in a row, the first three full of

milk, the second three empty. By moving only one glass, can you arrange them so that empty and full glasses alternate?

[Programming Practicum, December 2009]

Page 15: Programming  Practicum

15

Exercise #4: Puzzles What am I?

You can catch me but not throw me. I go all around the world but stay in the corner. You throw away the outside and eat the inside.

Then you eat the outside and throw away the inside.

[Programming Practicum, December 2009]

Page 16: Programming  Practicum

16

Exercise #5: Mad scientist A mad scientist wishes to make a chain out of

plutonium and lead pieces. There is a problem, however. If the scientist places two pieces of plutonium next to each other, BOOM!!! The question is, in how many ways can the scientist safely construct a chain of length n?

[Programming Practicum, December 2009]

Page 17: Programming  Practicum

17

Exercise #6: Dominoes Figure 1 below shows a domino and Figure 2 shows a 44 board

with the two squares at opposite corners removed. How do you show that it is not possible to cover this board completely with dominoes? All dominoes should lay flat on the board, without overlapping one another, and should not cover area outside the board.

Figure 1. A domino.

Figure 2. A 44 board with 2 corner squares removed.

General case: How do you show the same for an nn board with the two squares at opposite corners removed, where n is even?

Special case: How do you show the same for an nn board with the two squares at opposite corners removed, where n is odd?

[Programming Practicum, December 2009]

Page 18: Programming  Practicum

18

Exercise #7: Triominoes Figure 3 below shows a triomino and Figure 4 shows a 4 4 board

with a defect (hole) in one square. How do you show that the board can be covered with triominoes?

General case: How do you show that a 2n 2n board (where n 1) with a hole in one square (anywhere on the board) can be covered with triominoes?

Figure 3. A triomino.

Figure 4. A 44 board with a hole.

[Programming Practicum, December 2009]

Page 19: Programming  Practicum

19

Algorithmic Problem Solving An algorithm is a well-defined computational

procedure consisting of a set of instructions, that takes some value or set of values, as input, and produces some value or set of values, as output.

AlgorithmInput Output

ExactTerminate

Effective

General

[Programming Practicum, December 2009]

Page 20: Programming  Practicum

20

Task 3: NE-Paths To find the number of north-east paths between any two

points. North-east (NE) path: you may only move northward or

eastward. How many NE-paths between A and C?

C

AA

A

A

20[Programming Practicum, December 2009]

Page 21: Programming  Practicum

21

THE END