Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming Doman’s Lecture CSCI101.

Similar presentations


Presentation on theme: "Introduction to Programming Doman’s Lecture CSCI101."— Presentation transcript:

1 Introduction to Programming Doman’s Lecture CSCI101

2 A deep understanding of programming, in particular the notions of successive decomposition as a mode of analysis and debugging of trial solutions, results in significant educational benefits in many domains of discourse, including those unrelated to computers and information technology per se. (Seymour Papert, in "Mindstorms") What is programming?

3  Programming is a creative process done by programmers to instruct a computer on how to do a task. (http://cplus.about.com)http://cplus.about.com  Writing an original program that performs a particular task that meets all stated constraints (Think Like a Programmer, V.Anton Spraul, No Starch Press, Inc. 2012) What is programming?

4 A lot of this lecture is taken from the book: Think Like a Programmer, By V.Anton Spraul, No Starch Press, Inc. 2012 What is programming?

5 Method or interface to do this: PROGRAMMING LANGUAGES Example: Java: Public class helloWorld { Public static void main ( ) { system.out.println(“Hello World”) } } Instruct a computer

6 Example: C++ #include using namespace std; int main() { cout << “Hello World” << endl; } Instruct a computer

7 Example: html Hello World Instruct a computer

8 GAMEMAKER Drag and drop structured language Uses icons, text…. Made to be easier than any of the previous languages. Instruct a computer

9  Programming is a creative process done by programmers to instruct a computer on how to do a task. (http://cplus.about.com)http://cplus.about.com What is programming?

10  Programming is a creative process done by programmers to instruct a computer on how to do a task. (http://cplus.about.com)http://cplus.about.com  Writing an original program that performs a particular task that meets all stated constraints (Think Like a Programmer, V.Anton Spraul, No Starch Press, Inc. 2012) What is programming?

11  Puzzles  Problem solving What is programming?

12 Your car has blue smoke coming from the tailpipe, is idling roughly and has lost fuel efficiency. How do you solve it? Problem Solving

13  Unbreakable rules about problems or the way in which problems must be solved.  Car problem constraints:  Cost of repair  How long before you need it fixed  No new tools be purchases Constraints

14  Programming language  Platform  Performance  Memory footprint  User/customer specific constraints  Design constraints. Common Programming Constraints

15  Figure out the steps to take to solve the problem  Be able to list the steps  Be able to repeat the steps  You can NOT change the rules (constraints) to get something solved! Problem solving

16 P ROBLEM : H OW TO CROSS THE RIVER ? A farmer with a fox, a goose and a sack of corn needs to cross a river. The farmer has a rowboat, but there is only room for the farmer and one of his three items. Unfortunately, both the fox and the goose are hungry. The fox cannot be left alone with the goose; the goose cannot be left alone with the grain. How does the farmer get everything across the river? Puzzle: Fox, goose, grain

17  Constraints  Only one item at a time in the boat  Can’t leave fox with goose  Can’t leave goose with grain  Operations  Carry the fox to the far side of the river  Carry the goose to the far side of the river  Carry the grain to the far side of the river Puzzle: Fox, goose, grain

18

19  Abstract the problem  Be more general in describing the way we will solve the problem  Concept: Variable Items are fox, goose or grain Let item vary between fox, goose or grain Rephrase the problem

20  Constraints  Only one item at a time in the boat  Can’t leave item(fox) with item(goose)  Can’t leave item(goose) with item(grain)  Operations  Row the boat from one shore to the other  If the boat is empty, load an item on the boat  If the boat is full, take the item off the boat Puzzle: Fox, goose, grain

21

22 Puzzle: Sudoku 347 81 625 5 8 47 1 9 73 347 891 625

23  Constraints   Techniques  Start with the easiest  Try something…… be prepared to change if it doesn’t work.  Try something else Puzzle: Soduko

24 P ROBLEM : T HE SLIDING EIGHT A 3x3 grid is filled with eight tiles, numbered 1 through 8 with one empty space. The grid is jumbled. A tile can be slid into an adjacent empty space, leaving its previous location empty. Slide the tiles so that they are in numerical order Puzzle: Sliding Tile

25 123 457 78 Puzzle: Sliding Tile Solution

26 472 861 35 Puzzle: Sliding Tile

27 Technique: the train A circuit of tile positions that include an empty slot forms a train of tiles that can be rotated anywhere along the circuit, preserving the relative order of the tiles. Puzzle: Sliding Tile

28 1 23 21 3 32 1 3 12

29  Look at the problem in subsets  P ROBLEM : T HE SLIDING FIVE Puzzle: Sliding Tile 68 547

30 68 547 568 47 456 7 8

31  Use this technique to generalize the solution to any sliding puzzle….. Puzzle: Sliding tile 472 861 35

32  Use this technique to generalize the solution to any sliding puzzle….. Puzzle: Sliding tile 472 861 35

33  Use this technique to generalize the solution to any sliding puzzle….. Puzzle: Sliding tile 456 81 327

34  Use this technique to generalize the solution to any sliding puzzle….. Puzzle: Sliding tile 456 81 327

35  Use this technique to generalize the solution to any sliding puzzle….. Puzzle: Sliding tile 1 23 68 547

36  Use this technique to generalize the solution to any sliding puzzle….. Puzzle: Sliding tile 1 23 68 547

37 Problem Solving  Have a plan  Generalize the problem  Restate the problem  Start with what you know  Divide the problem  Look for analogies or patterns  Experiment!!! THINK like a programmer!


Download ppt "Introduction to Programming Doman’s Lecture CSCI101."

Similar presentations


Ads by Google