CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:

Slides:



Advertisements
Similar presentations
Chapter 1: Computer Systems
Advertisements

Programming Languages
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
1 Kursusform  13 uger med: Undervisning i klassen 1,5-2 timer Opgave ”regning” i databar (løsninger på hjemmeside) En midtvejsopgave der afleveres og.
The Java Programming Language
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Outline Java program structure Basic program elements
Chapter 1 Introduction. © 2004 Pearson Addison-Wesley. All rights reserved1-2 Outline Computer Processing Hardware Components Networks The Java Programming.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Chapter 1 Introduction.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Java: Chapter 1 Computer Systems Computer Programming II Aug
Chapter 1 Introduction.
Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R# address: Group Addresses Post message:
HOW COMPUTERS MANIPULATE DATA Chapter 1 Coming up: Analog vs. Digital.
Chapter 1 Programming Languages. Application Development: Top 10 Programming Languages to Keep You Employed 1. Java 2. C# 3. C++ 4. JavaScript 5. Visual.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley John Lewis, Peter DePasquale, and Joseph Chase Chapter 1: Introduction.
© 2004 Pearson Addison-Wesley. All rights reserved August 22, 2007 Compiling and Compiler Errors ComS 207: Programming I (in Java) Iowa State University,
© 2006 Pearson Education Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition.
Java: Chapter 1 Computer Systems Computer Programming II.
Java Language and SW Dev’t
Welcome to Computing Presentation slides modified by M. A. Papalaskari from “Java Software Solutions Foundations of Program Design (3 rd ed.)” by John.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Mendel 162C Course website:
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Chapter 1 Introduction 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
Introduction. Objectives An overview of object-oriented concepts. Programming and programming languages An introduction to Java 1-2.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Chapter 2: Java Fundamentals
Chapter 1: Introduction Java Programming Language How the Java Virtual Machine Works (compiling, etc…) Update by: Dan Fleck Coming up: The Java Programming.
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
Lecture 2 Software Concepts Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
1 Problem Solving b The purpose of writing a program is to solve a problem b The general steps in problem solving are: Understand the problemUnderstand.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
© 2006 Pearson Education Chapter 1: Computer Systems.
Programming in Java (COP 2250) Lecture 2 Chengyong Yang Fall, 2005.
Intro to Programming  Chapter 1 Part 2  Problem Solving.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Chapter 1 Introduction. 2 Focus of the Course Object-Oriented Software Development problem solving program design, implementation, and testing object-oriented.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Working with Java.
Lecture 1 Introduction Richard Gesick.
1.3 Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: Understand the problem Dissect the.
Chapter 1: Introduction to Computers and Programming
Hardware and Software Hardware Software
null, true, and false are also reserved.
Introduction to Java Programming
Instructor: Alexander Stoytchev
Chapter 1: Computer Systems
Topics Introduction Hardware and Software How Computers Store Data
Units with – James tedder
Compiling and Compiler Errors
Units with – James tedder
Instructor: Alexander Stoytchev
Java Software Solutions Foundations of Program Design 9th Edition
Focus of the Course Object-Oriented Software Development
Instructor: Alexander Stoytchev
Chap 2. Identifiers, Keywords, and Types
Instructor: Alexander Stoytchev
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: CSC 1051 M.A. Papalaskari, Villanova University Lecture 2: Data representation History of computing Intro to Java

Last time: Go over syllabus/course information – Take the online survey Introduction to the course – reverse history of computing CSC 1051 M.A. Papalaskari, Villanova University

Last time: History of computers Great human developments that gave rise to the modern computer: Number systems and other encodings – data representation Mechanization of arithmetic – the concepts of algorithms and computation Automatic control of computation – a “program” to control operations (fetch/decode/execute cycle and the stored program concept) CSC 1051 M.A. Papalaskari, Villanova University

Today: Data representation Software Introduction to Java programming CSC 1051 M.A. Papalaskari, Villanova University

Data Representation Computers store all information digitally, using binary codes: –numbers –text –images –audio –video –program instructions CSC 1051 M.A. Papalaskari, Villanova University

Analog vs. Digital Data Analog –continuous, in direct proportion to the data represented –music on a record album - a needle rides on ridges in the grooves that are directly proportional to the voltages sent to the speaker Digital –information is broken down into pieces, and each piece is represented separately –sampling – record discrete values of the analog representation CSC 1051 M.A. Papalaskari, Villanova University

Binary Numbers Number system consisting of 1’s & 0’s Simplest way to represent digital information modern computers use binary numbers internally A binary digit is called a bit - binary digit A byte is a group of eight bits CSC 1051 M.A. Papalaskari, Villanova University

Representing and processing bits Electronic circuits: high/low voltage Magnetic devices (eg hard drive): positive/negative Optical devices (eg DVD): light reflected/not reflected due to microscopic grooves CSC 1051 M.A. Papalaskari, Villanova University

