1 / 83

CS 201 Introduction to Computing

CS 201 Introduction to Computing. SPRING 2017. This course will give you. Basic computer science notions Mostly C++ programming concepts with emphasis on computational problems Object Oriented Programming language At the end of this course, you will be able to develop algorithms

lawrencea
Download Presentation

CS 201 Introduction to Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 201 Introduction to Computing SPRING 2017

  2. This course will give you • Basic computer science notions • Mostly C++ programming concepts • with emphasis on computational problems • Object Oriented Programming language At the end of this course, you will be able to • develop algorithms • write programs using C++ • but not-so-big-applications

  3. Course Information • CS201 – Introduction to Computing • Website http://myweb.sabanciuniv.edu/gulsend/courses/cs201/ • also follow SUCourse • an e-mail list will be set up for announcements • so you are responsible to check your e-mails (sabanciuniv account) • Instructor: • Gülşen Demiröz, FENS L015, gulsend@sabanciuniv.edu • Textbook: A Computer Science Tapestry, by Owen Astrachan – several copies in the library • Weekly or Biweekly Homework Assignments

  4. Course Information • Lecture Schedule (in FENS G077): • Monday 13:40 - 15:30 • Tuesday 15:40 - 16:30 • Recitations will start first week • See your schedule for date, time and location • Recitations will also be used as labs, so please take your laptops with power cables to recitations • Freshmans could not register yet. • Ask for Special Approval to the recitation: • Go to the recitation section that you will add. • Attend all. It is to your benefit. Recitation Attendance: %4 of your grade.

  5. Course Policy • Grading (might change) • Two Midterm Exams + One Final Exam • Midterm 1 (23%): March 27th Monday 19:40 – 21:30 • Midterm 2 (23%): May 2nd Tuesday 19:40 – 21:30 • Final Exam (30% ): scheduled by registrar • Recitation Attendance (%4): %1 is left to the TA as “kanaat” • Homeworks (20% total): 7 homework will be assigned and they are not of equal weight • Important Notice about grading: • Weighted average is not the only criterion in letter grading; exam average compared to homework average will also be taken into consideration.

  6. Course Policy • No late homework without penalty • One late day is allowed at cost of 10% of full grade • Plagiarism is not tolerated • All homeworks have to be personal. • We use toolsto detect plagiarized homework. • Cooperation is not an excuse • If you do not know how to cooperate, don’t do it • Grades will be divided into the number of people who cooperated. • First case –100 (minus hundred), second fails the course! • Detailed policy is on the web site of the course

  7. Course Policy • Make-ups (detailed policy is on the web) • reports must come before or during the exam • you must be really sick to take a make-up exam • according to the by-laws, acceptance of report is up to the instructor • a medical report does not guarantee taking a make-up exam • make-ups will be much more harder

  8. Before CS 201 Maybe you used computers just for fun before Maybe you hate Maybe you are afraid of computers

  9. During CS 201 You may have bad dreams at the beginning And you may think of you are going nuts But if you work properly and spend considerable amount of time ...

  10. At the End of CS 201 Success is yours!

  11. The Burning Question • What is Computer Science and Engineering? 10

  12. The Burning Question • What is Computer Science and Engineering? • What is Science? • Science is the study and understanding of the possible (and beyond.) • Science is mainly analytic, that is, • it tries to analyze, understand and describe nature • Observe, hypothesize, predict, evaluate, and refine 11

  13. The Burning Question • What is Computer Science and Engineering? • What is Engineering? • Engineering is the study of the feasible, that is, what is possible within time, space and money constraints. • Engineering aims to synthesize the artificial, but, one should have very good analytical skills, also! 12

  14. What is Computer Science? • Computer science is the study and the science of the theoretical foundations of information and computation and their implementation and application in computer systems. • Information – data • Computation – processing, problem solving • A computer is a machine that manipulates data according to a list of instructions. • The discipline is called informatics in many countries • especially in Europe

  15. History of Computer Science • Computer Science is a relatively young discipline • More than 50 years • First graduate program at CMU (then Carnegie Tech) in 1965 • in Turkey first CS department in 1977 • Turing machine (1937) • abstract machine • theoretically capable of any computation that we can do with modern computers today

  16. Alan Turing (1912--1954) • A scientist and mathematician • Watch the movie The Imitation Game • Instrumental in breaking a German coding machine during WW II • Developed mathematical model of a computer called a Turing Machine (before computers) • Showed there are problems that cannot be solved by a computer • Was a long distance runner • committed suicide

  17. What is Computer Engineering? • An engineering discipline for building hardware and software systems that • store • transmit • process information. 16

  18. What do Computer Engineers do? • They build systems that process information. • They do research into how to build systems: • that are new (incorporating new ideas and technology), • that solve an important problem unsolved satisfactorily • that are “cheap” (so that they are affordable) 17

  19. Building Systems • Computer Engineers build information processing systems by bringing together • hardware • software so that the system • works, i.e. has (almost) no bugs • is fast, maintainable, robust, and affordable. 18

  20. Computer Science & Engineering Computer Science & Engineering is more than programming!!! • Hardware Engineering developing hardware products • Software Engineering developing software products • Operating Systems Windows, Linux/UNIX, MacOS • Graphics animation, entertainment, games • Computer Security hacking, digital signatures • Computer Networking made internet a reality • Artificial Intelligence thinking machines, learning • Scientific Computing biocomputing • Theoretical CS analyze algorithms • …….

  21. Problems, Algorithms, and Programs Problem Algorithm Program • Problem: A situation that needs to be dealt with • Algorithm: Computational procedure for solving a problem. • Program: Implementation of an algorithm using a specific programming language to execute on specific platforms

  22. Problem • In general: a situation that needs to be dealt with • Some problems: • Finding the best phone to buy • Tiding up your books so that you can find what you want easier • Going from SU Campus to Taksim Square • Problems defined more precisely: • Finding the cheapest phone to buy • Putting your books in alphabetical order so that you can find what you want easier • Going from SU Campus to Taksim Square by using a car not having an OGS/HGS I would spend 55 minutes defining the problem and then 5 minutes solving it. -- Albert Einstein

  23. Problem • In CS: a situation that needs to be dealt with, by a using computer • Some problems in CS: • Finding the smallest number in a given set (Finding the cheapest phone to buy) • Sorting a given set of items (Putting your books in alphabetical order) • Finding a path in a graph (Going from SU Campus to Taksim Square by using a car not having an OGS/HGS)

  24. Algorithms • Arabic-originated word • Step-by-step process that solves a problem • do this, then do that, ... • eventually stops with an answer • general process rather than specific to a programming language

  25. Algorithms • Example algorithms to solve a problem • An example algorithm to go from SU Campus to Taksim: • Turn right after leaving the campus • Drive 2-3km and turn left • … • A more precise algorithm to go from SU Campus to Taksim: • Turn right after leaving the campus • Drive 2512 meters and turn left • …

  26. Example Algorithms – Find The Heaviest Ball A B C 3 seemingly identical steel balls A two arm balance scale

  27. Example Algorithm - Find the minimum • Initial list: 4 6 7 3 9 1 4 5 • Should we sort? 1 3 4 4 5 6 7 9 • About (n.log(n)) operations, where n is the number of elements • Optimal algorithm - About n operations • Pick 4 as the minimum • Compare 4 to 6 - min is still 4 • Compare 4 to 7- min is still 4 • Compare 4 to 3 - Pick 3 as the minimum • Compare 3 to 9- min is still 3 • Compare 3 to 1 - Pick 1 as the minimum • Compare 1 to 4- min is still 1 • Compare 1 to 5 - We are done and the minimum is 1

  28. Algorithms • Issues • correctness • complexity and efficiency • I picked a number between 1 and 100 • You will guess it • I’ll respond “high”, “low”, “correct”. • how many guesses needed (worst case)?

  29. Programs • A program is an implementation of an algorithm • using a specific programming language • to execute on specific platforms • Programming language are needed, because natural languages are • vague • ambiguous • hard to reason about

  30. Programming Languages • A programming language is a formal constructed language to communicate instructions to a machine, particularly to a computer • High-level programming languages • C++, Java, C, C#, Perl, Fortran, Lisp, Scheme, Visual BASIC, ... • Low-level programming languages • Assembly language

  31. High-Level vs. Low-Level Languages • Rather than instruct computers at the level of 0’s and 1’s, higher level languages have been developed. • Flexible and easier programming

  32. High-Level vs. Low-Level Languages assembler compiler main: pushl %ebp movl %esp,%ebp subl $12,%esp movl $7,-4(%ebp) movl $12,-8(%ebp) movl -4(%ebp),%eax imull -8(%ebp),%eax movl %eax,-12(%ebp) xorl %eax,%eax jmp .L1 .align 4 xorl %eax,%eax jmp .L1 int main() { int x, y, z; x = 7; y = 12; z = x * y; return 0; } high-level low-level (assembly) lowest-level (binary)

  33. Compilers • Translate a high level language, such as C++, into machine-specific executable program (0s and 1s) • The compiler is a program, input is C++ program, output is an executable binary program • In theory, C++ source code works on any machine given a compiler for the machine • for other languages different compilers are needed

  34. Levels of Programming Language - assembly • Machine specific assembly language, Sparc on left, Pentium on right, both generated from the same C++ code main: main: save %sp,-128,%sp pushl %ebp mov 7,%o0 movl %esp,%ebp st %o0,[%fp-20] subl $12,%esp mov 12,%o0 movl $7,-4(%ebp) st %o0,[%fp-24] movl $12,-8(%ebp) ld [%fp-20],%o0 movl -4(%ebp),%eax ld [%fp-24],%o1 imull -8(%ebp),%eax call .umul,0 movl %eax,-12(%ebp) nopxorl %eax,%eax st %o0,[%fp-28] jmp .L1 mov 0,%i0 .align 4 b .LL1 xorl %eax,%eax nopjmp .L1

  35. Data Representation in Computers • All types of data are represented in numeric format • characters – ASCII (Unicode) codes • ‘+’ = 43, ‘A’=65, 'C’=67, ‘Z’=90 • colors – RGB values • Music files, such as .mp3 files, and video files, such as .mov files are also represented in numbers • Emails, tweets, facebook messages • Low-level machine instructions • And everything else

  36. Data Representation in Computers • Internal representation (at the lowest level) is in binary form, i.e., in base-2 numeral system • 0s and 1s • all arithmetic in binary too • Examples • 410 = 1002 • 510 = 1012 • 6710= 010000112 • 4310= 001010112

  37. Representation vs. Interpretation • Programs instruct computers on how to interpret these binary numbers • For Example 0100001100101011001010112 can be interpreted as • As string ‘C++’ 0100001100101011001010112 • As RGB color 0100001100101011001010112 blue + green + red C

  38. A Simple Scenario • Problem • Given 3 numbers, compute their sum • Algorithm • Display a prompt for data entry • Input 3 numbers: number1, number2, number3 • sum  number1 + number2 + number3 • Output sum • Program • First, we will write a C++ program and run it using MS Visual Studio (sum3num.cpp) • Then we will see an animation about the steps taken during the execution

  39. MS Visual Studio .NET (2012) • One way of developing C++ programs • You will install to your laptops • Help will be available in first week labs • Check website for instructions on how to install, if you prefer to install before the labs • You can install • over the network \\software\microsoft\VisualStudio\Visual_Studio_2012 • step-by-step installation screenshots are on course web site

  40. A Simple Program – Execution steps

  41. COMPUTERS Central Processing Unit (CPU) executes primitive instructions

  42. COMPUTERS Random Access Memory (RAM) stores instructions & data Central Processing Unit (CPU) executes primitive instructions

  43. Memory • Primary memory is generally RAM • fast data access • volatile • electricity gone, data gone • expensive • Secondary memory (storage) • Disks, tapes, CD-ROMs, floppies, flash memory • non-volatile • slow data access • cheap • ROM (Read-only memory) • BIOS (Basic Input Output System) - to start the system (before the operating system)

  44. bus … bunch of other hardware … COMPUTERS Random Access Memory (RAM) stores instructions & data Central Processing Unit (CPU) executes primitive instructions instructions & data motherboard

  45. COMPUTERS CD-ROM Random Access Memory (RAM) stores instructions & data keyboard monitor printer hard disk mouse Central Processing Unit (CPU) executes primitive instructions input/output (IO) devices are input and output devices at the same time output devices return data from the system input devices provide instructions and data to the system instructions & data bus

  46. A Typical Computer System

  47. A Motherboard

  48. Important Parameters Random Access Memory (RAM) stores instructions & data Central Processing Unit (CPU) executes primitive instructions • CPU Speed: Hz, MHz(106 Hz), GHz (109 Hz), etc. • Memory Capacity: Megabytes, Gigabytes, etc. 46

  49. How Much Memory Is That? • Bit • A basic unit of information storage • Stores a binary decision yes/no, or 0/1  47

  50. How Much Memory Is That? • Byte 8 bits • 1 byte: One character • 140 bytes: Longest possible tweet (under certain assumptions) 48

More Related