welcome cosc 145: algorithmic thinking dr. donald simon simon@mathcs.duq.edu simond@duq.edu

Post on 19-Jan-2016

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Welcome

COSC 145: Algorithmic Thinking

Dr. Donald Simon

simon@mathcs.duq.edu

simond@duq.edu

Algorithms

From Wikipedia.org: Effective method for solving a problem Expressed as a finite sequence of steps List of well-defined instructions for completing a

task Describes a computation that proceeds through a

well-defined series of successive states Terminates in a final ending state

Enchiladas

• Preheat oven to 350° F.• In a heavy saucepan

– Heat 2 tablespoons of olive oil.– Saute

½ cup chopped onion

1 minced garlic clove

until golden– Add

1 tablespoon chili powder

1 cup tomato puree

½ cup chicken stock

Enchiladas (cont'd)

– Season with

Salt and pepper

1 teaspoon cumin• Spread sauce over tortillas• Fill centers with equal quantities of

Chopped raw onion

Chopped mozzarella cheese• Roll tortillas• Place in ovenproof dish• Pour more sauce over tops• Sprinkle with chopped mozzarella cheese• Heat thoroughly in oven about 15 minutes

Shampoo Instructions

• Apply shampoo to wet hair• Lather• Rinse• Repeat

Exercise 1

Computers are very good at following directions to

the letter. How are people?

Shake hands with everybody in the room and tell

them your name.

Question 1: How many hands did you shake?

Question 2: How many total handshakes were there?

Exercise 2

Stand in line by order by height.

Question: How did you determine where to stand?

Exercise 3

Stand in line by order of birthday.

Question: How did you determine where to stand?

Exercise 4

Sort one suit of cards into numerical order. Assume

that aces are high.

Question: Can you systematically describe how you

sorted the cards?

Exercise 5

Break up into pairs Person 1 in each pair will have a suit of cards Person 1 should scramble the cards Only Person 1 may look at the faces of the cards Person 2 will lead Person 1 in sorting the cards:

Person 2 may not touch or look at the faces of the cards Person 2 may ask Person 1 to compare two cards and state which

is smaller/larger Person 2 may ask Person 1 to move a card to a different place

Exercise 5 (cont'd)

Question: Can Person 1 systematically describe how

to sort the cards, i.e., give an algorithm for sorting

a suit of cards?

top related