What is Computer Science 1 r We learn

  • Slides: 12
Download presentation
What is Computer Science 1 r We learn how to program a computer using

What is Computer Science 1 r We learn how to program a computer using a mixture of C and C++ l Basic constructs of the C++ language l How to design and use simple data structures r Understand the issues that matter to Computer Scientists and Professional Programmers l How to write complex programs quickly and efficiently l How to develop algorithms l How to organize data l How to maximize the reuse of data and programs r This course is the first in a sequence l CS 1 - basic programming l CS 2 - data structure programming l DSA - advanced programming and data structures Computer Science I - Martin Hardwick Lecture 1 -- 1

What you must ask yourself r Do I want to learn the details of

What you must ask yourself r Do I want to learn the details of programming? l Many computing activities such as using a spreadsheet or a database do not require you to understand how to write algorithms l Getting a program right can take a long time and be very tedious if you do not like sitting in front of a computer trying again and again r The experience and knowledge can be rewarding l Many problems in business, science and engineering can only be solved by writing a program l Most people will have to work with programmers during their careers so understanding what they do should be helpful l If you want to be a Computer Scientist and have not taken any Computer Science courses then you should start with CS 1 Computer Science I - Martin Hardwick Lecture 1 -- 2

Alternatives r If you think this course will be too hard but you still

Alternatives r If you think this course will be too hard but you still want to learn something about programming consider taking l CSCI 1190 Beginning C Programming for Engineers l BUT you cannot get credit for CS 1190 and any other CS course r If you think this course will be too easy consider going straight to CS II l Recommended for students with AP credit in Computer Science l You will not enjoy being bored l You will make it difficult for me to judge how well the course is progressing l Your fellow students will find it unpleasant watching you rush through the studios Computer Science I - Martin Hardwick Lecture 1 -- 3

Organization of CS 1 r Lectures l On the topic of the previous and

Organization of CS 1 r Lectures l On the topic of the previous and following Studio assignments l Background and context information that you will not get from just doing the studio assignment l There will be 10 quizzes during the lectures r Studios l Break into smaller sections – one TA per section – each section has its own lab time and location l Progressively learn how to write more complex C++ programs l Studio attendance is required and will be part of your grade r Exams l One final exam – which will also be your last chance to show you know how to write programs and algorithms r Homework l 4 Homework’s. First will be given at about Lecture 10. Computer Science I - Martin Hardwick Lecture 1 -- 4

Grading r Look at the rules in the syllabus l I will follow these

Grading r Look at the rules in the syllabus l I will follow these rules when computing your grade – 40% Quizzes (best 8 @ 5% each) – 20% Studios (best 20 @ 1% each) – 24% Homeworks (4 @ 6%) – 16% Final l A >= 90, B >= 80, C >= 70 D > = 60 F < 60 l I may raise your grade but I will never lower it unless you are caught cheating. r We make extensive use of RPI LMS in this course l Distribution of lecture notes (before the lecture) l Homework assignments l Distribution of grades for Studios, Homework’s and Exams l Announcements r The bulletin board l A good place to ask questions late at night. l Do not be rude to me, the TA’s or your fellow students. Computer Science I - Martin Hardwick Lecture 1 -- 5

Getting Started r A computer is a device for solving problems. l its advantage

Getting Started r A computer is a device for solving problems. l its advantage is its speed r Programming is nothing more than telling a computer how to solve a specific problem. l you can’t do this unless you know how to solve the problem yourself r Steps in using a computer: l understand the problem to be solved l figure out how to solve it yourself l develop an algorithm to solve the problem l write a program to tell the computer how to solve the problem Computer Science I - Martin Hardwick Lecture 1 -- 6

Algorithms r An algorithm is a step-by-step set of instructions for solving a problem.

