Algorithm –History Muhammad ibn Musa Al-Khwarizmi www -groups.dcs.st-andrews.ac.uk/~history/Mathematicians/Al- Khwarizmi.html Book on arithmetic:

Slides:



Advertisements
Similar presentations
Overview of Programming and Problem Solving ROBERT REAVES.
Advertisements

ITEC113 Algorithms and Programming Techniques
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
CSC141 Introduction to Computer Programming
Problem Solving Methods. CSCE 1062 Outline Problem Solving Methods Problem solving steps The analytical method The algorithmic method The software engineering.
CHAPTER 1 Overview of Programming and Problem Solving.
Introduction to Computers (L02) * Hardware * Software * Programming Languages * Three Phase of Program Development * Development and Design Steps * Algorithms.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Software Life Cycle What Requirements Gathering, Problem definition
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.
Design & Analysis of Algorithms Lecture 1 Introduction.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
ALGORITHM List of instructions for carrying out some process step by step. A sequence of instructions which has a clear meaning and can performed with.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
The Programming Process Define the problem* Make or buy software? Design the program * Code (write) the program Test (debug) the program Document the.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Recursive Algorithms &
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.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Data Structure Introduction Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2010.
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Problem, Problem Solving, Algorithm & Flow Charts –Part 1 Presented By Manesh T Course:101 CS 101CS Manesh T1.
1 Overview of Programming Principles of Computers.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Introduction to Computer Programming using Fortran 77.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Program Program is a collection of instructions that will perform some task.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
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
ALGORITHMS AND FLOWCHARTS
GC101 Introduction to computers and programs
Unit 3: ALGORITHMS AND FLOWCHARTS
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
Computer Programming.
GC211Data Structure Lecture2 Sara Alhajjam.
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
Topic:- ALGORITHM Incharge Faculty – Lokesh Sir.
Algorithms and Flowcharts
The Selection Structure
ALGORITHM Basic CONCEPTS of Basic Concepts of Algorithm
Introduction to Computer Programming
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Problem Solving Techniques
ALGORITHMS AND FLOWCHARTS
Program Design Introduction to Computer Programming By:
ALGORITHMS AND FLOWCHARTS
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Lecture 6 Architecture Algorithm Defin ition. Algorithm 1stDefinition: Sequence of steps that can be taken to solve a problem 2ndDefinition: The step.
Introduction to Programming
Understand the interaction between computer hardware and software
Basic Concepts of Algorithm
Presentation transcript:

Algorithm –History Muhammad ibn Musa Al-Khwarizmi www -groups.dcs.st-andrews.ac.uk/~history/Mathematicians/Al- Khwarizmi.html Book on arithmetic: Hindu numeration, decimal numbers, use of zero, method for finding square root Latin translation (c.1120 CE): “Algoritmi de numero Indorum” Book on algebra Hisab al-jabr w’al-muqabala

The Problem-solving Process Problem specification Algorithm Program Executable (solution) Analysis Design Implementation Compilation

Components of an Algorithm 1. Variables and values 2. Instructions a.Sequences b.Procedures c.Selections d.Repetitions 3. Also required: Documentation

Algorithm basics It is a step by step procedure to solve a given problem in/with finite number of steps, where every step is labeled with a step number and no 2 steps are same. The components of an algorithm comprises of simple English statements with mathematical expressions, that specify step by step procedure towards the problem solution

Algorithm basics Properties of an algorithm It should be definite- no ambiguity It should be finite- definite number of steps It should be complete- must work successfully for which it has been designed for. It should be efficient

Need for writing algorithm  Effective communication-understandability  Effective analysis-easy to write programs  Proper documentation- to identify logical errors  Easy and efficient coding  Program debugging-detect & fix errors  Program maintenance- maintenance of the software becomes easier

Algorithm -- Examples 1. Assembly instructions for a model 2. The rules of how to play a game 3. VCR instructions 4. Directions for driving from A to B

Algorithmic Notations Algorithms are identified by a algorithm name followed by the type of computation it performs Ex: Algorithm Area_of_Circle ( This algorithm computes the area of a circle given radius) Each step is identified by a number followed by a description of what it does Ex: Step 3:[write the area of the circle] print area Finally the algorithm is terminated by using a stop/end. Step 4: [Stop] finished Provide the necessary information as what the algorithm performs, along with the inputs and outputs

