Chapter 5 Algorithms Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information Technology.

Slides:



Advertisements
Similar presentations
Algorithms An algorithm is a finite sequence of instructions, logic, an explicit step-by-step procedure for solving a problem. Specific algorithms sometimes.
Advertisements

CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Chapter 2- Visual Basic Schneider
Chapter 2: Algorithm Discovery and Design
Chapter 2 The Algorithmic Foundations of Computer Science
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Chapter 2: Algorithm Discovery and Design
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Review Algorithm Analysis Problem Solving Space Complexity
Chapter 1 Pseudocode & Flowcharts
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
Introduction to Computer Systems
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
Copyright © 2015 Pearson Education, Inc. Chapter 5: Algorithms.
CIS Computer Programming Logic
CSC141 Introduction to Computer Programming
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science 6th Edition
Invitation to Computer Science, Java Version, Second Edition.
Chapter 5 Algorithms © 2007 Pearson Addison-Wesley. All rights reserved.
“The study of algorithms is the cornerstone of computer science.” Algorithms Fall 2011.
Software Life Cycle What Requirements Gathering, Problem definition
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
ALGORITHM CHAPTER 8. Chapter Outlines and Objectives  Define an algorithm and relate it to problem solving.  Define three construct and describe their.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Chapter 5: 演算法 Algorithms 陳以德助理教授 : 高醫大舊二棟 轉 2586
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Chapter 5 Algorithms © 2007 Pearson Addison-Wesley. All rights reserved.
Computer Science: An Overview Eleventh Edition
Structured Programming (4 Credits)
Data Manipulation, part two Introduction to computer, 2 nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information.
17 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Invitation to Computer Science 5 th Edition Chapter 2 The Algorithmic Foundations of Computer Science.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
 Problem Analysis  Coding  Debugging  Testing.
Program design Program Design Process has 2 phases:
Programming Languages
Unit 3: ALGORITHMS AND FLOWCHARTS
Computer Programming.
Computer Science: An Overview Eleventh Edition
Chapter 2- Visual Basic Schneider
ALGORITHMS AND FLOWCHARTS
Introduction to Computer Programming
Programming Fundamentals
Unit# 9: Computer Program Development
Chapter 5: Algorithms Computer Science: An Overview Tenth Edition
Chapter 2- Visual Basic Schneider
Algorithm Discovery and Design
Introduction to Algorithms and Programming
A programming language
ICT Gaming Lesson 2.
Computer Science: An Overview Tenth Edition
Presentation transcript:

Chapter 5 Algorithms Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information Technology Islamic University of Gaza

Introduction  We have seen that before a computer can perform a task, it must be given an algorithm telling it what to do.  Algorithm: set of ordered steps that define how a task is performed.  Algorithm: an ordered set of executable steps that defines a terminating process  We have seen some examples of algorithms such as converting numeric representation, as well as algorithm for the machine cycle that is followed by the CPU.

Introduction Machine cycle: ◦ As long as the halt instruction not executed ◦ Continue to execute the following steps: a)Fetch an instruction b)Decode the instruction c)Execute the instruction

Introduction As mentioned in the definition, the steps required to be ordered, that means the steps must have a well-established structure in terms of the order of their execution.

The abstract nature of algorithm  It is important to differentiate between the algorithm and its representation.  It is similar to different between story and book.  Story is abstract, book is a physical representation of a story, is a book is translated in another language or different format, it still the representation of the story.  A single algorithm can be represented in many ways.

Process, algorithm, and program Program is a presentation of an algorithm Process is activity of executing a program “algorithm”.

Algorithm representation  The goal of this section is to introduce the basic of primitives and Pseudocode  Primitives:  The representation of an algorithm requires some form of language, human language (English, Arabic), or picture language.  Such natural channels of communications “natural language” leads to misunderstandings (communication problems).

Algorithm representation Computer science approaches this problem by establishing a well-defined set of building blocks from which algorithm representation can be constructed, such building block is called a primitive. A collection of primitives a long with a collection of rules stating how the primitives can be combined constitutes a programming language. Each primitive has its own syntax and semantic. Syntax: primitive's symbolic representation Semantic: meaning of the primitive

Pseudocode Notational system in which ideas can be expressed informally during the algorithm development process. Pseudocode is a kind of structured English for describing algorithms. Pseudocode generally does not actually obey the syntax rules of any particular language.

Pseudocode  Example: saving of a computed value.  If we have computed the sum of two value, and we want to save the result.  General syntax: Name expression  We read it as assign name the value of the expression (assignment statement) ResultA+B Grademid+final So that the grade can be used on future to refer to that sum.

Pseudocode  Another recurring semantic structure is:  If (condition) then (activity) else (activity)  Selection one of two possible activites. If (sales have decreased) then (lower the price by 5%) If (not raining ) then (if (temperature = hot) then ( go swimming) else (play golf) ) else (watch TV)

Pseudocode Another recurring semantic structure repeated execution of a statement: While (condition) do (activity) ◦ While (tickets remain to be sold) do (sell a ticket) X  3; while (X < 5) do (X  X + 1)

Pseudocode, procedure  We want to use out Pseudocode to describe activities that can be used as abstract tools in other applications  Computer science has a variety of terms for such programs units, including sub- program, procedure, model, and functions.  We will use the term procedure  Syntax: Procedure name

Figure 5.4 The procedure Greetings in pseudocode 5- 14

Iterative Structures Pretest loop: while (condition) do (loop body) Posttest loop: repeat (loop body) until(condition) 5- 15

Figure 5.7 Components of repetitive control 5- 16

Recursion The execution of a procedure leads to another execution of the procedure. Multiple activations of the procedure are formed, all but one of which are waiting for other activations to complete

Flow chart A flowchart is a common type of diagram, that represents an algorithm or process. A flow chart is a graphical or symbolic representation of a process. Each step in the process is represented by a different symbol. The flow chart symbols are linked together with arrows showing the process flow direction.

Flowchart symbols

Construct Flowchart To construct an effective flowchart  Define the process boundaries with starting and ending points.  Complete the big picture before filling in the details.  Clearly define each step in the process

Example 1 Draw a flowchart to find the sum of first 50 natural numbers

Example 2 Draw a flowchart to find the largest of three numbers A, B, and C. NO YES Start Read A, B,C IS A>B? IS B>C? IS A>C? Print A Print B Print C YESNO YES NO END