Introduction Algorithms and Programming. Computer Programming  A form of problem solving  Or, more accurately, a way to solve problems  What we will.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
 Computer hardware components are the physical pieces of the computer.  The major hardware components of a computer are: – The central processing.
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
Programming Types of Testing.
Introduction to Computers and Java Module 1. Objectives overview computer hardware and software introduce program design and object-oriented programming.
COSC 120 Computer Programming
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Computers: Tools for an Information Age
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 1: Getting Started by George Lamperti & BU Faculty.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Getting Started with Java
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
CIS 115 Lecture 1.  Hardware: Electronic Devices  Software: Instructions and Computer Programs.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Lesson 1b: Computer Systems and Program Development CPS118.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
Introduction to Computer Systems and the Java Programming Language.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Introduction to Computers and Java Module 1. Objectives overview computer hardware and software introduce program design and object-oriented programming.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Software Engineering Algorithms, Compilers, & Lifecycle.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Chapter 1Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 1 l Background information »important regardless of programming.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Chapter 1 Introduction 2nd Semester H
CSCI-235 Micro-Computer Applications
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Introduction to Computers and Java
Chapter 1: An Overview of Computers and Programming Languages
Computers: Hardware and Software
Introduction CSC 111.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
ICS103 Programming in C 1: Overview of Computers And Programming
Presentation transcript:

Introduction Algorithms and Programming

Computer Programming  A form of problem solving  Or, more accurately, a way to solve problems  What we will be studying is “How to solve problems” using computers

What’s a Problem?  A question that someone wants an answer to  A problem usually has information that represents a starting point, initial assumptions, facts, or data that will be needed in answering the question  For example, “What is my grade point average?”

How Do We Solve the Problem?  With pencil and paper we can compute our grade point average if we know all of our grades and the units for each of the courses taken  What are the advantages of writing a computer program to compute our grade point average?

How Do We Solve Problems?  Four Steps 1. Understand the problem 2. Devise a plan to solve the problem 3. Implement the plan 4. Evaluate the solution From George Polya’s book, “How to Solve It” written in 1945.

What is an Algorithm?  A plan for solving a problem A series of steps to follow to arrive at a solution A highly technical and precise “recipe” for solving a problem A “good” algorithm is “correct”, “complete”, and “unambiguous” “Good” algorithms are also general rather than specific

Algorithm Definition  From mathworld.wolfram.com/Algorithm.html A specific set of instructions for carrying out a procedure or solving a problem, usually with the requirement that the procedure terminate at some point Specific algorithms sometimes also go by the name “method”, “procedure”, or “technique” The word “algorithm” is a distortion of al-Khwarizmi, a Persian Mathematician who wrote an influential treatise about algebraic methods

What Does an Algorithm Look Like?  It can be written in (precise) English  It can be drawn as a diagram (e.g., a flowchart) with steps and a path to follow from one step to the next  To make it precise (and computer executable) algorithms are translated into a computer understandable form (e.g., machine language)

A Simple Example  Problem: Calculate the average of a list of numbers. Let the number of numbers in the list be n Assume n is greater than or equal to 1 Calculate the sum of the n numbers Call this sum s Then the average is given by s/n

Example Expanded  Problem: Calculate the average of a list of numbers. Let the number of numbers in the list be n. Assume n is greater than or equal to 1. Pick off the first number on the list and place it on the blackboard. As long as there are more numbers on the list, pick the next number off the list and add it to the number on the blackboard and replace the number on the blackboard with this sum. (Repeat this step until the list is empty.) Call the number on the blackboard s. Then the average is given by s/n.

Final Note about Algorithms  To qualify as an algorithm, the instructions must be expressed so completely and precisely that somebody could follow the instructions without having to make any assumptions or ask for more information or help of any kind.

Computer Basics  Hardware and Memory  Programs  Programming Languages  Compilers

Hardware and Memory  The processor or CPU (Central Processing Unit) Executes instructions  Memory Main memory (RAM) Secondary (auxiliary) memory  Disk drives (hard drives)  Diskettes (floppies)  Compact disks (and DVDs)  USB Flash Drives

Bits, Bytes, and Memory Organization  A bit is a single binary digit (i.e., it can assume the value 0 or 1)  A byte is a string of 8 bits (enough to hold the representation of a character)  The number of a byte is called its “address” or “memory location”  When more than one byte is needed to store information the computer uses a string of adjacent bytes

Why Do Computers Use Just Zeros and Ones?  It’s easier to make a physical device that has only two physical states (e.g., “on” and “off”).  There is nothing special about zero and one. The only important thing is that the physical device have two stable states.

Programs  A program is simply a set of instructions for a computer to follow.  A computer “executes” the instructions in the program to process the “data” or information provided as input in order to produce the results or output desired.  It is actually the “operating system” (just another program) running on the computer that executes your program.

Programming Languages  High level languages (languages designed for people to use) Pascal, FORTRAN, C, C++, Visual Basic, Lisp, Java  Low level languages (languages that computers can understand) Machine languages, assembly languages

Compilers  Compilers are programs that translate high level languages into low level languages  Compilers are generally machine dependent because different machines have different machine languages  The input to the compiler is called the “source code” and the output is called the “object code”

Designing Programs – An Object-Oriented Approach  An Object is a software package that contains a collection of related procedures and data.  The procedures in an object-oriented approach are called methods.  One object interacts with another by sending it a message asking it to carry out one of its methods.

Designing Programs – An OO Approach Cont’d  A class is a template that defines the methods and variables to be included in a particular type of object.  The objects that belong to a class, called instances of the class, contain only their particular values for the variables.  Inheritance is a mechanism whereby one class of objects can be defined as a special case of a more general class, automatically including the method and variable definitions of the general class.

Designing Programs – An OO Approach Cont’d  A special case of a class is known as subclass of that class.  Encapsulation is a technique in which data is packaged together with its corresponding procedures in a way that the details of implementation are hidden.  Polymorphism is the ability to use one name for several different implementations of a method.

Testing and Debugging  A mistake in a program is called a bug.  The process of removing bugs from a program is called debugging.  There are three main classes of bugs or errors in programs: Syntax errors Runtime errors Logic errors

Syntax Errors  A syntax error is a grammatical mistake in a program.  There are strict grammatical rules for writing programs including required punctuation marks.  The compiler will catch syntax errors and give its best guess as to the problem, but is often wrong regarding the actual mistake made.

Run-Time Errors  Errors caught when the program is run.  The computer will give an error message, but such messages are often hard to understand.  You can be sure that there is an error in your program but it may take some time to find.

Logic Errors  If the program runs successfully to completion but produces the wrong result, you have a logic error.  What you have written is a valid program, but it doesn’t do what it is supposed to do.  These are the most difficult errors to find.

The History of Java  Java had its beginnings in an effort by James Gosling in 1991 at Sun Microsystems to develop a new language for programming home appliances.  That’s where the idea of translating programs into an intermediate language that was the same for all appliances (computers) came from (Java byte- code).

The History of Java Cont’d  In 1994 Gosling realized that his language would be ideal for developing a Web browser that could run programs over the Internet.  The original name of the language was “Oak” but they found that that name was already taken.  Rumor has it that the name resulted from a trip for coffee after a fruitless meeting to come up with a new name.

Two Types of Java Programs  Applications – regular programs meant to be run directly on peoples computers.  Applets – “little” applications meant to be sent to another location on the Internet and run there.

Sample Java Program public class Hello { public static void main(String [] args) { System.out.println("Hello, world!"); }

Solution to the Eight Queens Problem (one of twelve)