Objectives
Develop problem-solving skills
Computer Science 1 Useful to all engineers
(1E3) Develop basic programming skills
Useful in some CAE applications
Necessary for computer and other engineers.
Lucy Hederman
[email protected] Introduce main themes of computer
science
Room G.13, O’Reilly Institute
Of general interest to all ???
1 Introduction 1 1 Introduction 2
Computers are Pervasive Problem-Solving
When did you last interface with a Compute the shortest route that visits a
computer? list of cities?
Or with a device that interfaces with a Find the web pages most likely to satisfy a
computer? query?
Produce monthly paychecks for TCD
Or with a human service provider who
employees.
depended on a computerised device to
Identify a car from an image of its number
deliver that service? plate.
1 Introduction 3 1 Introduction 4
1
Programming and Problem Solving An Algorithm
Determine how many times a name occurs in a list of
Algorithm names.
A sequence of precise instructions which 1. Input the list of names.
leads to a solution
2. Input the name being checked
Program 3. Set a counter to zero.
An algorithm expressed in a language the 4. For each name on the list
computer can understand If the list name is the same as the name being
checked
Add 1 to the counter.
5. Output the counter value as the answer.
1 Introduction 5 1 Introduction 6
Pseudocode Algorithm A program fragment in C++
Computes the sum of even numbers from 1 to
Determine how many times a name occurs in a list of an entered number
names.
1. Input the name-list.
2. Input the test-name.
3. Set a counter to be 0.
4. FOR EACH name on name- list
IF name is the same as test-name
THEN Add 1 to the counter.
5. Output counter. firstexample.cpp
1 Introduction 7 1 Introduction 8
2
Other things you might learn Practicalities
Computers are “stupid”. Lectures
Wed 12-1 Hamilton 3 theatre
Programming is easy, a bit tedious Fri 9-10 Ed Burke, Arts block
Problem solving is challenging and fun. Labs
Some things can’t be computed. Start week 3 (20th October)
1.5 hours per week
Attendance compulsory
Coursework
Completed in labs
Contributes 20% to overall mark.
Marks posted weekly
1 Introduction 9 1 Introduction 10
Textbook & Webpage Programming Language
C++ Programming: Program Design Including Data We’ll use C++
Structures, D.S. Malik, Fourth Edition, Thomson, C++ is an object-oriented (OO) language
ISBN 978-1-4239-0222-5
We’ll focus on the procedural aspects.
We’ll cover Chapters 1- 7, 9 and possibly 11.
Will also be used in 2E3 C++ is the OO extension of C
Strongly recommend that you buy it. C is a high-level language but allows low-
TCD library Call No. 500.16424P69 (Third Ed.) level control of machines.
http://www.tcd.ie/Engineering/Courses/BAI/ C is the language used by UNIX
JF_Subjects/1E3/ programmers.
1 Introduction 11 1 Introduction 12
3
Environment Next …
iMacs running Mac OS X “Jaguar” Next day we’ll look briefly at
SubEthaEdit text editor Computer architecture
To type in and edit your program files Programming languages
Terminal utility Problem-solving.
Gives UNIX interface
“make myprog.cpp”
Make compiles (and link) programs
“./myprog”
To run the compiled program myprog
1 Introduction 13 1 Introduction 14