Unit 171 Algorithms and Problem Solving  Introduction  Algorithm Design  Algorithm Properties  Algorithm Control Flow  Examples  Comparing Algorithms.

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

CS107 Introduction to Computer Science Lecture 2.
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
Control Flow Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Algorithms and Problem Solving
INTRODUCTION TO PROGRAMMING
 Control structures  Algorithm & flowchart  If statements  While statements.
CMPUT101 Introduction to Computing(c) Yngvi Bjornsson & Jia You1 Algorithm Discovery and Design Chapter 2 Topics: Representing Algorithms Algorithmic Problem.
What is an algorithm? Informally: An Algorithm is a step by step method for solving a problem. It’s purpose is to break a larger task down so that each.
Chapter 2: Algorithm Discovery and Design
Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
Chapter 2: Algorithm Discovery and Design
Chapter 2 The Algorithmic Foundations of Computer Science
1 Algorithms and Problem Solving. 2 Outline  Problem Solving  Problem Solving Strategy  Algorithms  Sequential Statements  Examples.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Chapter 2: Algorithm Discovery and Design
1 Design and Analysis of Algorithms تصميم وتحليل الخوارزميات (311 عال) Chapter 1 Introduction to Algorithms.
Adapted from slides by Marie desJardins
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Muhammad Adnan Talib Lec#4 27 th Sep,2012 Computer Science Department COMSATS Institute of Information Technology Sahiwal 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.
Branching and Conditions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Programming Lifecycle
The Software Development Life Cycle. Software Development SDLC The Software Development Life-Cycle Sometimes called the program development lifecycle.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
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.
ALGORITHM CHAPTER 8. Chapter Outlines and Objectives  Define an algorithm and relate it to problem solving.  Define three construct and describe their.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
CPSC 171 Introduction to Computer Science Algorithm Discovery and Design.
Chapter 2: General Problem Solving Concepts
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
The Hashemite University Computer Engineering Department
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 CONCEPTCONCEPT 8.1.
1 Introduction 1. Why Data Structures? 2. What AreData Structure? 3. Phases of Software Development 4. Precondition and Postcondition 5. Examples.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Algorithms JPC and JWD © 2002 McGraw-Hill, Inc. 2 Algorithms 2 An Algorithm is a finite set of precise instructions for performing a computation or for.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
1 The Role of Algorithms in Computing. 2 Computational problems A computational problem specifies an input-output relationship  What does the.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Program design Program Design Process has 2 phases:
ICS 3UI - Introduction to Computer Science
ALGORITHMS AND FLOWCHARTS
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Transition to Code Upsorn Praphamontripong CS 1110
Lecture 2 Introduction to Programming
Programming Fundamentals
Lecture 2: Introduction to Algorithms
COMS W1004 Introduction to Computer Science and Programming in Java
Lecture 2: Logical Problems with Choices
Algorithm Discovery and Design
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Understanding Problems and how to Solve them by using Computers
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
ICT Gaming Lesson 2.
Basic Concepts of Algorithm
Presentation transcript:

Unit 171 Algorithms and Problem Solving  Introduction  Algorithm Design  Algorithm Properties  Algorithm Control Flow  Examples  Comparing Algorithms  Exercises

Unit 172 Introduction A major phase of Software Design Life Cycle (SDLC) is the design phase. This phase involves the design of algorithms. It also involves the design of data structures.

Unit 173 Algorithm Design Algorithms are the details of the methods in the classes being designed. The methods are designed and specified after discovering the classes and relationships among them. A method usually uses other methods.

Unit 174 Algorithm Properties What is an Algorithm? An algorithm is an ordered sequence of instructions that is guaranteed to solve a specific problem Properties of Algorithm An algorithm should have the following properties: –No ambiguity in any instruction –No ambiguity which instruction is executed next –Finite number of instructions –Execution must halt and produce a result

Unit 175 Algorithm Control Flow How to represent an algorithm? Mostly pseudocode is used, which is a special set of English language constructs that look like statements of programming languages Syntax is flexible but simple and readable The constructs are of three types: –Sequential –Selection –Iteration

Unit 176 Comparing Algorithms Many ways to write an algorithm Desired attributes –Correctness –Ease of understanding –Elegance –Efficiency How to compare algorithms?

Unit 177 Example 1 Develop an algorithm to convert a temperature from Fahrenheit to Celsius Algorithm –get temperature –result = 5 / 9*(temperature – 32) –return result

Unit 178 Example 2 Develop an algorithm to withdraw a given amount from the balance Algorithm –get amount –if amount > balance print “cannot exceed balance” –else balance = balance - amount

Unit 179 Example 3 Develop an algorithm to determine if a given number n is prime Algorithm –get n –If n<2 isprime = false –else isprime = true –x = 2 –while isprime and x < sqrt(n) if x divides n isprime = false else x = x + 1 –return isprime

Unit 1710 Exercises 1.Develop an algorithm to check if a given integer is a perfect square or not. 2.Develop an algorithm to find the average and the standard deviation of an array of grades. 3.Develop an algorithm to display all prime numbers from 2 to 100.