Design and Analysis of Algorithms Faculty Name : Ruhi Fatima Course Description This course provides techniques to prove.

Slides:



Advertisements
Similar presentations
Algorithms Analysis Lecture 6 Quicksort. Quick Sort Divide and Conquer.
Advertisements

A simple example finding the maximum of a set S of n numbers.
Comp 122, Spring 2004 Divide and Conquer (Merge Sort)
1 Divide & Conquer Algorithms. 2 Recursion Review A function that calls itself either directly or indirectly through another function Recursive solutions.
Divide-and-Conquer Recursive in structure –Divide the problem into several smaller sub-problems that are similar to the original but smaller in size –Conquer.
Chapter 2. Getting Started. Outline Familiarize you with the to think about the design and analysis of algorithms Familiarize you with the framework to.
A Basic Study on the Algorithm Analysis Chapter 2. Getting Started 한양대학교 정보보호 및 알고리즘 연구실 이재준 담당교수님 : 박희진 교수님 1.
ALGORITHMS Introduction. Definition Algorithm: Any well-defined computational procedure that takes some value or set of values as input and produces some.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 5.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Lecture 3 Nearest Neighbor Algorithms Shang-Hua Teng.
CS421 - Course Information Website Syllabus Schedule The Book:
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Lecture 2: Divide and Conquer I: Merge-Sort and Master Theorem Shang-Hua Teng.
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.
CS Main Questions Given that the computer is the Great Symbol Manipulator, there are three main questions in the field of computer science: What kinds.
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
Introduction CIS 606 Spring The sorting problem Input: A sequence of n numbers 〈 a 1, a 2, …, a n 〉. Output: A permutation (reordering) 〈 a’ 1,
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Introduction to Algorithm design and analysis
Design and Analysis of Algorithms
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.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Project 2 due … Project 2 due … Project 2 Project 2.
Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The main aim of this.
Introduction to Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The.
10/14/ Algorithms1 Algorithms - Ch2 - Sorting.
ECOE 456/556: Algorithms and Computational Complexity Lecture 1 Serdar Taşıran.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
1 Designing algorithms There are many ways to design an algorithm. Insertion sort uses an incremental approach: having sorted the sub-array A[1…j - 1],
File Organization and Processing Week 13 Divide and Conquer.
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)
Computer programming.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Getting Started Introduction to Algorithms Jeff Chastine.
1Computer Sciences Department. Book: Introduction to Algorithms, by: Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Electronic:
By: Lokman Chan Recursive Algorithm Recursion Definition: A function that is define in terms of itself. Goal: Reduce the solution to.
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
Divide-and-Conquer UNC Chapel HillZ. Guo. Divide-and-Conquer It’s a technique instead of an algorithm Recursive in structure – Divide the problem into.
Divide and Conquer. Recall Divide the problem into a number of sub-problems that are smaller instances of the same problem. Conquer the sub-problems by.
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 2: Getting Started.
Introduction to Complexity Analysis. Computer Science, Silpakorn University 2 Complexity of Algorithm algorithm คือ ขั้นตอนการคำนวณ ที่ถูกนิยามไว้อย่างชัดเจนโดยจะ.
Algorithms A well-defined computational procedure that takes some value as input and produces some value as output. (Also, a sequence of computational.
2IS80 Fundamentals of Informatics Fall 2015 Lecture 6: Sorting and Searching.
1 Ch. 2: Getting Started. 2 About this lecture Study a few simple algorithms for sorting – Insertion Sort – Selection Sort (Exercise) – Merge Sort Show.
1 Recursive algorithms Recursive solution: solve a smaller version of the problem and combine the smaller solutions. Example: to find the largest element.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
 Design and Analysis of Algorithms تصميم وتحليل الخوارزميات (311 عال) Chapter 2 Sorting (insertion Sort, Merge Sort)
Lecture # 6 1 Advance Analysis of Algorithms. Divide-and-Conquer Divide the problem into a number of subproblems Similar sub-problems of smaller size.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
1 The Role of Algorithms in Computing. 2 Computational problems A computational problem specifies an input-output relationship  What does the.
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
ECOE 456/556: Algorithms and Computational Complexity
Lecture 2 Algorithm Analysis
CMPT 438 Algorithms.
Advanced Algorithms Analysis and Design
Introduction to Algorithms
Unit 1. Sorting and Divide and Conquer
Introduction to Algorithms
Courtsey & Copyright: DESIGN AND ANALYSIS OF ALGORITHMS Courtsey & Copyright:
CS 583 Fall 2006 Analysis of Algorithms
Objective of This Course
Introduction to Algorithms
Divide-and-Conquer 7 2  9 4   2   4   7
Divide & Conquer Algorithms
Introduction To Algorithms
Divide-and-Conquer 7 2  9 4   2   4   7
Presentation transcript:

Design and Analysis of Algorithms Faculty Name : Ruhi Fatima Course Description This course provides techniques to prove the correctness and to analyze the running time of the basic algorithms for those classic problems in various domains; to apply the algorithms and design techniques to solve problems; and to analyze the complexities of various problems in different domains.

Introduction to Algorithm Topics Covered Study of Algorithms Algorithms as a technology Insertion sort Analyzing algorithm Designing algorithm Turing Machine

Donald E. Knuth stated “Computer Science is the study of algorithms” –Cornerstone of computer science. Programs will not exist without algorithms. Behind every successful programming project there is a good design. So if the underlying design is bad, then often no amount of fine-tuning is going to make a substantial difference Usually design of any algorithm is chosen from existing techniques that are discussed in data structure course and based upon the selection proper design steps are formed Help to develop the ability of analyzing and solving problems via computers To be sure that your design is the most suitable design for the underlying problem, you must develop the ability of analyzing the design you made. Why Study this Course?

Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm is thus a sequence of computational steps that transform the input into the output. We can also view an algorithm as a tool for solving a well-specified computational problem. The statement of the problem specifies in general terms the desired input/output relationship. The algorithm describes a specific computational procedure for achieving that input/output relationship. What is an Algorithm? “computer” problem algorithm inputoutput

This course introduces students to the analysis and design of computer algorithms. Upon completion of this course, students will be able to do the following: –Analyze the asymptotic performance of algorithms. –Demonstrate a familiarity with major algorithms and data structures. –Apply important algorithmic design paradigms and methods of analysis. –Synthesize efficient algorithms in common engineering design situations. In this course we will cover the following topics: Understand foundations of algorithms && design and analysis various variants algorithms Accuracy, Efficiency, Comparing efficiencies Make use of skills to understand mathematical notations in algorithms and their simple mathematical proofs Gain familiarity with a number of classical problems that occur frequently in real-world applications Course Objectives

Understanding the problem –Asking questions, doing few examples by hand, think about special cases, etc. Deciding on –Exact vs. approximate problem solving, Appropriate data structure Design an algorithm Proving correctness Analyzing an algorithm –Time efficiency : how fast the algorithm runs –Space efficiency: how much extra memory the algorithm needs. Any algorithm can be analyzed when we study it as a pure mathematical entity, and so ignore issues such as programming language, machine, and operating system. Coding an algorithm Fundamentals of Algorithmic Problem Solving What kinds of Problems are solved by Algorithms Practical applications of algorithms are ubiquitous and include the following examples: The Human Genome Project has made great progress toward the goals of identifying all the 100,000 genes in human DNA, determining the sequences of the 3 billion chemical base pairs that make up human DNA, storing this information in databases, and developing tools for data analysis. Each of these steps requires sophisticated algorithms.

The Internet enables people all around the world to quickly access and retrieve large amounts of information. With the aid of clever algorithms, sites on the Internet are able to manage and manipulate this large volume of data. Examples of problems that make essential use of algorithms include finding good routes on which the data will travel and using a search engine to quickly find pages on which particular information resides. There are two characteristics that are common to many interesting algorithmic problems: 1. They have many candidate solutions, so finding one that is “best,” can present quite a challenge. 2. They have practical applications. Like, finding the shortest path provides the easiest examples. Or a routing node on the Internet may need to find the shortest path through the network in order to route a message quickly. Cont…

Algorithm as technology Computers may be fast, but they are not infinitely fast. And memory may be inexpensive, but it is not free. Computing time is therefore a bounded resource, and so is space in memory. So, these resources should be used wisely, and algorithms that are efficient in terms of time or space will help. Efficiency : Different algorithms devised to solve the same problem often differ dramatically in their efficiency. These differences can be much more significant than differences due to hardware and software. Example: Consider two algorithms for sorting. The first, insertion sort, takes time roughly equal to c 1 n 2 to sort n items, where c 1 is a constant that does not depend on n. The second, merge sort, takes time roughly equal to c 2 n lg n, and c 2 is another constant that also does not depend on n. Consider faster computer (computer A) running insertion sort against a slower computer (computer B) running merge sort. They each must sort an array of 10 million numbers. Computer A takes Computer B takes

Insertion sort Algorithms Input: A sequence of n numbers. Output: A permutation (reordering) of the input sequence such that a 1 ’ ≤ a 2 ’ ≤ …. ≤ a n ’

Merge Sort The divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems that are smaller instances of the same problem. Conquer the subproblems by solving them recursively. If the subproblem sizes are small enough, however, just solve the subproblems in a straightforward manner. Combine the solutions to the subproblems into the solution for the original problem. The merge sort algorithm closely follows the divide-and-conquer paradigm. Divide: Divide the n-element sequence to be sorted into two subsequences of n=2 elements each. Conquer: Sort the two subsequences recursively using merge sort. Combine: Merge the two sorted subsequences to produce the sorted answer.

Cont… Analyzing divide-and-conquer algorithms When an algorithm contains a recursive call to itself, often its running time is described by a recurrence equation or recurrence, which describes the overall running time on a problem of size n in terms of the running time on smaller inputs. The mathematical tools can be used to solve the recurrence and provide bounds on the performance of the algorithm.

Cont… Analyzing divide-and-conquer algorithms : When an algorithm contains a recursive call to itself, often its running time is described by a recurrence equation or recurrence, which describes the overall running time on a problem of size n in terms of the running time on smaller inputs. The mathematical tools can be used to solve the recurrence and provide bounds on the performance of the algorithm. The recurrence is Where D(n ) time to divide the problem into subproblems and C(n ) time to combine the solutions to the subproblems into the solution to the original problem. The divide step just computes the middle of the subarray, which takes constant time. Thus, D(n )= Θ(1 ). Two subproblems are recursively solved, each of size n=2, which contributes 2T(n/2) to the running time. We have already noted that the MERGE procedure on an n-element subarray takes time Θ(n ), and so C(n )= Θ(n ).

Cont… Adding above functions to recurrence gives Master theorem, which can be used to show that T(n) is Θ (n lg n). With Merge sort Θ (n lg n) running time, outperforms insertion sort, whose running time is Θ (n 2 ), in the worst case. Let us rewrite recurrence as where the constant c represents the time required to solve problems of size 1 as well as the time per array element of the divide and combine steps. After recursively solving the above recurrence and ignoring the low-order term and the constant c gives the desired result of Θ (n lg n).

A TM consists of an infinite length tape, on which input is provided as a finite sequence of symbols. A head reads the input tape. The TM starts at start state s 0. On reading an input symbol it optionally replaces it with another symbol, changes its internal state and moves one cell to the right or left. Example: EG Successor Program Sample Rules: If read 1, write 0, go right, repeat. If read 0, write 1, HALT! If read , write 1, HALT! Let’s see how they are carried out on a piece of paper that contains the reverse binary representation of 47: Turing Machine

So the successor’s output on was which is the reverse binary representation of