cs 103 introductory programming for engineers and scientists j. michael fitzpatrick john d. crocetti...

16
CS 103 CS 103 Introductory Programming for Introductory Programming for Engineers and Scientists Engineers and Scientists J. Michael Fitzpatrick J. Michael Fitzpatrick John D. Crocetti John D. Crocetti 134 Jacobs Hall 134 Jacobs Hall

Upload: dorcas-crawford

Post on 03-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

CS 103CS 103Introductory Programming for Introductory Programming for

Engineers and ScientistsEngineers and Scientists

J. Michael FitzpatrickJ. Michael Fitzpatrick

John D. CrocettiJohn D. Crocetti

134 Jacobs Hall134 Jacobs Hall

Page 2: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Contact InformationContact Information

John CrocettiJohn Crocetti

Office: 381 Jacobs HallOffice: 381 Jacobs Hall

Email: Email: [email protected]@vanderbilt.edu

Phone: 322-8487Phone: 322-8487

Office Hours: MW 2:30 – Office Hours: MW 2:30 – 4:00pm or by appointment4:00pm or by appointment

J. Michael FitzpatrickJ. Michael Fitzpatrick

Office: 363 Jacobs HallOffice: 363 Jacobs Hall

Email: Email: [email protected]@vanderbilt.edu

Phone: 322-2365Phone: 322-2365

Office Hours: Thurs 1-4pmOffice Hours: Thurs 1-4pmor by appointmentor by appointment

Page 3: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Class WebsiteClass Website

http://eecs.vanderbilt.edu/courses/cs103/http://eecs.vanderbilt.edu/courses/cs103/

Page 4: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

What is Computer Science?What is Computer Science?

Computer Science is a discipline that Computer Science is a discipline that seeks to build a scientific foundation for a seeks to build a scientific foundation for a variety of topics, including computer variety of topics, including computer design, computer programming, design, computer programming, information processing, and problem information processing, and problem solving.solving.Computer science provides the Computer science provides the underpinnings for today’s computer underpinnings for today’s computer applications and future development.applications and future development.

Page 5: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Major Fields in Computer ScienceMajor Fields in Computer Science

Computer Architecture (hardware)Computer Architecture (hardware)

Computer Programming (software)Computer Programming (software)

Information Processing & StorageInformation Processing & Storage

Algorithmic Problem SolvingAlgorithmic Problem Solving

In this class, we will largely focus on programming and In this class, we will largely focus on programming and algorithmic problem solvingalgorithmic problem solving

Page 6: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Philosophy or Science?Philosophy or Science?

CS is as much a philosophy as it is a scienceCS is as much a philosophy as it is a science– CS forces you to think about problems and solutions CS forces you to think about problems and solutions

in new waysin new ways– You will learn problem solving techniques, such as You will learn problem solving techniques, such as

stepwise refinement, that will teach you to break down stepwise refinement, that will teach you to break down problems into small parts.problems into small parts.

– Problem solving, however, is an individual process. Problem solving, however, is an individual process. There is more than one “right” way. You will have to There is more than one “right” way. You will have to develop your own personal problem solving develop your own personal problem solving methodology.methodology.

– Sometimes, you have to think “outside the box”Sometimes, you have to think “outside the box”

Page 7: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Example Problem 1Example Problem 1

Joe has been charged with the task of determining the Joe has been charged with the task of determining the ages of Sally’s three children. (Assume the ages are ages of Sally’s three children. (Assume the ages are integers)integers)

Sally tells Joe the product of their ages is 36.Sally tells Joe the product of their ages is 36.

Joe decides that isn’t enough information.Joe decides that isn’t enough information.

Sally tells Joe the sum of the childrens’ agesSally tells Joe the sum of the childrens’ ages..Joe determines that he needs more information.Joe determines that he needs more information.

Sally tells Joe that her oldest child plays the piano.Sally tells Joe that her oldest child plays the piano.

Joe is now able to tell Sally the ages of her children.Joe is now able to tell Sally the ages of her children.

What are their ages?What are their ages?

Page 8: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Problem SolutionProblem Solution

Triples whose product is 36Triples whose product is 36(1, 1, 36)(1, 1, 36) (1, 2, 18)(1, 2, 18) (1, 3, 12)(1, 3, 12) (1, 4, 9)(1, 4, 9)

(1, 6, 6)(1, 6, 6) (2, 2, 9)(2, 2, 9) (2, 3, 6)(2, 3, 6) (3, 3, 4)(3, 3, 4)

