CS420/520 Algorithm Analysis Spring 2010 Lecture 01
|
|
- Loren Harrington
- 5 years ago
- Views:
Transcription
1 CS420/520 Algorithm Analysis Spring 2010 Lecture 01 I. Review the syllabus A. How to reach me this semester B. course description from catalog C. prerequisites 1. C++ 2. Java D. Computer Requirement 1. JDK 2. GNU C/C++ E. instructional objectives and relationship to exams this semester F. text and related resource texts G. Internet resources reserve holdings for this class H. homework assignments 1. reading 2. homework 3. programming a) languages b) style & documentation (1) RCS/CVS keyword substitution (2) C++ header located on WWW page (3) Javadoc template located on WWW page (4) Rsm cef H O rsm.html *.java (5) Javadoc *.java (6) Print in such a way that lines do not wrap c) test cases 4. grading policies I. Attendance J. Academic standards K. general schedule II. Chapter 1 The Role of Algorithms in Computing A. 1.1 Algorithms 1. informal algorithm definition - any well-defined computational procedure that takes from some value, or set of values, as input and produces some value, or set of values, as output. 2. view algorithm as a tool for solving a well-specified computational problem a) statement of the problem specifies in general terms the desired input/output relationship b) the algorithm describes a computational procedure for achieving that input/output relationship 3. what is an algorithm? a) a step-by-step procedure for solving a specific problem in a finite amount of time b) a finite set of rules which gives a sequence of operations for solving a specific type of problem [Knuth v1 pg 4] (1) finiteness - an algorithm must terminate after a finite number of steps Spring
2 (a) a procedure which lacks finiteness is a computational method (2) definiteness - each step of an algorithm must be precisely defined; the actions to be carried out must be rigorously and unambiguously specified for each case (a) an expression of a computational method in a computer language is called a program (3) input - an algorithm has zero or more inputs (quantities which are given initially before the algorithm begins) (4) output - an algorithm has one or more outputs (quantities which have a specified relation to the inputs) (5) effectiveness - all operations to be performed in the algorithm must be sufficiently basic that they can in principle be done exactly and in a finite length of time by a person using pencil and paper 4. DIFFERENCE BETWEEN AN ALGORITHM AND A COMPUTATIONAL PROCEDURE 5. sorting problem (defined page 5, CLRS text) a) the specific input sequence specified is an instance of the sorting problem b) an instance of a problem consists of all the inputs (satisfying any constraints imposed in the problem statement) needed to compute a solution to the problem 6. an algorithm is said to be correct if, for every input instance, it halts with the correct output. 7. Tonight we are considering only deterministic programs later lectures will address nondeterministic algorithms. 8. Bertrand Meyer, CHAPTER 9, AXIOMATIC SEMANTICS, Introduction to the Theory of Programming Languages. a) assertions (1) a property of the program's objects which may or may not be satisfied by a state of the program during execution (2) (will be expressed as Boolean expressions in concrete syntax for now) b) preconditions and postconditions (programming by contract) (1) preconditions (P) - assumed to be satisfied before the fragment is executed (a) (b) should be as broad as possible it is the responsibility of the environment to invoke the program or program fragment only for cases that fall within the precondition (2) postconditions (Q)- guaranteed to be satisfied after the fragment has been executed (3) a program or program fragment will be said to be correct with respect to a certain precondition P and a certain postcondition Q IFF when executed Spring
3 in a state in which P is satisfied it yields a state in which Q is satisfied (4) precondition obligates the environment, postcondition obligates the program (5) programming by contract (6) defined this way program correctness is only a relative concept...but programs must terminate c) definitions of total and partial correctness (1) definition (Total Correctness): A program fragment a is totally correct for P and Q IFF the following holds: whenever a is executed in any state in which P is satisfied, the execution terminates and the resulting state satisfies Q. (a) achieves the postcondition (b) and terminates (2) definition (Partial Correctness): A program fragment a is partially correct for P and Q IFF the following holds: whenever a is executed in any state in which P is satisfied and this execution terminates, the resulting state satisfies Q. (a) achieves the postcondition (b) if it terminates 9. What kinds of problems are solved by algorithms? a) Types of Problems (1) Decision Problem - decide whether the input satisfies property Y (2) Adaptive Problem - maintain property Y over time (3) Search Problem - find an X in the input that satisfies property Y (4) Structuring Problem - transform input to satisfy property Y (5) Construction Problem - build an X to satisfy property Y (6) Optimization Problem - find the best X that satisfies property Y b) problem categories (1) conceptually hard problems - don't have an algorithm to solve the problem because don't understand it well enough (2) analytically hard problems - have an algorithm but don't know how to analyze how long it will take to solve every problem instance (3) computationally hard problems - analyzed and analyzed it, but only small problems can be solved efficiently (a) know? (b) Suspect? (4) Computationally unsolvable - no efficient algorithm exists c) Examples in CLRS Spring
4 (1) Sorting (2) Biological problems, such as gene identification (3) Information retrieval (4) Privacy and security (5) Allocation of scarce resources (6) Shortest route from one point to one other point/all other points (7) Longest common string subsequence (8) Topological sorting (9) Convex hull d) Some general characteristics (1) Finding a solution we do want from among many candidate solutions (2) The problems solved in the text are often practical problems 10. Data structures a) A data structure is a way to store and organize data in order to facilitate access and modification 11. Why study computational complexity? a) analyzing computational methods helps us to focus on what must be determined and the most efficient way to determine it b) "A detailed consideration of computational complexity serves as a kind of "Occam's razor": the most efficient algorithms are generally those that compute exactly the information relevant to the problem situation. Thus the development of an especially efficient algorithm often gives us added insight into the problem we are considering, an the resulting algorithm is not only efficient but simple and elegant. Such algorithms are the kind we are after." [Tarjan] c) (showed up in the movie "Contact") d) William of Ockham (1284?-1347?) (1) believed the primary form of knowledge came from experience gained through the senses (2) based scientific knowledge on such experience and on self-evident truths (3) and on logical propositions resulting from these two sources (4) stressed the Aristotelian principle that "entities must not be multiplied beyond what is necessary" (5) What can be done with fewer assumptions is done in vain with more. (Occam's Razor sometime in the 1320s) (6) the simplest theory that fits the facts of a problem is the one that should be selected (7) he was persecuted in Pope John XXII's purge of spiritualists in the Franciscan order and other orders in 1324 e) The importance of hard problems (1) Family of NP-complete problems (a) It is unknown whether or not efficient Spring
5 algorithms exist for NP-complete problems (b) If an efficient algorithm for one is found, all others in the family have efficient algorithms (c) Problems in the family are similar to problems for which there are efficient algorithms (d) Importance of solutions by approximation techniques 12. two example problems a) Given a set of n distinct positive integers x 1, x 2,..., x n (where n is an even number) (1) partition the set into two subsets each of cardinality n/2 such that the difference between the sums of the two subsets is maximized (2) partition the set into two subsets such that the difference between the sums of the two subsets is minimized b) Which problem looks harder? B. 1.2 Algorithms as technology 1. algorithms, like computer hardware, are a technology 2. we need to consider algorithms that are space and time efficient 3. Efficiency a) Sorting algorithm examples (1) Insertion sort takes c 1 n 2 time to sort n items (2) Merge sort takes c 2 nlgn time to sort n items (3) There is some partition of the integers such that below that partition insertion sort is faster than merge sort, and above which merge sort is faster than insertion sort Spring
6 Run Time Sort Comparisons (c1=12, c2=100) Number of items sorted insertion sort merge sort III. b) a) algorithm efficiency is more important than computer speed when the size of the input becomes large 2. Algorithms and other technologies a) Total system performance depends on choosing efficient algorithms as much as on choosing fast hardware b) Importance of algorithms (1) Used in routing and network control (2) Used in design of hardware (computational devices as well as interface devices) (3) Problems to be solved are larger than ever before IV. Chapter 2 Getting Started A. 2.1 Insertion Sort 1. (SEE KNUTH VOL 3 page 382 ff for history of sorting and developments associated with these historical events) 2. Insertion Sort a) efficient for sorting a small number of elements (1) works much like sorting cards held in a hand of play (2) empty left hand (assumes you are right handed) and cards face down on the table (3) choose a card from the table and insert it in the correct position in the left hand (a) compare to each card already in the hand from right to left b) specification, page 16 Spring
7 (1) input (2) output c) pseudocode intro (1) employs whatever expressive method is most clear and conside to specify a given algorithm (2) pseudocode not typically concerned with issues of software engineering (a) data abstractions, (b) modularity, (c) error handling d) INSERTION-SORT pseudocode, page 18 (1) sorts in place: the numbers are rearranged within the input array A (2) BE AWARE THAT THIS TEXT USES ARRAYS WITH MIN INDEX = 1 (3) note that parameters are passed by value, except for arrays which are passed as pointers (Pascaltype code conventions) (4) note use of short-circuit evaluation on line 5 e) Loop invariants and the correctness of insertion sort (From Chapter 4 of Discrete Mathematics with Applications, Susanna S. Epp, 1990, Wadsworth) Spring
8 (1) [pre-condition for loop] while (G) [Statements in loop body. None contain branching statements that leap outside the loop] end while [post-condition for loop] (2) A loop is defined to be correct with respect to its pre-and post-conditions if, and only if, whenever the algorithm variables satisfy the precondition for the loop and the loop is executed, then the algorithm variables satisfy the postcondition for the loop. (3) G is the guard, which restricts entry to the loop (4) Loop Invariant Theorem (a) Let a while loop with guard G be given, together with pre- and post-conditions that are predicates in the algorithm variables. Also let a predicate I(n), called the loop invariant, be given. If the following four properties are true, then the loop is correct with respect to its pre- and post-conditions (i) Basis Property: The pre-condition for the loop implies that I(0) is true before the first iteration of the loop. (ii) Inductive Property: If the G and the loop invariant I(k) are both true for an integer k 0 before an iteration of the loop, then I(k + 1) is true after iteration of the loop. (iii) Eventual Falsity of Guard: After a finite number of iterations of the loop, the guard G becomes false. (iv) Correctness of the Post-Condition: If for some nonnegative integer N, G is false and I(N) is true, then the values of the algorithm variables will be specified in the post-condition of the loop f) Principle of Strong Mathematical Induction (Epps page 249) (1) Let P(n) be a predicate that is defined for integers n, and let a and b be fixed integers with a b. Suppose the following two statements are true: (a) (b) P(a), P(a+1), & P(b) are all true [BASIS STEP] For any integer k > b, if P(I) is true for all integers I with a I < k, then P(k) is true [INDUCTIVE STEP] (2) Then the statement (a) For all integers n a, P(n) is true (3) (The supposition the P(I) is true for all integers I Spring
9 with a I < k is called the inductive hypothesis) (4) g) At the beginning of each iteration of the outer for loop, which is indexed by j, the subarray of A[1 j-1] constitute the sorted hand and the elements A[j+1...n] correspond to the cards on the table. (1) Properties of A[1 j-1] as a loop invariant (a) At the start of each iteration of the for loop in lines 1-8, the subarray A[1 j-1] consists of the elements originally in A[1 j-1] but in sorted order (2) Must show three things (a) Initialization: it is true prior to the first iteration of the loop (b) Maintenance: if it is true before an iteration of the loop, it remains true before the next iteration (c) Termination: when the loop terminates, the invariant gives us a useful property that helps show the algorithm is correct (3) Walkthrough analysis page Pseudocode Conventions a) Note also return is allowed for functions (e.g., page 128) b) Parameters passed by value B. 2.2 Analyzing Algorithms 1. analyzing an algorithm has come to mean predicting the resources that the algorithm requires 2. need a model of the implementation technology that will be used, including a model for the resources of technology and their costs 3. this text uses a random-access machine model of computation 4. Computer Models (architecture)(tarjan Notes) a) Turing Machines (1) See PowerPoint slides for Lecture 01 (2) Byte magazine article Nov 87 page 345 Malitz "The Turing Machine", Isaac Mailitz, BYTE, November, 1987, pp (3) a finite state control (4) two-way infinite memory tape divided into squares, each holds a finite number of symbols (5) R/W head (6) in one step can (a) read a square (b) write to a square (c) move to an adjacent square left or right (d) change state of the control b) random-access machine (1) finite program (2) finite collection of registers, each stores a single Spring
10 integer or real number (3) memory (array of n words with unique addresses 1 through n holding single integer or real numbers) (4) in one step can (a) perform a single arithmetic operation on specified register contents (b) fetch a word into a register using an (c) address in a register store the contents of a register in a word whose address is in a register c) pointer machines (1) memory is an extendable collection of nodes divided into a fixed number of fields (2) field holds a number of a pointer to a node (3) to read/write a field in a node the machine must have in a register a pointer to the node (4) operations on register contents, fetching/storing, creating and destroying nodes take constant time (5) cannot do address arithmetic (6) good for lower bounds on list-processing algorithms d) common machine attributes (1) all are deterministic and sequential e) C op = ln(number of operands) - logarithmic cost measure f) Tarjan assumptions (1) all algorithms implementable in random-access or pointer machines (2) integers of size at most nc for some small constant c (3) comparison, addition, and multiplication of input values allowed on real numbers (4) no clever encoding to hide parallel computations g) RAM model contains instructions commonly found in real computers (1) Arithmetic (2) Data movement (3) Control (4) (each instruction takes a constant amount of time) h) Date in the RAM model (1) Integer or floating point (2) Limit on size of each word (a) Integers represented by clgn, where c 1 i) What isn t included (1) Compound arithmetical operations (exponentiation) (2) Shift left (equivalent to multiplication by 2) (3) Do not attempt to model the memory hierarchy of real machines 5. Analysis of insertion sort a) input size depends on the problem being studied (total Spring
11 number of items in the input, total number of bits needed to represent the input in binary form) b) running time is the number of primitive operations or steps executed (1) make the notion as machine independent as possible (2) a constant amount of time is required to execute each line of pseudocode, i.e. each time the line is executed it takes the same amount of time (c i ) c) time for different pseudocode lines may be different, though d) if the data are already in sorted order, the running time is linear function of n with constants a and b depending on statement costs e) if the data are in reverse order, the running time is a quadratic function of n with constants a, b, and c depending on statement costs f) walkthrough pages of text 6. Worst-case and average-case analysis a) text usually concentrates on finding the worst-case running time (1) its an upper bound on the running time for any input (2) worst-case can occur fairly often for some algorithms (3) average-case is roughly as bad as the worst-case 7. order of growth a) we'll consider only the leading term of a formula, since the lower-order terms are relatively insignificant, in comparison, for large n C. 2.3 Designing Algorithms 1. incremental approach divide-and-conquer (running times are often easily determined using techniques described in chapter 4) a) The divide-and-conquer approach (using a recursive approach) b) three steps at each level of the recursion (1) DIVIDE the problem into a number of subproblems (2) CONQUER the subproblems by solving them recursively or as a recursion base case (3) COMBINE the solutions to the subproblems into the solution for the original problem c) merge sort (page 31) (1) recursive base case is when a subsequence has length 1 (2) need MERGE(A,p,q,r) to combine two sorted sequences (a) A is an array (b) p, q, and r are indices numbering the elements of the array such that p q < r. (c) merges A[p..q] and A[q+1..r] replacing Spring
12 A[p..r] (d) MERGE is a linear time function Θ(n), where n = r p +1 is the number of elements being merged (i) Choose smaller of two sets, place in merged set (ii) Repeat until both sets exhausted or one set remains (in which case all move to the merged set) (e) Use of a sentinel value (3) Loop invariant analysis of for loop lines (4) Runtime analysis of MERGE pages (5) MERGE-SORT(A,p,r) page 34 (a) (consult handwritten notes on tree here..) Analyzing divide-and-conquer algorithms a) Introduction (1) use recurrence equation or recurrence to describe the running time of an algorithm with a recursive call (2) a subproblems, each of which is 1/b the size of the original data (3) see page 35 b) Analysis of MERGE-SORT (1) Determining the runtime of the divide/conquer/combine steps (2) (Log functions grows more slowly than any linear function) (3) analysis of T(n) using recursion trees, pages (a) (b) add across the levels of the tree in general, level I below the top has 2 i nodes, each contributing a cost of c(n/2 i ), so that the ith level below the top has cost 2 i c(n/2 i ), = cn (4) The number of levels in the recursion tree is lgn + 1 (a) Base occurs when n = 1 and lg1 = 0 (5) Total cost cn(lgn + 1) = cnlgn + cn V. Let us review how we'll view computational complexity A. to solve a problem means to solve all possible instances of a problem B. we are interested in worst case behavior of algorithms C. we are interested in large input problems D. we will analyze time (space) using asymptotic behavior E. we can choose how we represent problem size F. all reasonable such choices will not change our conditions G. analysis is independent of computer model selected Spring
Lecture Notes for Chapter 2: Getting Started
Instant download and all chapters Instructor's Manual Introduction To Algorithms 2nd Edition Thomas H. Cormen, Clara Lee, Erica Lin https://testbankdata.com/download/instructors-manual-introduction-algorithms-2ndedition-thomas-h-cormen-clara-lee-erica-lin/
More informationThe divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems.
2.3 Designing algorithms There are many ways to design algorithms. Insertion sort uses an incremental approach: having sorted the subarray A[1 j - 1], we insert the single element A[j] into its proper
More information6/12/2013. Introduction to Algorithms (2 nd edition) Overview. The Sorting Problem. Chapter 2: Getting Started. by Cormen, Leiserson, Rivest & Stein
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 2: Getting Started (slides enhanced by N. Adlai A. DePano) Overview Aims to familiarize us with framework used throughout
More informationLecture 2: Getting Started
Lecture 2: Getting Started Insertion Sort Our first algorithm is Insertion Sort Solves the sorting problem Input: A sequence of n numbers a 1, a 2,..., a n. Output: A permutation (reordering) a 1, a 2,...,
More informationPlotting run-time graphically. Plotting run-time graphically. CS241 Algorithmics - week 1 review. Prefix Averages - Algorithm #1
CS241 - week 1 review Special classes of algorithms: logarithmic: O(log n) linear: O(n) quadratic: O(n 2 ) polynomial: O(n k ), k 1 exponential: O(a n ), a > 1 Classifying algorithms is generally done
More informationFundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.
Fundamental mathematical techniques reviewed: Mathematical induction Recursion Typically taught in courses such as Calculus and Discrete Mathematics. Techniques introduced: Divide-and-Conquer Algorithms
More informationDiscrete Mathematics Lecture 4. Harper Langston New York University
Discrete Mathematics Lecture 4 Harper Langston New York University Sequences Sequence is a set of (usually infinite number of) ordered elements: a 1, a 2,, a n, Each individual element a k is called a
More informationCS583 Lecture 01. Jana Kosecka. some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes
CS583 Lecture 01 Jana Kosecka some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes Course Info course webpage: - from the syllabus on http://cs.gmu.edu/
More informationThe divide and conquer strategy has three basic parts. For a given problem of size n,
1 Divide & Conquer One strategy for designing efficient algorithms is the divide and conquer approach, which is also called, more simply, a recursive approach. The analysis of recursive algorithms often
More informationSorting & Growth of Functions
Sorting & Growth of Functions CSci 588: Data Structures, Algorithms and Software Design Introduction to Algorithms, Cormen et al., Chapter 3 All material not from online sources or text copyright Travis
More informationData Structures and Algorithms
Data Structures and Algorithms About the course (objectives, outline, recommended reading) Problem solving Notions of Algorithmics (growth of functions, efficiency, programming model, example analysis)
More informationAlgorithms - Ch2 Sorting
Algorithms - Ch2 Sorting (courtesy of Prof.Pecelli with some changes from Prof. Daniels) 1/28/2015 91.404 - Algorithms 1 Algorithm Description Algorithm Description: -Pseudocode see conventions on p. 20-22
More information0.1 Welcome. 0.2 Insertion sort. Jessica Su (some portions copied from CLRS)
0.1 Welcome http://cs161.stanford.edu My contact info: Jessica Su, jtysu at stanford dot edu, office hours Monday 3-5 pm in Huang basement TA office hours: Monday, Tuesday, Wednesday 7-9 pm in Huang basement
More informationLecture 1. Introduction / Insertion Sort / Merge Sort
Lecture 1. Introduction / Insertion Sort / Merge Sort T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3nd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo choo@skku.edu
More informationAdvanced Algorithms and Data Structures
Advanced Algorithms and Data Structures Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Prerequisites A seven credit unit course Replaced OHJ-2156 Analysis of Algorithms We take things a bit further than
More informationSEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION
CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/ SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All
More informationOutline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include
Outline Computer Science 331 Correctness of Algorithms Mike Jacobson Department of Computer Science University of Calgary Lectures #2-4 1 What is a? Applications 2 Recursive Algorithms 3 Final Notes Additional
More informationOrganisation. Assessment
Week 1 s s Getting Started 1 3 4 5 - - Lecturer Dr Lectures Tuesday 1-13 Fulton House Lecture room Tuesday 15-16 Fulton House Lecture room Thursday 11-1 Fulton House Lecture room Friday 10-11 Glyndwr C
More informationSEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY. Lecture 11 CS2110 Spring 2016
1 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Spring 2016 Time spent on A2 2 Histogram: [inclusive:exclusive) [0:1): 0 [1:2): 24 ***** [2:3): 84 ***************** [3:4): 123 *************************
More informationAdvanced Algorithms and Data Structures
Advanced Algorithms and Data Structures Prof. Tapio Elomaa Course Basics A new 7 credit unit course Replaces OHJ-2156 Analysis of Algorithms We take things a bit further than OHJ-2156 We will assume familiarity
More informationCS2351 Data Structures. Lecture 1: Getting Started
CS2351 Data Structures Lecture 1: Getting Started About this lecture Study some sorting algorithms Insertion Sort Selection Sort Merge Sort Show why these algorithms are correct Analyze the efficiency
More informationMergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri
CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri 1 Introduction Today, we will introduce a fundamental algorithm design paradigm,
More informationSEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY
1 A3 and Prelim 2 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Fall 2016 Deadline for A3: tonight. Only two late days allowed (Wed-Thur) Prelim: Thursday evening. 74 conflicts! If you
More informationSEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION
CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Copyright Cengage Learning. All rights reserved. SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All rights reserved.
More informationAlgorithm Analysis and Design
Algorithm Analysis and Design Dr. Truong Tuan Anh Faculty of Computer Science and Engineering Ho Chi Minh City University of Technology VNU- Ho Chi Minh City 1 References [1] Cormen, T. H., Leiserson,
More informationHandout 9: Imperative Programs and State
06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative
More informationCS4311 Design and Analysis of Algorithms. Lecture 1: Getting Started
CS4311 Design and Analysis of Algorithms Lecture 1: Getting Started 1 Study a few simple algorithms for sorting Insertion Sort Selection Sort Merge Sort About this lecture Show why these algorithms are
More informationEECS 2011M: Fundamentals of Data Structures
M: Fundamentals of Data Structures Instructor: Suprakash Datta Office : LAS 3043 Course page: http://www.eecs.yorku.ca/course/2011m Also on Moodle Note: Some slides in this lecture are adopted from James
More informationMergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015
CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015 1 Introduction Today, we will introduce a fundamental algorithm design paradigm, Divide-And-Conquer,
More informationScientific Computing. Algorithm Analysis
ECE257 Numerical Methods and Scientific Computing Algorithm Analysis Today s s class: Introduction to algorithm analysis Growth of functions Introduction What is an algorithm? A sequence of computation
More informationCS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK
CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK Page 1 UNIT I INTRODUCTION 2 marks 1. Why is the need of studying algorithms? From a practical standpoint, a standard set of algorithms from different
More informationRecurrences and Divide-and-Conquer
Recurrences and Divide-and-Conquer Frits Vaandrager Institute for Computing and Information Sciences 16th November 2017 Frits Vaandrager 16th November 2017 Lecture 9 1 / 35 Algorithm Design Strategies
More informationCSC Design and Analysis of Algorithms
CSC 8301- Design and Analysis of Algorithms Lecture 6 Divide and Conquer Algorithm Design Technique Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide a problem instance into two
More informationOrder Analysis of Algorithms. Sorting problem
Order Analysis of Algorithms Debdeep Mukhopadhyay IIT Kharagpur Sorting problem Input: A sequence of n numbers, a1,a2,,an Output: A permutation (reordering) (a1,a2,,an ) of the input sequence such that
More informationCSC Design and Analysis of Algorithms. Lecture 6. Divide and Conquer Algorithm Design Technique. Divide-and-Conquer
CSC 8301- Design and Analysis of Algorithms Lecture 6 Divide and Conquer Algorithm Design Technique Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide a problem instance into two
More informationFramework for Design of Dynamic Programming Algorithms
CSE 441T/541T Advanced Algorithms September 22, 2010 Framework for Design of Dynamic Programming Algorithms Dynamic programming algorithms for combinatorial optimization generalize the strategy we studied
More informationTheory and Algorithms Introduction: insertion sort, merge sort
Theory and Algorithms Introduction: insertion sort, merge sort Rafael Ramirez rafael@iua.upf.es Analysis of algorithms The theoretical study of computer-program performance and resource usage. What s also
More informationCS302 Topic: Algorithm Analysis #2. Thursday, Sept. 21, 2006
CS302 Topic: Algorithm Analysis #2 Thursday, Sept. 21, 2006 Analysis of Algorithms The theoretical study of computer program performance and resource usage What s also important (besides performance/resource
More informationCOMP250: Loop invariants
COMP250: Loop invariants Jérôme Waldispühl School of Computer Science McGill University Based on (CRLS, 2009) & slides from (Sora,2015) Algorithm specification An algorithm is described by: Input data
More information(Refer Slide Time: 1:27)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 1 Introduction to Data Structures and Algorithms Welcome to data
More information«Computer Science» Requirements for applicants by Innopolis University
«Computer Science» Requirements for applicants by Innopolis University Contents Architecture and Organization... 2 Digital Logic and Digital Systems... 2 Machine Level Representation of Data... 2 Assembly
More informationLecture 5: Sorting Part A
Lecture 5: Sorting Part A Heapsort Running time O(n lg n), like merge sort Sorts in place (as insertion sort), only constant number of array elements are stored outside the input array at any time Combines
More informationAlgorithms + Data Structures Programs
Introduction Algorithms Method for solving problems suitable for computer implementation Generally independent of computer hardware characteristics Possibly suitable for many different programming languages
More information5105 BHARATHIDASAN ENGINEERING COLLEGE
CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS II CSE/IT /IV SEMESTER UNIT I PART A 1. Design an algorithm to compute the area and circumference of a circle?(dec 2016) 2. Define recurrence relation? (Dec 2016)
More informationLecture 5: Running Time Evaluation
Lecture 5: Running Time Evaluation Worst-case and average-case performance Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 13 1 Time complexity 2 Time growth 3 Worst-case 4 Average-case
More informationAlgorithms. Algorithms 1.4 ANALYSIS OF ALGORITHMS
ROBERT SEDGEWICK KEVIN WAYNE Algorithms ROBERT SEDGEWICK KEVIN WAYNE 1.4 ANALYSIS OF ALGORITHMS Algorithms F O U R T H E D I T I O N http://algs4.cs.princeton.edu introduction observations mathematical
More informationUML CS Algorithms Qualifying Exam Fall, 2003 ALGORITHMS QUALIFYING EXAM
NAME: This exam is open: - books - notes and closed: - neighbors - calculators ALGORITHMS QUALIFYING EXAM The upper bound on exam time is 3 hours. Please put all your work on the exam paper. (Partial credit
More informationFoundations, Reasoning About Algorithms, and Design By Contract CMPSC 122
Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 I. Logic 101 In logic, a statement or proposition is a sentence that can either be true or false. A predicate is a sentence in
More informationIntroduction to Algorithms
Introduction to Algorithms 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. 1 Why study algorithms?
More informationCSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD
Recap. Growth rates: Arrange the following functions in ascending order of growth rate: n 2 log n n log n 2 log n n/ log n n n Introduction Algorithm: A step-by-step way of solving a problem. Design of
More informationData Structures Lecture 8
Fall 2017 Fang Yu Software Security Lab. Dept. Management Information Systems, National Chengchi University Data Structures Lecture 8 Recap What should you have learned? Basic java programming skills Object-oriented
More informationSolutions to relevant spring 2000 exam problems
Problem 2, exam Here s Prim s algorithm, modified slightly to use C syntax. MSTPrim (G, w, r): Q = V[G]; for (each u Q) { key[u] = ; key[r] = 0; π[r] = 0; while (Q not empty) { u = ExtractMin (Q); for
More informationGreedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.
Greedy Algorithms 1 Simple Knapsack Problem Greedy Algorithms form an important class of algorithmic techniques. We illustrate the idea by applying it to a simplified version of the Knapsack Problem. Informally,
More informationCSE Qualifying Exam, Spring February 2, 2008
CSE Qualifying Exam, Spring 2008 February 2, 2008 Architecture 1. You are building a system around a processor with in-order execution that runs at 1.1 GHz and has a CPI of 0.7 excluding memory accesses.
More informationCS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 25: Review and Open Problems
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 25: Review and Open Problems Course Overview Programming Concepts Object-Oriented Programming Interfaces
More informationExample Algorithms. CSE 2320 Algorithms and Data Structures Alexandra Stefan. University of Texas at Arlington. Last updated 9/7/2016
Example Algorithms CSE 2320 Algorithms and Data Structures Alexandra Stefan University of Texas at Arlington Last updated 9/7/2016 1 Summary Binary Search See the notation conventions (e.g. log 2 N = lg
More informationChapter 4. Divide-and-Conquer. Copyright 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 4 Divide-and-Conquer Copyright 2007 Pearson Addison-Wesley. All rights reserved. Divide-and-Conquer The most-well known algorithm design strategy: 2. Divide instance of problem into two or more
More informationSorting. There exist sorting algorithms which have shown to be more efficient in practice.
Sorting Next to storing and retrieving data, sorting of data is one of the more common algorithmic tasks, with many different ways to perform it. Whenever we perform a web search and/or view statistics
More informationCOE428 Lecture Notes Week 1 (Week of January 9, 2017)
COE428 Lecture Notes: Week 1 1 of 10 COE428 Lecture Notes Week 1 (Week of January 9, 2017) Table of Contents COE428 Lecture Notes Week 1 (Week of January 9, 2017)...1 Announcements...1 Topics...1 Informal
More informationAnalysis of Algorithms - Quicksort -
Analysis of Algorithms - Quicksort - Andreas Ermedahl MRTC (Mälardalens Real-Time Reseach Center) andreas.ermedahl@mdh.se Autumn 2003 Quicksort Proposed by C.A.R. Hoare in 962. Divide- and- conquer algorithm
More informationChapter 9 Graph Algorithms
Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a
More informationPLD Semester Exam Study Guide Dec. 2018
Covers material from Chapters 1-8. Semester Exam will be built from these questions and answers, though they will be re-ordered and re-numbered and possibly worded slightly differently than on this study
More informationPROGRAM EFFICIENCY & COMPLEXITY ANALYSIS
Lecture 03-04 PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS By: Dr. Zahoor Jan 1 ALGORITHM DEFINITION A finite set of statements that guarantees an optimal solution in finite interval of time 2 GOOD ALGORITHMS?
More informationECS122A Lecture Notes on Algorithm Design and Analysis
ECS122A Lecture Notes on Algorithm Design and Analysis Winter 2018 http://www.cs.ucdavis.edu/ bai/ecs122a Professor Zhaojun Bai 1 / 12 Overview I. Introduction and getting started II. Growth of functions
More informationTreewidth and graph minors
Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under
More informationLecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning
Lecture 1 Contracts 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,
More informationCSE 20 DISCRETE MATH. Fall
CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Final exam The final exam is Saturday December 16 11:30am-2:30pm. Lecture A will take the exam in Lecture B will take the exam
More informationScan and its Uses. 1 Scan. 1.1 Contraction CSE341T/CSE549T 09/17/2014. Lecture 8
CSE341T/CSE549T 09/17/2014 Lecture 8 Scan and its Uses 1 Scan Today, we start by learning a very useful primitive. First, lets start by thinking about what other primitives we have learned so far? The
More informationData Structures and Algorithms Chapter 2
1 Data Structures and Algorithms Chapter 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples
More information1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall
CSE 20 https://goo.gl/forms/1o 1KOd17RMoURxjn2 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Today's learning goals Explain the steps in a proof by mathematical and/or structural
More informationCSE 20 DISCRETE MATH. Winter
CSE 20 DISCRETE MATH Winter 2017 http://cseweb.ucsd.edu/classes/wi17/cse20-ab/ Final exam The final exam is Saturday March 18 8am-11am. Lecture A will take the exam in GH 242 Lecture B will take the exam
More informationSorting. Popular algorithms: Many algorithms for sorting in parallel also exist.
Sorting Popular algorithms: Selection sort* Insertion sort* Bubble sort* Quick sort* Comb-sort Shell-sort Heap sort* Merge sort* Counting-sort Radix-sort Bucket-sort Tim-sort Many algorithms for sorting
More informationASYMPTOTIC COMPLEXITY
Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better. - Edsger Dijkstra ASYMPTOTIC COMPLEXITY Lecture
More informationCS1800 Discrete Structures Final Version A
CS1800 Discrete Structures Fall 2017 Profs. Aslam, Gold, & Pavlu December 11, 2017 CS1800 Discrete Structures Final Version A Instructions: 1. The exam is closed book and closed notes. You may not use
More informationChapter 9 Graph Algorithms
Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set
More informationDepartment of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I
MCA 312: Design and Analysis of Algorithms [Part I : Medium Answer Type Questions] UNIT I 1) What is an Algorithm? What is the need to study Algorithms? 2) Define: a) Time Efficiency b) Space Efficiency
More informationData Structures and Algorithms. Part 2
1 Data Structures and Algorithms Part 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples displayed
More informationDivide & Conquer Design Technique
Divide & Conquer Design Technique Adnan YAZICI Dept. of Computer Engineering Middle East Technical Univ. Ankara - TURKEY 1 The Divide & Conquer strategy can be described in general terms as follows: A
More informationWe ve studied the main models and concepts of the theory of computation:
CMPSCI 601: Summary & Conclusions Lecture 27 We ve studied the main models and concepts of the theory of computation: Computability: what can be computed in principle Logic: how can we express our requirements
More informationCIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)
By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable
More informationDISCRETE MATHEMATICS
DISCRETE MATHEMATICS WITH APPLICATIONS THIRD EDITION SUSANNA S. EPP DePaul University THOIVISON * BROOKS/COLE Australia Canada Mexico Singapore Spain United Kingdom United States CONTENTS Chapter 1 The
More informationIntegers and Mathematical Induction
IT Program, NTUT, Fall 07 Integers and Mathematical Induction Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology TAIWAN 1 Learning Objectives Learn about
More informationCS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 10: Asymptotic Complexity and What Makes a Good Algorithm? Suppose you have two possible algorithms or
More informationEND-TERM EXAMINATION
(Please Write your Exam Roll No. immediately) Exam. Roll No... END-TERM EXAMINATION Paper Code : MCA-205 DECEMBER 2006 Subject: Design and analysis of algorithm Time: 3 Hours Maximum Marks: 60 Note: Attempt
More informationScan and Quicksort. 1 Scan. 1.1 Contraction CSE341T 09/20/2017. Lecture 7
CSE341T 09/20/2017 Lecture 7 Scan and Quicksort 1 Scan Scan is a very useful primitive for parallel programming. We will use it all the time in this class. First, lets start by thinking about what other
More information17/05/2018. Outline. Outline. Divide and Conquer. Control Abstraction for Divide &Conquer. Outline. Module 2: Divide and Conquer
Module 2: Divide and Conquer Divide and Conquer Control Abstraction for Divide &Conquer 1 Recurrence equation for Divide and Conquer: If the size of problem p is n and the sizes of the k sub problems are
More informationCSE 20 DISCRETE MATH WINTER
CSE 20 DISCRETE MATH WINTER 2016 http://cseweb.ucsd.edu/classes/wi16/cse20-ab/ Today's learning goals Explain the steps in a proof by (strong) mathematical induction Use (strong) mathematical induction
More information1 Introduction. 2 InsertionSort. 2.1 Correctness of InsertionSort
CS 161, Lecture 2 MergeSort, Recurrences 101, and Asymptotic Analysis Scribes: Michael Kim (2015), Ofir Geri (2016), M. Wootters (2017) Date: September 27, 2017 Adapted From Virginia Williams lecture notes
More informationAlgorithms and Data Structures (INF1) Lecture 15/15 Hua Lu
Algorithms and Data Structures (INF1) Lecture 15/15 Hua Lu Department of Computer Science Aalborg University Fall 2007 This Lecture Minimum spanning trees Definitions Kruskal s algorithm Prim s algorithm
More informationWhat is an algorithm?
Reminders CS 142 Lecture 3 Analysis, ADTs & Objects Program 1 was assigned - Due on 1/27 by 11:55pm 2 Abstraction Measuring Algorithm Efficiency When you utilize the mylist.index(item) function you are
More informationClassic Data Structures Introduction UNIT I
ALGORITHM SPECIFICATION An algorithm is a finite set of instructions that, if followed, accomplishes a particular task. All algorithms must satisfy the following criteria: Input. An algorithm has zero
More informationCS 512, Spring 2017: Take-Home End-of-Term Examination
CS 512, Spring 2017: Take-Home End-of-Term Examination Out: Tuesday, 9 May 2017, 12:00 noon Due: Wednesday, 10 May 2017, by 11:59 am Turn in your solutions electronically, as a single PDF file, by placing
More information6.001 Notes: Section 4.1
6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,
More informationIntroduction to the Analysis of Algorithms. Algorithm
Introduction to the Analysis of Algorithms Based on the notes from David Fernandez-Baca Bryn Mawr College CS206 Intro to Data Structures Algorithm An algorithm is a strategy (well-defined computational
More informationDesign and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis
Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Week 02 Module 06 Lecture - 14 Merge Sort: Analysis So, we have seen how to use a divide and conquer strategy, we
More informationIntroduction to Axiomatic Semantics
Introduction to Axiomatic Semantics Meeting 10, CSCI 5535, Spring 2009 Announcements Homework 3 due tonight Homework 2 is graded 13 (mean), 14 (median), out of 21 total, but Graduate class: final project
More information1 Definition of Reduction
1 Definition of Reduction Problem A is reducible, or more technically Turing reducible, to problem B, denoted A B if there a main program M to solve problem A that lacks only a procedure to solve problem
More informationThe Limits of Sorting Divide-and-Conquer Comparison Sorts II
The Limits of Sorting Divide-and-Conquer Comparison Sorts II CS 311 Data Structures and Algorithms Lecture Slides Monday, October 12, 2009 Glenn G. Chappell Department of Computer Science University of
More informationThomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms
Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Introduction to Algorithms Preface xiii 1 Introduction 1 1.1 Algorithms 1 1.2 Analyzing algorithms 6 1.3 Designing algorithms 1 1 1.4 Summary 1 6
More informationTheory and Frontiers of Computer Science. Fall 2013 Carola Wenk
Theory and Frontiers of Computer Science Fall 2013 Carola Wenk We have seen so far Computer Architecture and Digital Logic (Von Neumann Architecture, binary numbers, circuits) Introduction to Python (if,
More information