Algorithm: 1. Introduction

Similar documents
CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

PROBLEM SOLVING AND PYTHON PROGRAMMING

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

Low-Level Languages. Computer Programs and Programming Languages

A Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<

Introduction. Computers, algorithms

Programming Languages

Programming Languages

Algorithms. algorithm: An algorithm must possess the following properties: Algorithm Analysis

Module 1: Introduction to Computers, Programs, and Java

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Chapter Twelve. Systems Design and Development

CSI32 Object-Oriented Programming

SME1013 PROGRAMMING FOR ENGINEERS

Programming Languages and Program Development

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show

Java and Software Design

History of Computing. Ahmed Sallam 11/28/2014 1

Unit II. (i) Computer Programming Languages

What is programming? What are computer languages and how have they evolved? What is the basic process of programming, including the tools involved?

Algorithm must complete after a finite number of instructions have been executed. Each step must be clearly defined, having only one interpretation.

0 Introduction: Computer systems and program development

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

Discovering Computers 2008

Command-line interface DOS Graphical User interface (GUI) -- Windows

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

G Programming Languages - Fall 2012

Discovering Computers Chapter 13 Programming Languages and Program Development

Assembly Language: Overview!

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development

Programming 1 - Honors

III. Check if the divisors add up to the number. Now we may consider each of these tasks separately, assuming the others will be taken care of

Little Man Computer (LMC)

Towards the Hardware"

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

Lecture 1: Preliminaries

Stating the obvious, people and computers do not speak the same language.

INTRODUCTION TO ALGORITHMS

Introduction. A. Bellaachia Page: 1

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.

UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS

CSC180: Lecture 2. Wael Aboulsaadat.

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #23 Loops: Precedence of Operators

Lesson #1. Computer Systems and Program Development. 1. Computer Systems and Program Development - Copyright Denis Hamelin - Ryerson University

1. Introduction to Programming

Lecture 1: Introduction to Java

Introduction Objectives: 1) differentiate between high-level, low-level, and machine language; 2) explain why it is necessary to translate a program

2.2 (a) Statement, subroutine, procedure, function, parameter, loop

Class List. Java Must Have. Class Goals. Class Goals. Schedule

Fundamentals of Programming Session 2

Software Lesson 1 Outline

CSC 121 Spring 2017 Howard Rosenthal

Chapter 6 Programming the LC-3

Python - Week 1. Mohammad Shokoohi-Yekta

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

Lecture Objectives. Structured Programming & an Introduction to Error. Review the basic good habits of programming

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

Computer Programming-I. Developed by: Strawberry

Outline. Program development cycle. Algorithms development and representation. Examples.

Introduction to Java Programming

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science

Topic 1: Programming concepts

A Quick Review of Chapter 1

BLM1011 Bilgisayar Bilimlerine Giriş I

Chapter 1 Introduction to Computers, Programs, and Java

Programming Languages and Program Development Life Cycle Fall Introduction to Information and Communication Technologies CSD 102

CS111: PROGRAMMING LANGUAGE1. Lecture 2: Algorithmic Problem Solving

Principles of computer programming. Profesor : doc. dr Marko Tanasković Assistent : doc. dr Marko Tanasković

Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

Principles of Programming Languages. Lecture Outline

UNIT 1 REFERENCE 1 PREPARED BY S.RAVINDRAKUMAR, LECT/ECE, CHETTINAD COLLEGE OF ENGG AND TECH, KARUR

Copyright 2005 Department of Computer & Information Science

Procedural Programming

Computer Organization and Assembly Language. Lab Session 3

Variable A variable is a value that can change during the execution of a program.

Procedural Programming

Course Syllabus [1/2]

Machine and Assembly Language Principles

Introduction to Scientific Computing

LECTURE 17. Expressions and Assignment

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Unit 2 : Computer and Operating System Structure

An Introduction to Python (TEJ3M & TEJ4M)

1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100?

Life Cycle of Source Program - Compiler Design

Chapter 8 Structuring System Logic Requirements

Computer Software: Introduction

ENGR 105: Introduction to Scientific Computing. Dr. Graham. E. Wabiszewski

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts

Harry H. Porter, 2006

Assembly Language: Overview

Algorithm Discovery and Design

what is an algorithm? analysis of algorithms classic algorithm example: search


Transcription:

