アルゴリズムの設計と解析 教授: 黄 潤和 (W4022) SA: 広野 史明 (A4/A10)

Slides:



Advertisements
Similar presentations
MATH 224 – Discrete Mathematics
Advertisements

5/15/2015COT COT 5407: Introduction to Algorithms Tao Li ECS 318; Phone: x6036
CSC401 – Analysis of Algorithms Lecture Notes 1 Introduction
The Design & Analysis of the algorithms Lecture by me M. Sakalli.
Introduction to Analysis of Algorithms
Analysis of Algorithms1 Estimate the running time Estimate the memory space required. Time and space depend on the input size.
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
The Design and Analysis of Algorithms
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Design and Analysis of Algorithms - Chapter 11 Algorithm An algorithm is a.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
Algorithm Design and Analysis Liao Minghong School of Computer Science and Technology of HIT July, 2003.
Analysis of Algorithm Lecture 1
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
CSCE350: Data Structures and Algorithms Instructor: Dr. Jianjun Hu Fall Department of Computer Science and Engineering.
Algorithm Input Output An algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Chapter 4. Algorithm Analysis (complexity)
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Copyright © 2007 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction.
Design and Analysis of Algorithms - Chapter 11 Algorithm b An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining.
Algorithms 1.Notion of an algorithm 2.Properties of an algorithm 3.The GCD algorithm 4.Correctness of the GCD algorithm 5.Termination of the GCD algorithm.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3 rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 1. Complexity Bounds.
Copyright © 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin “ Introduction to the Design & Analysis of Algorithms, ” 2 nd ed., Ch. 1 Chapter.
DATA STRUCTURES (CS212D) Overview & Review Instructor Information 2  Instructor Information:  Dr. Radwa El Shawi  Room: 
Algorithms Design and Analysis CS Course description / Algorithms Design and Analysis Course name and Number: Algorithms designs and analysis –
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Algorithm Analysis 1.
Algorithms.
Design and Analysis of Algorithms
Advanced Algorithms Analysis and Design
TK3043 Analysis and Design of Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
The Design and Analysis of Algorithms
Analysis of Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
Introduction to the Design and Analysis of Algorithms
Introduction to The Design & Analysis of Algorithms
Analysis of algorithms
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
Divide-and-Conquer The most-well known algorithm design strategy:
Courtsey & Copyright: DESIGN AND ANALYSIS OF ALGORITHMS Courtsey & Copyright:
CS 583 Fall 2006 Analysis of Algorithms
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
Data Structures (CS212D) Overview & Review.
Definition In simple terms, an algorithm is a series of instructions to solve a problem (complete a task) We focus on Deterministic Algorithms Under the.
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
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
Decrease-and-Conquer
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Divide-and-Conquer The most-well known algorithm design strategy:
Data Structures (CS212D) Overview & Review.
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
CSE 2010: Algorithms and Data Structures Algorithms
CSC 380: Design and Analysis of Algorithms
Analysis of Algorithms
Analysis of algorithms
CSC 380: Design and Analysis of Algorithms
Introduction to Algorithms
CSC 380: Design and Analysis of Algorithms
Design and Analysis of Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Advanced Analysis of Algorithms
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
Presentation transcript:

アルゴリズムの設計と解析 教授: 黄 潤和 (W4022) SA: 広野 史明 (A4/A10) rhuang@hosei.ac.jp fumiaki.hirono.5k@stu.hosei.ac.jp

Goal 到達目標:  The objectives of this course are to make students firmly laying good foundation of data structures and algorithms, and one-step further comprehensively understanding algorithm analysis and having design and implementation skills in Python, Java, or other programming language.

Contents (L1 - Introduction) What is an Algorithm? How to design? How to analyze?

Why study algorithms? Algorithms play the central role both in the science practice From a practical standpoint - you have to know a standard set of important algorithms - you should be able to design new algorithms From theoretical standard - the study of algorithms is the core of computer science related to many other fields useful in developing analytical skills Of computing

Introduction What is an Algorithm? ambiguous あいまいな An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time. 合理的な A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. The algorithm is independent from any programming languages.

Two main approaches from typical problem types from algorithm design techniques

1. from typical problem types (a number of algorithms to a problem type)

Algorithm Features

Difference between Algorithm and Pseudocode An algorithm is a formal definition with some specific characteristics that describes a process, which could be executed by a Turing-complete computer machine to perform a specific task. Generally, the word "algorithm" can be used to describe any high level task in computer science. Pseudocode is an informal and (often rudimentary) human readable description of an algorithm leaving many granular details of it. Writing a pseudocode has no restriction of styles and its only objective is to describe the high level steps of algorithm in a much realistic manner in natural language.

Some Well-known Computational Problems Sorting Searching (e.g. BFS, DFS, Red-black tree, 2-3-4 tree) Shortest paths in a graph (e.g. Dijkstra’s algorithm) Minimum spanning tree (e.g. Prim’s algorithm, Kruskal’s algorithm ) Traveling salesman problem (TSP tour approximation) Knapsack problem (Dynamic programming algorithm ) Chess Primality testing Towers of Hanoi Program termination

