Algorithms & FlowchartsLecture 10. Algorithm’s CONCEPT.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
1 CS101 Introduction to Computing Lecture 17 Algorithms II.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
Lecture 14 Go over midterm results Algorithms Efficiency More on prime numbers.
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 The Origins of “Algorithm”
Chapter 2: Algorithm Discovery and Design
CSE 830: Design and Theory of Algorithms
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
Chapter 2: Algorithm Discovery and Design
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
CHAPTER 10 Recursion. 2 Recursive Thinking Recursion is a programming technique in which a method can call itself to solve a problem A recursive definition.
Chapter 2: Algorithm Discovery and Design
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
HOW TO SOLVE IT? Algorithms. An Algorithm An algorithm is any well-defined (computational) procedure that takes some value, or set of values, as input.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
1 CS101 Introduction to Computing Lecture 16 Algorithms I.
Invitation to Computer Science, Java Version, Second Edition.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
Recursion l Powerful Tool l Useful in simplifying a problem (hides details of a problem) l The ability of a function to call itself l A recursive call.
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
ALGORITHM CHAPTER 8. Chapter Outlines and Objectives  Define an algorithm and relate it to problem solving.  Define three construct and describe their.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Design & Analysis of Algorithms Lecture 1 Introduction.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2008 Algorithm analysis, searching and sorting  best vs. average vs. worst case analysis  big-Oh.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
Definition of Terms Software/Programs Programs that directs the operation of a computer system Set of instructions Codes Programming Process of planning,
Procedural Programming. Programming Process 1.Understand the problem 2.Outline a general solution 3.Decompose the general solution into manageable component.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Algorithm Design.
1 Section 2.1 Algorithms. 2 Algorithm A finite set of precise instructions for performing a computation or for solving a problem.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Chapter 8 Algorithms.
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
Chapter 10 Algorithmic Thinking. Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the.
Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2012 Sanghyun Park.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 CONCEPTCONCEPT 8.1.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
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.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Ch03-Algorithms 1. Algorithms What is an algorithm? An algorithm is a finite set of precise instructions for performing a computation or for solving a.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
CMSC 104, L041 Algorithms, Part 1 of 3 Topics Definition of an Algorithm Example: The Euclidean Algorithm Syntax versus Semantics Reading Sections 3.1.
Creativity of Algorithms & Simple JavaScript Commands
Algorithms, Part 1 of 3 The First step in the programming process
Programming & Scratch.
INTRODUCTION TO PROBLEM SOLVING
Data Structures and Algorithms
GC211Data Structure Lecture2 Sara Alhajjam.
Lecture 2 Introduction to Programming
Algorithm Analysis CSE 2011 Winter September 2018.
Algorithm and Ambiguity
Algorithms Chapter 3 With Question/Answer Animations
IF if (condition) { Process… }
Algorithm and Ambiguity
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.
Lecture 7 Algorithm Design & Implementation. All problems can be solved by employing any one of the following building blocks or their combinations 1.
Teori Bahasa dan Automata Lecture 13: Algorithm
Presentation transcript:

Algorithms & FlowchartsLecture 10

Algorithm’s CONCEPT

Solving Problems When faced with a problem: 1.We first clearly define the problem 2.Think of possible solutions 3.Select the one that we think is the best under the prevailing circumstances 4.And then apply that solution 5.If the solution works as desired, fine; else we go back to step 2

al.go.rithm Sequence of steps that can be taken to solve a given problem

Algorithm (Better Definition) 1 st Definition: Sequence of steps that can be taken to solve a problem Better Definition: A precise sequence of a limited number of unambiguous, executable steps that terminates in the form of a solution

Examples Addition Conversion from decimal to binary The process of boiling an egg The process of mailing a letter Sorting Searching

Informal definition of an algorithm used in a computer

Finding the largest integer among five integers

Defining actions in FindLargest algorithm

FindLargest refined

Generalization of FindLargest

THREE BUILDING BLOCKS

Sequences A sequence of instructions that are executed in the precise order they are written in: statement block 1 statement block 2 statement block 3 statement block 1 statement block 2 statement block 3

Decisions Select between alternate courses of action depending upon the evaluation of a condition If ( condition = true ) statement block 1 Else statement block 2 End if statement block 1 condition TrueFalse statement block 2

Repetitions/Loops Loop through a set of statements as long as a condition is true Loop while ( condition = true ) statement block End Loop condition True False statement block

Three building blocks

Algorithm TYPES

Greedy Algorithm An algorithm that always takes the best immediate, or local solution while finding an answer Greedy algorithms may find the overall or globally optimal solution for some optimization problems, but may find less-than-optimal solutions for some instances of other problems KEY ADVANTAGE: Greedy algorithms are usually faster, since they don't consider the details of possible alternatives

Deterministic Algorithm An algorithm whose behavior can be completely predicted from the inputs That is, each time a certain set of input is presented, the algorithm gives the same results as any other time the set of input is presented

Randomized Algorithm Any algorithm whose behavior is not only determined by the input, but also values produced by a random number generator These algorithms are often simpler and more efficient than deterministic algorithms for the same problem Simpler algorithms have the advantages of being easier to analyze and implement

Syntax & Semantics An algo. is “correct” if its: –Semantics are correct –Syntax is correct Semantics: The concept embedded in an algorithm (the soul!) Syntax: The actual representation of an algorithm (the body!) WARNINGS: 1. An algo. can be syntactically correct, yet semantically incorrect – very dangerous situation! 2. Syntactic correctness is easier to check as compared with semantic