Algorithm 1 Algorithm: a finite set of instructions that specify a sequence of operations to be carried out in order to solve a specific problem or class of problems. [Zwass] Properties of algorithms: Finiteness: Algorithm must complete after a finite number of instructions have been executed. Absence of Ambiguity: Each step must be clearly defined, having only one interpretation. Definition of Sequence: Each step must have a unique defined preceding and succeeding step. The first step (start step) and last step (halt step) must be clearly noted. Feasibility: Input: Output: All instructions must be able to be performed. Illegal operations (division by 0) are not allowed. 0 or more data values. 1 or more results.

3-Iteration Newton-Raphson Algorithm 2 Algorithm: Newton-Raphson (3 iteration version) 1. Input: a real number X. 2. If (X < 0) Then Output: X " cannot be negative." STOP. Endif 3. Set a variable, S, to 1.0. 4. Set a counter variable, I, to 3. 5. While (I > 0) Do a. Calculate the value (S + X / S) / 2.0. b. Set S to the value calculated in step 5a. c. Subtract 1 from I. Endwhile 6. Output: "The square root of " X " is about " S 7. STOP. Does this possess the properties of an algorithm listed on the previous slide?

The Programming Process 3 Development Process Problem-Solving Phase 1. Analysis & Specification 2. Design of a General Solution 3. Verification. Implementation Phase 1. Production of a Specific Solution 2. Test These are not really just a simple sequence of actions. Discovered errors will force a re-examination of the algorithm, or perhaps the underlying analysis or even the problem specification. Pólya's Four-Step Process Maintenance Phase 1. Use (Install, Execute) 2. Maintain (Modify) Maintenance often costs more than development and marketing together. Especially if the design is ill-considered or the testing is inadequate.

Pólya s Four-Step Process 4 There is no recipe for solving general problems. However these ideas are often useful: 1. Understand the problem a. Know the boundaries of the problem b. Know the constraints on the solution c. Know what actions are allowed 2. Devise a plan a. Organize thoughts to develop a detailed algorithm b. Use tools such as: outlining, flowcharting, and pseudocode. 3. Implement the plan a. Carry out the steps in the algorithm b. Translate the problem into a language understandable by the device to be used. 4. Test the plan a. Did the solution yield appropriate results? b. Can the solution be improved? George Pólya (1887-1985)

Understand the Problem What are the data? What is the required result? What is the starting point (initial conditions)? Is it at all possible to get the result from the data? 5 Useful approach: solve the problem by hand. What steps did you take? Can you write them down? Is the problem divided into major parts? Can they be identified? Have any problem assumptions been made? What are they? Is the solution general?

Devise a Plan Have you seen a similar problem before? 6 Do you know of a related problem with a useful solution? Can you use part of the related problem? Can the solution of the related problem be modified and used? Look at the data... repetitions hint at loops in the solution. Identify the patterns in the data. If you can't solve the problem, can you solve part of the problem?

Implement the Plan Check each step of the plan. 7 Have you considered all the special cases? Can you arrive at a reasonable result given... reasonable data? unreasonable data? Make certain your solution works for "boundary conditions". Empty data? Data set too large? Data sets that results in illegal operations (division by zero)?

Test the Plan Did you compute any intermediate results that were not used later? Can they be eliminated? 8 Can the result be derived differently? Can the solution be made simpler or more general? Can the solution method be used for other problems?

Language Levels 9 Machine Language: (very low-level language) - consists of strings of 0's and 1's (binary digits or bits); often expressed in base 16 (hexadecimal) for clarity - different for each machine (machine dependent) - all programs must be written in machine language (code) OR be translated into machine code before being executed Assembly Language: (low or intermediate level)... 8b 95 14 ff 03 95 1c ff 89 95 14 ff... - short abbreviations (mnemonics) are used for instructions; for the assembly code above, one might have:... mov edx, DWORD PTR _SumOfScores$[ebp] add edx, DWORD PTR _nextscore$[ebp] mov DWORD PTR _SumOfScores$[ebp], edx...

Language Levels 10 High Level Languages: - Logical and relatively English-like SumOfScores = SumOfScores + nextscore; - machine independent - must be translated before execution (compiled or interpreted) Some common high-level languages: COBOL Fortran Pascal Ada C C++ Java Common Business-Oriented Language Formula Translation designed for programming instruction intended for general DOD contractor use intended for system software development object-oriented extension of C language pure object-oriented design, portable but interpreted

Program Translation 11 source code object code high-level language instructions (C++) written by the programmer low-level machine instructions readable by the hardware Compilation source code compiler interpreter object code Linking Building object code linker executable Execution loading Input Data executable results