e.g. Sorting problem There are many different algorithms

e.g. Greatest common factor 最大公約数 Problem: Find gcd(m,n), the greatest common divisor of two nonnegative, not both zero integers m and n e.g.: gcd(60,24) = 12, gcd(60,0) = 60, … (1) Euclid’s algorithm: it is based on repeated application of equality gcd(m,n) = gcd(n, m mod n) until the second number becomes 0, which makes the problem trivial. e.g.: gcd(60,24) = gcd(24,12) = gcd(12,0) = 12

Other methods (to the same problem: Greatest common factor) (2) Brute force solution Step 1 Assign the value of min{m,n} to t Step 2 Divide m by t. If the remainder is 0, go to Step 3; otherwise, go to Step 4 Step 3 Divide n by t. If the remainder is 0, return t and stop; otherwise, go to Step 4 Step 4 Decrease t by 1 and go to Step 2 (3) Finding the prime factors Step 1 Find the prime factorization of m Step 2 Find the prime factorization of n Step 3 Find all the common prime factors Step 4 Compute the product of all the common prime factors and return it as gcd(m,n)

2. from algorithm design techniques Some well-known algorithm design techniques Divide and conquer Decrease and conquer Transform and conquer Brute force Greedy approach Dynamic programming Backtracking and branch-and-bound Space and time tradeoffs

A design technique to solve different problems e. g. Divide and Conquer technique (分割統治) which is used in many different algorithms for solving different problems. For example Searching Sorting Matrix multiplication ……

Which is better? Two main issues: (1) How to design algorithms? (solve the problem) (2) How to analyze algorithms? (evaluate/optimize the algorithms)

Algorithm design techniques Brute force Divide and conquer Decrease and conquer Transform and conquer Space and time tradeoffs Greedy approach Dynamic programming Iterative improvement Backtracking Branch and bound ……

Analysis of algorithms How good is the algorithm? correctness time efficiency space efficiency Does there exist a better algorithm? lower bounds optimality

For example: sorting Rearrange the items of a given list in ascending order. Input: A sequence of n numbers <a1, a2, …, an> Output: A reordering <a´1, a´2, …, a´n> of the input sequence such that a´1≤ a´2 ≤ … ≤ a´n. Why sorting? Help searching Algorithms often use sorting as a key subroutine. Sorting key A specially chosen piece of information used to guide sorting. E.g., sort student records by student ID.

Analysis of Algorithms An example: Approach Pseudo code  Analysis of Algorithms

Analysis of Algorithms the best case occurs if the array is already sorted, t j =1 the best-case running time is (n) Analysis of Algorithms

Analysis of Algorithms A worst-case running time of (n2) O(n2) bound on worst-case running time of insertion sort Analysis of Algorithms

Running Time Most algorithms transform input objects into output objects. The running time of an algorithm typically grows with the input size. Average case time is often difficult to determine. We focus on the worst case running time. Easier to analyze Crucial to applications such as games, finance and robotics Wednesday, November 14, 2018Wednesday, November 14, 2018 Analysis of Algorithm

Experimental Studies Write a program implementing the algorithm Run the program with inputs of varying size and composition Use a method in Java like System.currentTimeMillis() or to get an accurate measure of the actual running time Plot the results

Comparison of different algorithms

Big-Oh Notation To simplify the running time estimation, for a function f(n), we ignore the constants and lower order terms. Example: 10n3+4n2-4n+5 is O(n3). Analysis of Algorithm Wednesday, November 14, 2018

Big-Oh Notation To simplify the running time estimation, for a function f(n), we ignore the constants and lower order terms. Example: 10n3+4n2-4n+5 is O(n3). Analysis of Algorithm Wednesday, November 14, 2018

Function of Growth rate

Some approximate of several functions important for analysis of algorithms

Efficiency is very much depended on data structure Apart from the linked list, there are other often used data structure.

About this course Textbook Anany Levitin, Addison-Wesley, 2011 Reference book Thomas H. Cor-men, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, MIT Press, 2009 Anany Levitin, Addison-Wesley, 2011

About this course Teaching plan It is expected to have slight adjustments Evaluation - Mid-term: exercise problems (20%) - Exams: final exam (80%)

Exercise 1-1 What is the output of Test1(200) ? Test1(200)の出力結果は何ですか? Algorithm Test1(n) b  0 for i  1 to n do if i mod 6 = 0 then b  b + 1 else if i mod 9 = 0 then b  b +10 return b

Exercise 1-2 What are the output of Test2(100)? Test2(100)の出力結果は何ですか? Test2は次のアルゴリズムです。 Algorithm Test2(n) b  0 for i  1 to n do for j  1 to i do b  b +1 return b

Exercise 1-3 What are the output of Test3(1000) ? Test3(1000 )の出力結果は何ですか? Test3は次のアルゴリズムです。 Algorithm Test3(n) i  1 b  0 while i < n do b  b + 1 i  2i return b