Bit Permutations 1 bit bits bits bits Each additional bit doubles the number of possible permutations CSC 1051 M.A. Papalaskari, Villanova University

Bit Permutations How many permutations of N bits? How many bits are needed to represent 64 items? How many bits are needed to represent 100 items? 1 bit ? 2 bits ? 3 bits ? 4 bits ? 5 bits ? How many items can be represented by CSC 1051 M.A. Papalaskari, Villanova University

Binary Representation of Information Computers store all information digitally, using binary codes: –numbers –text –images –audio –video –program instructions CSC 1051 M.A. Papalaskari, Villanova University

Representing Text Digitally For example, every character is stored as a number, including spaces, digits, and punctuation Corresponding upper and lower case letters are separate characters H i, H e a t h e r binary ASCII / UNICODE CSC 1051 M.A. Papalaskari, Villanova University

Color:(108,86,142) Position: (12,9) x = 12 y = 9 red=108green=86blue=142

CSC 1051 M.A. Papalaskari, Villanova University Pixel encodings Bitmap 1 bit Grayscale 8 bits RGB Color 3 colors: red, green, blue 8 bits/color 24 bits

Program instructions are also encoded in binary E.g., could be the code that causes input of a symbol from the keyboard CSC 1051 M.A. Papalaskari, Villanova University

Memory devices store data of all kinds a number? a letter? the red component of a pixel? a program instruction? CSC 1051 M.A. Papalaskari, Villanova University

Large values are stored in consecutive memory locations Each memory cell stores a set number of bits (usually 8 bits, or one byte) CSC 1051 M.A. Papalaskari, Villanova University Memory devices store data of all kinds

Why is main memory called “RAM”???? CSC 1051 M.A. Papalaskari, Villanova University

“Random Access Memory (RAM)” You don’t have to scan the memory sequentially – go to data directly using the address CSC 1051 M.A. Papalaskari, Villanova University

Memory characteristics Direct access or Random access – information can be reached directly (as opposed to sequentially as in the case of magnetic tape) Volatile - stored information is lost if the electric power is removed Read/Write – information can be overwritten (as opposed to read-only devices – ROM) CSC 1051 M.A. Papalaskari, Villanova University

What is “ROM”? is it the opposite of “RAM”???? CSC 1051 M.A. Papalaskari, Villanova University

What is “ROM”? is it the opposite of “RAM”???? CSC 1051 M.A. Papalaskari, Villanova University Read Only Memory

What is “ROM”? is it the opposite of “RAM”???? CSC 1051 M.A. Papalaskari, Villanova University Read Only Memory NO! ROM is also random access

RAM vs. ROM RAM - Random Access Memory – synonymous with main memory: fast read/write volatile random access ROM - Read-Only Memory –ROM typically holds the firmware, eg BIOS fast (except in CD-ROM) read only non-volatile random access CSC 1051 M.A. Papalaskari, Villanova University

Random Access Memory Devices VolatileNon-volatile fastest CPU registers Cache memory ROM chip fast main memory ( Also called Random Access Memory -- RAM) ROM chip slow USB flash drive Hard disks CD-ROM DVD CSC 1051 M.A. Papalaskari, Villanova University

Random Access Memory Devices VolatileNon-volatile fastest CPU registers Cache memory ROM chip fast main memory ( Also called Random Access Memory -- RAM) ROM chip slow USB flash drive Hard disks CD-ROM DVD Electronic circuits CSC 1051 M.A. Papalaskari, Villanova University

Random Access Memory Devices VolatileNon-volatile fastest CPU registers Cache memory ROM chip fast main memory ( Also called Random Access Memory -- RAM) ROM chip slow USB flash drive Hard disks CD-ROM DVD magnetic CSC 1051 M.A. Papalaskari, Villanova University

Random Access Memory Devices VolatileNon-volatile fastest CPU registers Cache memory ROM chip fast main memory ( Also called Random Access Memory -- RAM) ROM chip slow USB flash drive Hard disks CD-ROM DVD optical CSC 1051 M.A. Papalaskari, Villanova University

Storage Capacity Every memory device has a storage capacity, indicating the number of bytes it can hold Capacities are expressed in various units: UnitSymbolNumber of Bytes kilobyteKB2 10 = 1024 megabyteMB2 20 (over one million) gigabyteGB2 30 (over one billion) terabyteTB2 40 (over one trillion) petabytePB2 50 (a whole bunch) CSC 1051 M.A. Papalaskari, Villanova University

Hardware and Software Hardware –the physical, tangible parts of a computer –keyboard, monitor, disks, wires, chips, etc. Software –programs and data –a program is a series of instructions A computer requires both hardware and software Each is essentially useless without the other CSC 1051 M.A. Papalaskari, Villanova University

Software – What is it? CSC 1051 M.A. Papalaskari, Villanova University

Communicating with a Computer Programming language: –A series of specifically defined commands –Given by human programmers –To give directions to the digital computers CSC 1051 M.A. Papalaskari, Villanova University