Algorithm Example #1: Algorithm Area_of_a Circle This algorithm computes the area of a circle given radius Step 1: [start] Step 2: [ input the value of radius] read radius Step 3: [ calculate the area of the circle] area= 22/7*r*r Step 4: [ output the calculated area] write area Step 5: [finished] stop

Algorithm Example #2: Algorithm Area_of_a_Rectangle This algorithm computes the area of a rectangle given length and breadth step 1: [start] Step 2: [ input the value of length and breadth] read length, breadth Step 3: [ calculate the area of the rectangle] area= length * breadth Step 4: [ output the calculated area] write area Step 5: [finished] stop

Exchange (Swap) the contents of 2 variables ab temp 13 2

Concept of Swapping “SWAP”- refers to exchange the values between 2 variables, if the 2 variables are taken as a & b with initial values a=2, b=3 then before swapping a=2,b=3, but after swapping a=3,b=2, indicating that the values are interchanged & this is achieved by using a temporary variable called “temp” to hold the value during the exchange process. Steps involved in the exchange process are 1. temp=a, 2. a=b, 3. b=temp. Copy the value of a to temp Copy the value of b to a Copy the value of temp to b

Algorithm Example # 3: Algorithm Swap This algorithm exchanges the values of a with b and vice versa step 1: [start] Step 2: [ input the value of a and b] read a, b Step 3: [ perform the exchange operation] temp=a, the value of a is put to temp, hence a is empty a=b, the value of b is put to a, thus b is empty b=temp, temp contains the value of a and is put to b Step 4: [ output the exchanged values of a and b] write a & b Step 5: [finished] stop

Algorithm Example # 4: Algorithm Area of Triangle This algorithm calculates the area of a triangle where 3 sides a, b,c, are given step 1: [start] Step 2: [ input the value of a,b, c] read a, b, c Step 3: [ calculate the value of S] s= (a+b+c)/2. Step 4: [ compute the area of the triangle] area=sx(s-a)x(s-b)x(s-c) Step 5: [ display the calculated area] write area Step 6: [finished] stop

Algorithm Example # 5: Algorithm Simple Interest This algorithm calculates the simple interest given principle, rate and time step 1: [start] Step 2: [ input the value of p,t, r] read p, t, r Step 3: [ calculate the value of Simple interest] S.I.= (p*t*r)/100. Step 4: [ display the calculated simple interest] write S.I. Step 5: [finished] stop

Decision making Decision making is an integral part of every one’s life, in contrast to the computer languages have ”language constructs”, by which decisions are made, 2-way decision making being the most general Example: given a number its type is determined depending upon it being greater or lesser than 0. For example in c programming language the construct if..else provides a 2 way decision making facility

Format of a if..else statement If (logical expression) { True block statements } Else { False block statements }

Algorithm Example # 6: Algorithm odd_Even This algorithm determines whether the given number is odd or even step 1: [start] Step 2: [ input the value of n] read n Step 3: [ determine whether the given number is odd or even] if(n/2=0) write n as even else write n as odd end if Step 4: [finished] stop

Algorithm Example # 7: Algorithm Pos Neg Zero This algorithm checks whether the given number is positive, negative or zero step 1: [start] Step 2: [ input the value of n] read n Step 3: [ determine whether the given number is positive, negative, zero] if(n>0) write n as positive go to step 4 else write n as negative go to step 4 endif write n as zero Step 4: [finished] stop

When a given problem is large it is always natural to divide it into smaller independent sub problems and then to solve these sub problems independently and to merge the results of all these sub problems together to get the final solution. A central program that “puts together”, the smaller sub programs are referred to as the main programs or main functions & this strategy is commonly referred to as the divide and conquer strategy. The subprograms are referred differently in the programming languages for example in PASCAL they are referred as PROCEDURES, in C as FUNCTIONS and in FORTRAN as SUBPROGRAMS etc.

From Algorithms to Programs Problem C Program Algorithm: A sequence of instructions describing how to do a task (or process)