Sums of triples from aboveSums of triples from above1+1+36=381+1+36=38 1+2+18=211+2+18=21 1+3+12=161+3+12=16 1+4+9=141+4+9=14

1+6+6=131+6+6=13 2+2+9=132+2+9=13 2+3+6=112+3+6=11 3+3+4=103+3+4=10

We know that knowing the sum of the triple isn’t enough to solve the We know that knowing the sum of the triple isn’t enough to solve the problem…therefore, the sum must appear twice….meaning the sum problem…therefore, the sum must appear twice….meaning the sum

must be 13. Since we know that there is an oldest child, the only must be 13. Since we know that there is an oldest child, the only remaining triple is 2, 2, 9.remaining triple is 2, 2, 9.

Page 9: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Example Problem 2Example Problem 2

Big nails cost $3 per poundBig nails cost $3 per pound

Small nails cost $2 per poundSmall nails cost $2 per pound

Sam bought 34 pounds of nails and paid Sam bought 34 pounds of nails and paid $80$80

How many pounds of each did he buy?How many pounds of each did he buy?

Page 10: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Problem SolutionProblem Solution

Let b = the number of big nailsLet b = the number of big nails

Let s = the number of small nailsLet s = the number of small nails

b + s = 34 (pounds) b + s = 34 (pounds)3b + 2s = 80 (dollars)3b + 2s = 80 (dollars)

Find b & s that solves both Find b & s that solves both problems simultaneously.problems simultaneously.

Matlab’s solution:Matlab’s solution:

Page 11: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Developing AlgorithmsDeveloping Algorithms

An algorithm is a set of instructions that An algorithm is a set of instructions that directs the execution of a task.directs the execution of a task.

Technically speaking, an algorithm is Technically speaking, an algorithm is a a finite sequence of unambiguous, executable finite sequence of unambiguous, executable steps that ultimately terminate if followed.steps that ultimately terminate if followed.

Page 12: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Syntax vs. SemanticsSyntax vs. Semantics

Syntax = representationSyntax = representation

Semantics = the concept representedSemantics = the concept represented

For example, the syntactic structure of the For example, the syntactic structure of the word “air” is merely a collection of three word “air” is merely a collection of three letters. But the object represented, the letters. But the object represented, the semantics, is a gaseous substance semantics, is a gaseous substance surrounding the entire world.surrounding the entire world.

Page 13: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Bridging the Gap From Semantics Bridging the Gap From Semantics to Syntaxto Syntax

A major goal of algorithm representation is A major goal of algorithm representation is ensuring that the syntax accurately reflects ensuring that the syntax accurately reflects the intended semantics.the intended semantics.

For example, what does the following phrase mean?For example, what does the following phrase mean?

““Visiting grandchildren can be nerve-racking.”Visiting grandchildren can be nerve-racking.”

Page 14: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

Why is Computer Science so hard?Why is Computer Science so hard?

In broad terms, you have three challenges:In broad terms, you have three challenges:– Learning how to develop algorithms to solve problemsLearning how to develop algorithms to solve problems– Understanding the syntax and semantics of a Understanding the syntax and semantics of a

programming language named Matlabprogramming language named Matlab– Writing Matlab programs to implement your Writing Matlab programs to implement your

algorithmsalgorithms

Students often focus or get frustrated with their Students often focus or get frustrated with their program, when their problem is oftentimes with program, when their problem is oftentimes with the algorithmthe algorithm

Page 15: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

CS103 is NOT a “weed out” courseCS103 is NOT a “weed out” course

Contrary to popular opinion, this class is Contrary to popular opinion, this class is not designed to “weed” you out.not designed to “weed” you out.

In reality, we’re going to great lengths to In reality, we’re going to great lengths to ensure you succeed: online homework ensure you succeed: online homework solutions, sample exams, regular help solutions, sample exams, regular help sessions, etc.sessions, etc.

Students, however, often make poor Students, however, often make poor choices that cause them to underperformchoices that cause them to underperform

Page 16: CS 103 Introductory Programming for Engineers and Scientists J. Michael Fitzpatrick John D. Crocetti 134 Jacobs Hall

How to Succeed in CS103How to Succeed in CS103

1.1. Stay on schedule – DO NOT FALL Stay on schedule – DO NOT FALL BEHIND!BEHIND!

2.2. Do your reading before coming to classDo your reading before coming to class

3.3. Use the online material provided to youUse the online material provided to you

4.4. Take advantage of the help sessions and Take advantage of the help sessions and your TAs’ & instructor’s office hoursyour TAs’ & instructor’s office hours

5.5. Form a good study groupForm a good study group