Algorithms r An algorithm is a step-by-step set of instructions for solving a problem. l must be complete l must be unambiguous l must be in terms that are understood by the reader (man or machine) r An algorithm must have enough detail for the purpose l Algorithm to be given to a knowledgeable programmer (less detail) l Algorithm to be compiled on a machine (more detail) l In CS 1 nearly all our algorithms will be for the machine Computer Science I - Martin Hardwick Lecture 1 -- 7

An Algorithm for people r How to make a Rocky Road Egg l Input

An Algorithm for people r How to make a Rocky Road Egg l Input : One egg. One Piece of bread. One Frying pan. One vat of margarine. One knife. One stove with burner. l l Algorithm : 1. Spread margarine on both sides of bread with knife. 2. Cut a hole in the center of the bread with the knife. 3. Turn the burner on the stove on. 4. Put the frying pan on the turned on burner. 5. Put the bread on the frying pan. 6. Crack egg in the hole in the bread. 7. Wait 1. 5 minutes and then flip bread. 8. Wait 1 minute then remove bread with egg from frying pan. Output : A Rocky Road Egg Computer Science I - Martin Hardwick Lecture 1 -- 8

A machine Algorithm has to be very detailed r Because a computer can only:

A machine Algorithm has to be very detailed r Because a computer can only: l l l add two numbers subtract two numbers multiply two numbers divide two numbers compare two numbers to determine which is bigger based on a comparison, jump to a different part of a program save a number in a word of memory or a register fetch a number from a word of memory or a register read data from an input device write data to an output device read and write data to secondary storage interpret numbers as characters (e. g. , letters of the alphabet) r Fortunately the compiler breaks our C++ algorithms into these really simple pieces r In CS 1 we will learn how to write C++ algorithms and how to use the C++ compiler to convert them into programs. Computer Science I - Martin Hardwick Lecture 1 -- 9

Computer Organization Our programs manipulate this. As we advance we will learn more about

Computer Organization Our programs manipulate this. As we advance we will learn more about its details Computer I/O Devices RAM (memory) Central Processing Unit (CPU) Data Registers Program Secondary Storage Computer Science I - Martin Hardwick Instructions r Sometimes called random access memory (RAM). r Stores the numbers (data) that a program uses when it runs on the computer. r Also stores the instructions of the program that is running on the computer. r Divided into fixed size units of memory called words. l each word stores one number Lecture 1 -- 10

Number Systems r You are familiar with the base 10 number system in which

Number Systems r You are familiar with the base 10 number system in which each digit of a number is multiplied by a power of 10. 3 2 1 0 l for example: 4325 = 4 x 10 + 3 x 10 + 2 x 10 + 5 x 10 2 1 0 -1 + 3 x 10 -2 l for example: 103. 23 = 1 x 10 + 0 x 10 + 3 x 10 + 2 x 10 r Other number systems with a base different from 10 work in a similar fashion. 2 1 0 -1 (337. 5) l base 8 number system: 521. 48 = 5 x 8 + 2 x 8 + 1 x 8 + 4 x 8 l base 2 number system: 101. 12 = 1 x 22 + 0 x 21 + 1 x 20 + 1 x 2 -1 (5. 5) r A base X number system uses X symbols for digits. l namely, the symbols: 0, 1, …, X-1 r Two number systems are widely used in computers l binary -- base 2 with digits 0 and 1 l hexadecimal -- base 16 with digits 0, 1, 2, …, 9, A, B, C, D, E, F – 12 A 4 F 16 = 1 x 164 + 2 x 163 + 10 x 162 + 4 x 161 + 15 x 160 Computer Science I - Martin Hardwick (76367) Lecture 1 -- 11

Computer Number System Examples 101101011100010110011110110 11 B 5 5 12 5 C 9 5

Computer Number System Examples 101101011100010110011110110 11 B 5 5 12 5 C 9 5 12 9 B 5 C 59 CF 6 Computer Science I - Martin Hardwick C 15 F 6 binary number equivalent base 10 value for each group of 4 consecutive binary digits (bits) 6 corresponding hexadecimal (base 16) digit equivalent hexadecimal number Lecture 1 -- 12