1 The Role of Algorithms in Computing. 2 Computational problems A computational problem specifies an input-output relationship  What does the.

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University
I Advanced Algorithms Analysis. What is Algorithm?  A computer algorithm is a detailed step-by-step method for solving a problem by using a computer.
What is an Algorithm? (And how do we analyze one?)
Introduction to Analysis of Algorithms
Lecture 14 Go over midterm results Algorithms Efficiency More on prime numbers.
Unit 171 Algorithms and Problem Solving  Introduction  Algorithm Design  Algorithm Properties  Algorithm Control Flow  Examples  Comparing Algorithms.
1 Data Structures A program solves a problem. A program solves a problem. A solution consists of: A solution consists of:  a way to organize the data.
1. The Role of the Algorithms in Computer Hsu, Lih-Hsing
Concept of Basic Time Complexity Problem size (Input size) Time complexity analysis.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
1 Design and Analysis of Algorithms تصميم وتحليل الخوارزميات (311 عال) Chapter 1 Introduction to Algorithms.
BIT Presentation 4.  An algorithm is a method for solving a class of problems.  While computer scientists think a lot about algorithms, the term.
Asymptotic Growth Rates Themes –Analyzing the cost of programs –Ignoring constants and Big-Oh –Recurrence Relations & Sums –Divide and Conquer Examples.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
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.
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
Reynolds 2006 Complexity1 Complexity Analysis Algorithm: –A sequence of computations that operates on some set of inputs and produces a result in a finite.
CMPT 438 Algorithms. Why Study Algorithms? Necessary in any computer programming problem ▫Improve algorithm efficiency: run faster, process more data,
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 1: The Role of Algorithms in Computing (slides by N. Adlai A. DePano)
1. The Role of the Algorithms in Computer Algorithms – 1/2 Algorithm: Any well-defined computation procedure that takes some value, or set of values,
Complexity A decidable problem is computationally solvable. But what resources are needed to solve the problem? –How much time will it require? –How much.
Computer programming.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Introduction to Analysis of Algorithms COMP171 Fall 2005.
1Computer Sciences Department. Book: Introduction to Algorithms, by: Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Electronic:
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
Chapter 10 Algorithm Analysis.  Introduction  Generalizing Running Time  Doing a Timing Analysis  Big-Oh Notation  Analyzing Some Simple Programs.
CS 361 – Chapters 8-9 Sorting algorithms –Selection, insertion, bubble, “swap” –Merge, quick, stooge –Counting, bucket, radix How to select the n-th largest/smallest.
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Asymptotic Growth Rates  Themes  Analyzing the cost of programs  Ignoring constants and Big-Oh  Recurrence Relations & Sums  Divide and Conquer 
Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop.
ALGORITHMS.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 1. Complexity Bounds.
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 2: Getting Started.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Chapter 1. The Role of the Algorithms in Computer.
1 Ch. 2: Getting Started. 2 About this lecture Study a few simple algorithms for sorting – Insertion Sort – Selection Sort (Exercise) – Merge Sort Show.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Analysis of Algorithms: Methods and Examples CSE 2320 – Algorithms and Data Structures Alexandra Stefan Based on presentations by Vassilis Athitsos and.
Lecture 2 What is a computational problem? What is an instance of a problem? What is an algorithm? How to guarantee that an algorithm is correct? What.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Problem Solving.  Similar to Solving Math Word Problem  Read the Problem  Decide how to go about Solving the Problem  Solve the Problem  Test the.
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
1.  A step by step process to solve any problem is called algorithm.  Algorithm is a process which take some values as input and provide us output.
Design and Analysis of Algorithms Faculty Name : Ruhi Fatima Course Description This course provides techniques to prove.
Advanced Data Structures Lecture 1
CMPT 438 Algorithms.
Introduction to Algorithms
IGCSE 6 Cambridge Effectiveness of algorithms Computer Science
Introduction to Algorithms
Introduction Algorithms Order Analysis of Algorithm
Data Structures and Algorithms
Unit 1. Sorting and Divide and Conquer
Introduction to Algorithms
Algorithm Analysis CSE 2011 Winter September 2018.
Enough Mathematical Appetizers!
Introduction to Algorithms
Algorithm Analysis (not included in any exams!)
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Objective of This Course
Applied Discrete Mathematics Week 6: Computation
Asst. Dr.Surasak Mungsing
Universidad Nacional Bogota Depto. De Sistemas
Introduction to Algorithms
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Presentation transcript:

1 The Role of Algorithms in Computing

2 Computational problems A computational problem specifies an input-output relationship  What does the input look like?  What should the output be for each input? Example:  Input: an integer number n  Output: Is the number prime? Example:  Input: A list of names of people  Output: The same list sorted alphabetically Example:  Input: A picture in digital format  Output: An English description of what the picture shows

3 Algorithms A tool for solving a well-specified computational problem An algorithm is said to be correct if, for every input instance, it halts with the correct output An incorrect algorithm might:  not halt at all on some input, or  halt with an answer other than the desired one Algorithms must be:  Correct: For each input produce an appropriate output  Efficient: run as quickly as possible, and use as little memory as possible AlgorithmInput Output

4 Problems and Algorithms We need to solve a computational problem  “ Convert a weight in pounds to Kg ” An algorithm specifies how to solve it, e.g.:  1. Read weight-in-pounds  2. Calculate weight-in-Kg = weight-in-pounds *  3. Print weight-in-Kg A computer program is a computer-executable description of an algorithm

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

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

7 A Simple Algorithm INPUT: a sequence of n numbers,  T is an array of n elements  T[1], T[2], …, T[n] OUTPUT: the smallest number among them Performance of this algorithm is a function of n min = T[1] for i = 2 to n do { if T[i] < min min = T[i] } Output min

8 Describing Algorithms Algorithms can be implemented in any programming language Usually we use “ pseudo-code ” to describe algorithms Testing whether input n is prime: for j = 2 to n-1 { if mod(n, j) = 0 output “n is non prime” and halt } output “n is prime”

9 Algorithm Efficiency Consider two sort algorithms  Insertion sort takes c 1 n 2 to sort n items where c 1 is a constant that does not depends on n it takes time roughly proportional to n 2  Merge Sort takes c 2 n lg(n) to sort n items where c 2 is also a constant that does not depends on n lg(n) stands for log 2 (n) it takes time roughly proportional to n lg(n)  Insertion sort usually has a smaller constant factor than merge sort so that, c 1 < c 2  Merge sort is faster than insertion sort for large input sizes

10 Algorithm Efficiency Consider now:  A faster computer A running insertion sort against  A slower computer B running merge sort  Both must sort an array of one million numbers Suppose  Computer A execute one billion (10 9 ) instructions per second  Computer B execute ten million (10 7 ) instructions per second  So computer A is 100 times faster than computer B Assume that  c 1 = 2 and c 2 = 50

11 Algorithm Efficiency To sort one million numbers  Computer A takes 2. (10 6 ) 2 instructions 10 9 instructions/second = 2000 seconds  Computer B takes lg(10 6 ) instructions 10 7 instructions/second  100 seconds By using algorithm whose running time grows more slowly, Computer B runs 20 times faster than Computer A For ten million numbers  Insertion sort takes  2.3 days  Merge sort takes  20 minutes