ALGORITHMS part-1.

Slides:



Advertisements
Similar presentations
Algorithm Development & Introduction to Programming Language
Advertisements

UNIT 2. Introduction to Computer Programming
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
 Recap – Python Basics. Python  Python is an interpreter which reads and executes a python script.  A python script is a text file, which contains.
ITEC113 Algorithms and Programming Techniques
Lecture 14 Go over midterm results Algorithms Efficiency More on prime numbers.
The Program Design Phases
Review Algorithm Analysis Problem Solving Space Complexity
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Algorithm & Flowchart.
The Fundamentals: Algorithms, the Integers & Matrices.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
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.
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.
CIS Computer Programming Logic
Programming.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Fundamentals of Algorithms MCS - 2 Lecture # 1
Prepared By Ms.R.K.Dharme Head Computer Department.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
What does a computer program look like: a general overview.
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.
Algorithms & Flowchart
ITEC113 Algorithms and Programming Techniques
Algorithm Design.
Advanced Program Design. Review  Step 1: Problem analysis and specification –Specification description of the problem’s inputs and output –Analysis generalize.
Algorithms Writing instructions in the order they should execute.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
 Definition Definition  Algorithmic Representation of Computer Functions Algorithmic Representation of Computer Functions  Algorithm Description Algorithm.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Flowcharts C++ Lab. Algorithm An informal definition of an algorithm is: a step-by-step method for solving a problem or doing a task. Input data A step-by-step.
ALGORITHMS 1. INTRODUCTION. Definition  An algorithm is a finite sequence of step by step, discrete, unambiguous instructions for solving a particular.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
5. Algorithm 1: Variables, Operators, Sequences 1.
Program design Program Design Process has 2 phases:
Topic: Introduction to Computing Science and Programming + Algorithm
Topics Designing a Program Input, Processing, and Output
INTRODUCTION TO PROBLEM SOLVING
Introduction to Algorithms
1-1 Logic and Syntax A computer program is a solution to a problem.
GC211Data Structure Lecture2 Sara Alhajjam.
ALGORITHMS AND FLOWCHARTS
Lecture 3 of Computer Science II
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
3.1 Algorithms (and real programming examples).
ALGORITHM Basic CONCEPTS of Basic Concepts of Algorithm
Introduction to Variables, Algebraic Expressions, and Equations
Introduction to Flowcharting
Introduction to Computer Programming
Introduction to MATLAB
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Programming Funamental slides
ALGORITHMS AND FLOWCHARTS
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Introduction to Algorithms and Programming
Faculty of Computer Science & Information System
Computer Science Core Concepts
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Topics Designing a Program Input, Processing, and Output
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Topics Designing a Program Input, Processing, and Output
Basic Concepts of Algorithm
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Programming Logic and Design Eighth Edition
Presentation transcript:

ALGORITHMS part-1

Definition An algorithm is a finite sequence of step by step, discrete, unambiguous instructions for solving a particular problem. has input data, and is expected to produce output data each instruction can be carried out in a finite amount of time in a deterministic way

Definition(cont..) In simple terms, an algorithm is a series of instructions to solve a problem (complete a task) Problems can be in any form Business Allocate manpower to maximize profit Life I am hungry. How do I order pizza?

Definition(cont..) We deal with data processing problems translated to programs that can be run on a computer Since we can only input, store, process & output data on a computer, the instructions in our algorithms will be limited to these functions

Algorithmic Representation of Computer Functions Input Get information Get (input command) Storage Store information Given/Result Intermediates/Set Process Arithmetic Let (assignment command) Repeat instructions Loop Branch conditionals If Output Give information Give (output command)

Algorithmic Representation of Computer Functions Understand the problem before solving it Identify & name each Input/Givens Identify & name each Output/Results Assign a name to our algorithm (Name) Combine the previous 3 pieces of information into a formal statement (Definition) Results := Name (Givens)

Method Once we have prepared the Algorithm Description, we need to solve the problem We develop a series of instructions (limited to those described previously) that, when executed, will compute the desired Results from the Givens (Method)

Assignment command Syntax X = 5Y + 16 On the left side of =, we put the name of a variable and on the right side we put a value or an expression. Each variable refers to a unique location in computer memory that contains a value. Interpretation An assignement is executed in two steps : 1- evaluation of the expression found on the right side. 2- setting the returned value in the memory cell corresponding to variable. Example Let SideSize=15 Let Area=SideSizeSideSize

Assignment in computer science and equality in mathematics The instruction A=A+3 is false in mathematics. In computer science Let A=A+3 means: the new value of A is equal to the old one plus three. d) The instruction A+5=3 is allowed in mathematics (it is an equation). Let A+5=3 has no meaning in computer science (the left side must be a variable).

Input command -Syntax Get variable The variable must be from Givens -Interpretation Here the user must give a value. The given value is assigned to the variable. -Example Get Size_Side

Output command -Syntax Give variable The variable must be from Results -Interpretation The value of the variable is displayed. -Example Give Area

Algorithm 1.1 Write an algorithm to find the sum of three given numbers NAME: SUM3 GIVENS: N1, N2, N3 RESULTS: Total DEFINITION: Total := SUM3(N1, N2, N3) ------------------------- METHOD: Get N1 Get N2 Get N3 Let Total = N1 + N2 + N3 Give Total

Algorithm 1.2 Write an algorithm to find the result of a division operation for the given two numbers X and Y NAME: Division GIVENS: X, Y RESULTS: Quotient DEFINITION: Quotient := Division(X, Y) ------------------------- METHOD: Get X Get Y Let Quotient = X/Y Give Quotient

Algorithm 1.3 Write an algorithm to find the sum and product of the two given numbers NAME: SumTimes GIVENS:Num1, Num2 RESULTS: Total, Product DEFINITION: Total & Product := SumTimes(Num1, Num2) ------------------------- METHOD: Get Num1 Get Num2 Let Total = Num1 + Num2 Let Product = Num1 * Num2 Give Total Give Produc

Flow Charts Can be created in MS Visio, word, ….etc Begin and End with an Oval Get/Give use a parallelogram Lets use a rectangle Flow is shown with arrows

Algorithm 1.1 NAME: SUM3 GIVENS: N1, N2, N3 RESULTS: Total DEFINITION: Total := SUM3(N1, N2, N3)

Algorithm 1.2 NAME: Division GIVENS: X, Y RESULTS: Quotient DEFINITION: Quotient := Division(X, Y)

Algorithm 1.3 NAME: SumTimes GIVENS:Num1, Num2 RESULTS: Total, Product DEFINITION: Total & Product := SumTimes(Num1, Num2)