Translation Needed Special program to translate into binary Programmer writes –Source code Translation produces the binary equivalent – Object code The translator is an assembler, compiler, or an interpreter –Takes in the source code –Yields computer understandable instructions CSC 1051 M.A. Papalaskari, Villanova University

Java A programming language specifies the words and symbols that we can use to write a program A programming language employs a set of rules that dictate how the words and symbols can be put together to form valid program statements The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since CSC 1051 M.A. Papalaskari, Villanova University

Java Program Structure In the Java programming language: –A program is made up of one or more classes –A class contains one or more methods –A method contains program statements These terms will be explored in detail throughout the course A Java application always contains a method called main See Lincoln.java Lincoln.java CSC 1051 M.A. Papalaskari, Villanova University

//******************************************************************** // Lincoln.java Author: Lewis/Loftus // // Demonstrates the basic structure of a Java application. //******************************************************************** public class Lincoln { // // Prints a presidential quote. // public static void main (String[] args) { System.out.println ("A quote by Abraham Lincoln:"); System.out.println ("Whatever you are, be a good one."); }

CSC 1051 M.A. Papalaskari, Villanova University //******************************************************************** // Lincoln.java Author: Lewis/Loftus // // Demonstrates the basic structure of a Java application. //******************************************************************** public class Lincoln { // // Prints a presidential quote. // public static void main (String[] args) { System.out.println ("A quote by Abraham Lincoln:"); System.out.println ("Whatever you are, be a good one."); } Output A quote by Abraham Lincoln: Whatever you are, be a good one.

Java Program Structure public class MyProgram {}{} // comments about the class class header class body Comments can be placed almost anywhere CSC 1051 M.A. Papalaskari, Villanova University

Java Program Structure public class MyProgram {}{} // comments about the class public static void main (String[] args) {}{} // comments about the method method header method body CSC 1051 M.A. Papalaskari, Villanova University

Comments Comments in a program are called inline documentation They should be included to explain the purpose of the program and describe processing steps They do not affect how a program works Java comments can take three forms: // Basic this comment runs to the end of the line /* Basic this comment runs to the terminating symbol, even across line breaks */ /** this is a javadoc comment */ CSC 1051 M.A. Papalaskari, Villanova University

Identifiers Identifiers are the words a programmer uses in a program An identifier can be made up of letters, digits, the underscore character ( _ ), and the dollar sign Identifiers cannot begin with a digit Java is case sensitive - Total, total, and TOTAL are different identifiers By convention, programmers use different case styles for different types of identifiers, such as –title case for class names - Lincoln –upper case for constants - MAXIMUM CSC 1051 M.A. Papalaskari, Villanova University

Identifiers Sometimes we choose identifiers ourselves when writing a program (such as Lincoln ) Sometimes we are using another programmer's code, so we use the identifiers that he or she chose (such as println ) Often we use special identifiers called reserved words that already have a predefined meaning in the language A reserved word cannot be used in any other way CSC 1051 M.A. Papalaskari, Villanova University

Reserved Words The Java reserved words: abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while CSC 1051 M.A. Papalaskari, Villanova University

White Space Spaces, blank lines, and tabs are called white space White space is used to separate words and symbols in a program Extra white space is ignored A valid Java program can be formatted many ways Programs should be formatted to enhance readability, using consistent indentation See Lincoln2.java, Lincoln3.java Lincoln2.java Lincoln3.java CSC 1051 M.A. Papalaskari, Villanova University

Program Development The mechanics of developing a program include several activities –writing the program in a specific programming language (such as Java) –translating the program into a form that the computer can execute –investigating and fixing various types of errors that can occur Software tools can be used to help with all parts of this process CSC 1051 M.A. Papalaskari, Villanova University

Errors A program can have three types of errors The compiler will find syntax errors and other basic problems (compile-time errors) –If compile-time errors exist, an executable version of the program is not created A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally (run-time errors) A program may run, but produce incorrect results, perhaps using an incorrect formula (logical errors) CSC 1051 M.A. Papalaskari, Villanova University

Java Translation Java source code Machine code Java bytecode Bytecode interpreter Bytecode compiler Java compiler CSC 1051 M.A. Papalaskari, Villanova University

Development Environments There are many programs that support the development of Java software, including: –Sun Java Development Kit (JDK) –Sun NetBeans –IBM Eclipse –IntelliJ IDEA –Oracle JDeveloper –BlueJ –jGRASP Though the details of these environments differ, the basic compilation and execution process is essentially the same CSC 1051 M.A. Papalaskari, Villanova University

Summary Data representation Programming and programming languages An introduction to Java CSC 1051 M.A. Papalaskari, Villanova University

Homework Review Chapter 1 –Always do all self-review exercises when you review material Do Exercises EX and Read Section 2.1 to prepare for next class CSC 1051 M.A. Papalaskari, Villanova University