Introduction to Programming Doman’s Lecture CSCI101.
-
Upload
kristina-green -
Category
Documents
-
view
222 -
download
3
Transcript of Introduction to Programming Doman’s Lecture CSCI101.
![Page 1: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/1.jpg)
Introduction to Programming
Doman’s LectureCSCI101
![Page 2: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/2.jpg)
Programming is a creative process done by programmers to instruct a computer on how to do a task. (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?
![Page 3: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/3.jpg)
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?
![Page 4: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/4.jpg)
Method or interface to do this:
PROGRAMMING LANGUAGESExample: Java:
Public class helloWorld {Public static void main ( ) {
system.out.println(“Hello World”) }}
Instruct a computer
![Page 5: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/5.jpg)
Example: C++
#include<iostream>using namespace std;
int main(){
cout << “Hello World” << endl;}
Instruct a computer
![Page 6: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/6.jpg)
Example: html
<html><body><p> Hello World </p></body></html>
Instruct a computer
![Page 7: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/7.jpg)
GAMEMAKER
Drag and drop structured language
Uses icons, text…. Made to be easier than any of the previous languages.
Instruct a computer
![Page 8: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/8.jpg)
Programming is a creative process done by programmers to instruct a computer on how to do a task. (http://cplus.about.com)
What is programming?
![Page 9: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/9.jpg)
Puzzles
Problem solving
What is programming?
![Page 10: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/10.jpg)
Your car has blue smoke coming from the tailpipe, is idling roughly and has lost fuel efficiency.
How do you solve it?
Problem Solving
![Page 11: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/11.jpg)
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
![Page 12: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/12.jpg)
Programming language Platform Performance Memory footprint
User/customer specific constraints Design constraints.
Common Programming Constraints
![Page 13: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/13.jpg)
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
![Page 14: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/14.jpg)
PROBLEM: HOW 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
![Page 15: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/15.jpg)
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
![Page 16: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/16.jpg)
Puzzle: Fox, goose, grain
![Page 17: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/17.jpg)
Abstract the problem Be more general in describing the way we
will solve the problem
Concept: VariableItems are fox, goose or grainLet item vary between fox, goose or grain
Rephrase the problem
![Page 18: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/18.jpg)
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
![Page 19: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/19.jpg)
Puzzle: Fox, goose, grain
![Page 20: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/20.jpg)
Puzzle: Sudoku
3 4 7
8 1
6 2 5
5 8
4 7
1 9
7 3
3 4 7
8 9 1
6 2 5
![Page 21: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/21.jpg)
Constraints
Techniques Start with the easiest Try something…… be prepared to change if it
doesn’t work. Try something else
Puzzle: Soduko
![Page 22: Introduction to Programming Doman’s Lecture CSCI101.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dde5503460f94ad7b75/html5/thumbnails/22.jpg)
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!