Complexity. Alexandra Silva.
|
|
- Loren Miles
- 6 years ago
- Views:
Transcription
1 Complexity Alexandra Silva Institute for Computing and Information Sciences 22nd April 2014 Alexandra 22nd April 2014 Lesson 1 1 / 47
2 This is a course about algorithms and complexity We will analyze algorithms and assess efficiency It is an essential skill for advanced programmers Alexandra 22nd April 2014 Lesson 1 2 / 47
3 Basic course information Teachers Alexandra (lectures) Tim (tutorials) Robin and Wouter (practical assignments) There are 7 lectures plus 7 tutorials. No lecture on 17 June and no tutorial on 18 April (Good Friday) and 29 May (some other holiday). Final grade 0.6 T P T = test and P = practical assignment Mark of test must be at least 5. Alexandra 22nd April 2014 Lesson 1 3 / 47
4 Basic course information Lectures Weekly, 2 hours, on Tuesdays 15:45 Presence not compulsory... but active attitude expected, when present Tutorials Weekly, 2 hours, on Fridays 15:45. Homework not compulsory. Practical assignment Evaluation with several tests (easy, difficult). There will be a prize for the best assignment! Alexandra 22nd April 2014 Lesson 1 4 / 47
5 Basic course information Website complexity-2014/ Doubts, complains, suggestions,... My office: HG , check availability: Alexandra 22nd April 2014 Lesson 1 5 / 47
6 Basic course information How to pass this course... Practice, practice, practice... You don t learn it it by just staring at the slides - not a spectator sport! Test questions will be in line with exercises. Alexandra 22nd April 2014 Lesson 1 6 / 47
7 Basic course information Last but not least Alexandra 22nd April 2014 Lesson 1 7 / 47
8 Basic course information Last but not least You can fail for this course! (Statistics tells that some of you will) Alexandra 22nd April 2014 Lesson 1 7 / 47
9 Basic course information Last but not least You can fail for this course! (Statistics tells that some of you will) 3ec means 3 28 = 84 hours in total Let s say 20 hours for exam 64 hours for 8 weeks means: 8 hours per week! on average 4 hours for studying & making exercises Alexandra 22nd April 2014 Lesson 1 7 / 47
10 The importance of algorithms in Computer Science Alexandra 22nd April 2014 Lesson 1 8 / 47
11 Computer Science Alexandra 22nd April 2014 Lesson 1 9 / 47
12 Algorithms Algorithms = Human (high-level) way of teaching a computer what to do to solve a problem Alexandra 22nd April 2014 Lesson 1 10 / 47
13 One algorithm can change the world Alexandra 22nd April 2014 Lesson 1 11 / 47
14 One algorithm can change the world Why was the Google algorithm successful? Solved a problem search in an elegant, efficient, correct and scalable way. Alexandra 22nd April 2014 Lesson 1 11 / 47
15 Manao is traversing a valley inhabited by monsters. During his journey, he will encounter several monsters. The scariness of each monster is a number dread/scare. Manao is not going to fight the monsters (watje). Alexandra 22nd April 2014 Lesson 1 12 / 47
16 Instead, he will bribe some of them and make them join him. The monsters are not too greedy (price = 1 or 2). Alexandra 22nd April 2014 Lesson 1 13 / 47
17 Manao meets monster: bribe or not bribe? No bribe, not scary enough: monster will attack! Bribe: monster will join the party! So: if monster is stronger, Manao bribes. If monster is not strong: choice. Alexandra 22nd April 2014 Lesson 1 14 / 47
18 : example Dragon: bribe (always for the first monster). Hydra: Manao can either pass or bribe her. Killer Rabbit: 1 Bribed Hydra: total scariness = 13 > 10. Pass the rabbit! Total cost = = 2 coins. 2 Bribe the Rabbit. Total cost = = 3 coins. Alexandra 22nd April 2014 Lesson 1 15 / 47
19 : version 1 There are between 1 and 20 monsters. Their scariness level is between 1 and 2,000,000,000, inclusive. The bribe for each monster will be either 1 or 2. Alexandra 22nd April 2014 Lesson 1 16 / 47
20 : version 1 There are between 1 and 20 monsters. Their scariness level is between 1 and 2,000,000,000, inclusive. The bribe for each monster will be either 1 or 2. Goal Minimize the amount of money Manao needs to pay. Alexandra 22nd April 2014 Lesson 1 16 / 47
21 How do we solve it? Monster 0: no option, we bribe. Monster 1: two options. 1 Not bribe: we are scary enough, money and scariness. 2 bribe: scariness and money spent.. Monster p: we have passed the first p monsters and we have a total scariness level of currentscare. How do we decide what to do? Alexandra 22nd April 2014 Lesson 1 17 / 47
22 How do we solve it? Monster p: Bribe or scare? We will compute the minimum price at step p given how scary we are M(p, CurrentScare) by analyzing our two options: 1 bribe: it will cost us price p, we earn scare p. P 1 = price p + M(p + 1, CurrentScare + scare p ) 2 scare: currentscare > scare p, not pay, not scarier. P 2 = M(p + 1, CurrentScare) Choose best option: M(p, CurrentScare) = min(p 1, P 2 ). Alexandra 22nd April 2014 Lesson 1 18 / 47
23 How do we solve it? In the solution: We were using the minimum price of the next monster recursive algorithm. Alexandra 22nd April 2014 Lesson 1 19 / 47
24 How do we solve it? In the solution: We were using the minimum price of the next monster recursive algorithm. When do we stop: p = n all monsters done, price is 0. Alexandra 22nd April 2014 Lesson 1 19 / 47
25 How efficient is this algorithm? Let s measure how many options we have: At each step we double our options. For n monsters we have }{{} n times Alexandra 22nd April 2014 Lesson 1 20 / 47
26 How efficient is this algorithm? } 2 2 {{ 2 } = 2 n n times For 20 monsters we have Alexandra 22nd April 2014 Lesson 1 21 / 47
27 How efficient is this algorithm? } 2 2 {{ 2 } = 2 n n times For 20 monsters we have Good or bad? Alexandra 22nd April 2014 Lesson 1 21 / 47
28 : version 2 There can be now up to 50 monsters Alexandra 22nd April 2014 Lesson 1 22 / 47
29 : version 2 Is our previous algorithm ok? Alexandra 22nd April 2014 Lesson 1 23 / 47
30 : version 2 Is our previous algorithm ok? 2 50 = VERY BIG NUMBER Alexandra 22nd April 2014 Lesson 1 23 / 47
31 : version 2 Is our previous algorithm ok? 2 50 = VERY BIG NUMBER Actually, with 2 50 grains of rice you can cover the whole of the Netherlands with ca 2 meters of rice. Alexandra 22nd April 2014 Lesson 1 23 / 47
32 : version 2 Can we do better? Alexandra 22nd April 2014 Lesson 1 24 / 47
33 : version 2 Can we do better? Different perspective: what is the maximum price to pay for n monsters? Alexandra 22nd April 2014 Lesson 1 24 / 47
34 : version 2 Can we do better? Different perspective: what is the maximum price to pay for n monsters? 2 n Alexandra 22nd April 2014 Lesson 1 24 / 47
35 : version 2 Can we do better? Different perspective: what is the maximum price to pay for n monsters? 2 n Instead of minimizing, ask... For each price p from 0 to 2 n, can we cross without paying more than p? For n 50 there are at most 101 values for p and we can answer the problem fast (in polynomial time). Alexandra 22nd April 2014 Lesson 1 24 / 47
36 : version 2 Can we do better? Different perspective: what is the maximum price to pay for n monsters? 2 n Instead of minimizing, ask... For each price p from 0 to 2 n, can we cross without paying more than p? For n 50 there are at most 101 values for p and we can answer the problem fast (in polynomial time). solution = chocolate bar! Alexandra 22nd April 2014 Lesson 1 24 / 47
37 Topcoder appeared in a programming match of TopCoder. Both problems were solved in under 4 minutes! Alexandra 22nd April 2014 Lesson 1 25 / 47
38 Lessons to take home The parameters of the problem matter. Solutions often need to be adapted. A lot of improvement can be done before implementation. Alexandra 22nd April 2014 Lesson 1 26 / 47
39 Lessons to take home The parameters of the problem matter. Solutions often need to be adapted. A lot of improvement can be done before implementation. It is all about asking the right questions! Alexandra 22nd April 2014 Lesson 1 26 / 47
40 Lessons to take home The parameters of the problem matter. Solutions often need to be adapted. A lot of improvement can be done before implementation. It is all about asking the right questions! A lot of Computer Science is like solving puzzles! Alexandra 22nd April 2014 Lesson 1 26 / 47
41 Analysis of algorithms Study of different features that allow classifying and comparing algorithms Alexandra 22nd April 2014 Lesson 1 27 / 47
42 Analysis of algorithms Study of different features that allow classifying and comparing algorithms One important feature: the correction of an algorithm. Does the algorithm actually do what we meant it to do? (we will not be dealing with that in this course.) Alexandra 22nd April 2014 Lesson 1 27 / 47
43 Analysis of algorithms Then, it is important to take into account the resources needed to execute an algorithm: memory bandwidth hardware... and of particular interest in this course: execution/computation time The latter is what we will be using as comparison measure between algorithms. Alexandra 22nd April 2014 Lesson 1 28 / 47
44 Analysis of algorithms Then, it is important to take into account the resources needed to execute an algorithm: memory bandwidth hardware... and of particular interest in this course: execution/computation time The latter is what we will be using as comparison measure between algorithms. The strategy used in an algorithm to perform a certain task is very important! Alexandra 22nd April 2014 Lesson 1 28 / 47
45 In a nutshell... What we will be doing for the next couple of lectures. Analysis of execution times: Computational models Analyze the best, worst and average case of an algorithm Analysis of recursive algorithms (recurrence relations) (Analysis of average case; randomized algorithms) Analysis of strategies: linear, incremental divide and conquer, (greedy algorithms, dynamic programming) Sorting (and searching) algorithms Case studies: linear search, binary search, insertion sort, mergesort, quicksort, radix sort, heap sort. Alexandra 22nd April 2014 Lesson 1 29 / 47
46 For the sake of clarity: what is an algorithm An algorithm is a well-defined procedure which takes an input value and returns an output value Alternative definitions a sequence of computational steps transforming an input value into an output value a tool to solve a well defined computational problem, which defined the relation between input and output... Alexandra 22nd April 2014 Lesson 1 30 / 47
47 Why are algorithms important? Typical areas of application: Internet: routing, searching, etc Security and cryptography Operations research (have you wondered how TNT programs their deliveries?) Maps (TomTom and such) Alexandra 22nd April 2014 Lesson 1 31 / 47
48 Why are algorithms important? Typical areas of application: Internet: routing, searching, etc Security and cryptography Operations research (have you wondered how TNT programs their deliveries?) Maps (TomTom and such) Examples of hard problems how to find the shortest/fastest path from N (Nijmegen) to A (Amsterdam) in a given map? how to visit all the cities in the Netherlands in the shortest way possible? given a set of matrices (possibly not square), how to compute their multiplication? Alexandra 22nd April 2014 Lesson 1 31 / 47
49 Why are efficient algorithms important? For a given problem, the ultimate quest is to find the most efficient algorithm. Alexandra 22nd April 2014 Lesson 1 32 / 47
50 Why are efficient algorithms important? For a given problem, the ultimate quest is to find the most efficient algorithm. For harder problems, no efficient solution is known. These algorithms are NP (another course). Alexandra 22nd April 2014 Lesson 1 32 / 47
51 Why are efficient algorithms important? For a given problem, the ultimate quest is to find the most efficient algorithm. For harder problems, no efficient solution is known. These algorithms are NP (another course). A subclass of NP which is interesting is the class of NP-complete problems, because: The description of the problem is simple; they arise usually in common and important application areas; it is not know whether there is an efficient algorithm to solve them; if someone finds an efficient solution for one of these problems, then all of them are solvable efficiently! when (trying to) solves an NP-complete problem, solutions that come close to the ideal solution are enough, a long as computed in reasonable time. Alexandra 22nd April 2014 Lesson 1 32 / 47
52 Why is analysis of algorithms important? Why should we care to learn how to design and analyze algorithms? Even though many problems have been solved efficiently, the rapid change in the world (think of the amount of info) requires for constant improvement in the existing algorithms and design of new, more efficient algorithms; If we would have infinite resources (memory, processing speed,... ) then any solution would be fine; but in reality we have to optimize consumption and minimize the resource consumption (we have to be zuinig)! Alexandra 22nd April 2014 Lesson 1 33 / 47
53 Why is analysis of algorithms important? Why should we care to learn how to design and analyze algorithms? (c d) Algorithms for the same problem can have (crazily) different behaviors: good algorithm design can have more impact than the choice of hardware. In a nutshell: algorithms are important because the choices made at that level of devising a system can strongly affect its validity and scope of application. Alexandra 22nd April 2014 Lesson 1 34 / 47
54 Execution time analysis computational model To do this type of analysis we need to take to fix our setting: Which model should we use? What is the cost of the resources in that model Alexandra 22nd April 2014 Lesson 1 35 / 47
55 Execution time analysis computational model To do this type of analysis we need to take to fix our setting: Which model should we use? What is the cost of the resources in that model This is what we will use: Model: Random Access Machine (RAM). A generic computer, single processor, no concurrency (instructions executed sequentially) The algorithms are implemented as programs in such a simplified computer Alexandra 22nd April 2014 Lesson 1 35 / 47
56 Execution time analysis computational model We will not specify the model completely; we will be reasonable when it comes to using it... A computer does not have complicated functions as search or sort but more primitive/atomic ones such as: arithmetic operations: sum, multiplication,... basic data manipulation: store, access, copy,... basic control structures: if-then-else, loops,... For the purpose of this course, all these primitive operations execute in constant time. Alexandra 22nd April 2014 Lesson 1 36 / 47
57 Execution time analysis computational model Talking about being reasonable: Do you think exponentiation is executed in constant time? The RAM computational model does not take into account the memory hierarchy computers have (cache, virtual memory), however the analysis using this model is (almost) always a good representative. Alexandra 22nd April 2014 Lesson 1 37 / 47
58 Execution time analysis computational model Dimension of the input depends on the sort of problem being analyzed: sorting a list/vector: number of elements multiplying two integers: total number of bits used in the number representation shortest path in a graph: the input has two items (V,E) vertices and edges Execution time: number of primitive/atomic operations executed Operations are defined independently of a specific machine Do you think call of a sub-routine is an atomic operation? Alexandra 22nd April 2014 Lesson 1 38 / 47
59 In a nutshell blackboard... Alexandra 22nd April 2014 Lesson 1 39 / 47
60 In a nutshell blackboard... blue: 0.5n 2 + n black: 0.5n 2 red: 2 n green: lg(n) Alexandra 22nd April 2014 Lesson 1 39 / 47
61 Impact of complexity Alexandra 22nd April 2014 Lesson 1 40 / 47
62 Example: Looking up a word in a dictionary Alexandra 22nd April 2014 Lesson 1 41 / 47
63 Example: Looking up a word in a dictionary Alexandra 22nd April 2014 Lesson 1 42 / 47
64 How to compare execution functions We define classes of functions. Alexandra 22nd April 2014 Lesson 1 43 / 47
65 How to compare execution functions We define classes of functions. Intuitively: f O(g): f does not grow faster than g. e.g T (n) = 4n 2 2n + 2 Alexandra 22nd April 2014 Lesson 1 43 / 47
66 How to compare execution functions We define classes of functions. Intuitively: f O(g): f does not grow faster than g. e.g T (n) = 4n 2 2n + 2is in O(n 2 ). Alexandra 22nd April 2014 Lesson 1 43 / 47
67 How to compare execution functions We define classes of functions. Intuitively: f O(g): f does not grow faster than g. e.g T (n) = 4n 2 2n + 2is in O(n 2 ). More formally: means that there exists a point x 0 where function f is below cg. Alexandra 22nd April 2014 Lesson 1 43 / 47
68 How to compare execution functions Figure: Example: f O(g). Important: need to provide x 0 and c! (exercises) Alexandra 22nd April 2014 Lesson 1 44 / 47
69 Algorithms: Searching Alexandra 22nd April 2014 Lesson 1 45 / 47
70 Example I : Linear search in a vector int linsearch(int *v, int a, int b, int k) { int i; i=a; while ((i<=b) && (v[i]!=k)) i++; if (i>b) return -1; else return i; } Alexandra 22nd April 2014 Lesson 1 46 / 47
71 Example I : Linear search in a vector int linsearch(int *v, int a, int b, int k) { int i; i=a; c 1 while ((i<=b) && (v[i]!=k)) c 2 i++; c 3 if (i>b) c 4 return -1; c 5 else return i; c 5 } Cost Alexandra 22nd April 2014 Lesson 1 46 / 47
72 Example I : Linear search in a vector Cost int linsearch(int *v, int a, int b, int k) { int i; i=a; c 1 while ((i<=b) && (v[i]!=k)) c 2 i++; c 3 if (i>b) c 4 return -1; c 5 else return i; c 5 } m is the number of time i++ executes. repetitions 1 m+1 m Alexandra 22nd April 2014 Lesson 1 46 / 47
73 Example I : Linear search in a vector Cost repetitions int linsearch(int *v, int a, int b, int k) { int i; i=a; c 1 while ((i<=b) && (v[i]!=k)) c 2 i++; c 3 if (i>b) c 4 return -1; c 5 else return i; c 5 } 1 m+1 m m is the number of time i++ executes. Obs1: These value depends on the while loop condition being true the position i is in-between a and b, that is: 0 m b a + 1. Alexandra 22nd April 2014 Lesson 1 46 / 47
74 Total Execution Time T (n) = c 1 + c 2 (m + 1) + c 3 m + c 4 + c 5 Alexandra 22nd April 2014 Lesson 1 47 / 47
75 Total Execution Time T (n) = c 1 + c 2 (m + 1) + c 3 m + c 4 + c 5 For a given n (the size of the input to search, n = b a + 1), the value T (n) can vary: why? Alexandra 22nd April 2014 Lesson 1 47 / 47
76 Total Execution Time T (n) = c 1 + c 2 (m + 1) + c 3 m + c 4 + c 5 For a given n (the size of the input to search, n = b a + 1), the value T (n) can vary: why? Depends on when the element is found. Alexandra 22nd April 2014 Lesson 1 47 / 47
77 Total Execution Time T (n) = c 1 + c 2 (m + 1) + c 3 m + c 4 + c 5 For a given n (the size of the input to search, n = b a + 1), the value T (n) can vary: why? Depends on when the element is found. Best case scenario: The value k is in the first position (k = v[a]). Then: T (n) = (c 1 + c 2 + c 4 + c 5 ) T(n) is constant Worst case scenario: the value in not found. T (n) = c 1 +c 2 (n+1)+c 3 (n)+c 4 +c 5 = (c 2 +c 3 )n+(c 1 +c 2 +c 4 +c 5 ) T(n) is linear Alexandra 22nd April 2014 Lesson 1 47 / 47
Complexity. Alexandra Silva.
Complexity Alexandra Silva alexandra@cs.ru.nl http://www.cs.ru.nl/~alexandra Institute for Computing and Information Sciences 6th February 2013 Alexandra 6th February 2013 Lesson 1 1 / 39 Introduction
More informationData Structures and Algorithms
Berner Fachhochschule - Technik und Informatik Data Structures and Algorithms Topic 1: Algorithm Analysis Philipp Locher FS 2018 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and
More informationAlgorithms and Data Structures
Algorithm Analysis Page 1 - Algorithm Analysis Dr. Fall 2008 Algorithm Analysis Page 2 Outline Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Growth Rate and Big-Oh Notation
More informationAlgorithms and Data Structures, or
Algorithms and Data Structures, or... Classical Algorithms of the 50s, 60s and 70s Mary Cryan A&DS Lecture 1 1 Mary Cryan Our focus Emphasis is Algorithms ( Data Structures less important). Most of the
More informationVirtual University of Pakistan
Virtual University of Pakistan Department of Computer Science Course Outline Course Instructor Dr. Sohail Aslam E mail Course Code Course Title Credit Hours 3 Prerequisites Objectives Learning Outcomes
More informationCOMP 161 Lecture Notes 16 Analyzing Search and Sort
COMP 161 Lecture Notes 16 Analyzing Search and Sort In these notes we analyze search and sort. Counting Operations When we analyze the complexity of procedures we re determine the order of the number of
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 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 informationData Structures and Algorithms CMPSC 465
Data Structures and Algorithms CMPSC 465 LECTURES 7-8 More Divide and Conquer Multiplication Adam Smith S. Raskhodnikova and A. Smith; based on slides by E. Demaine and C. Leiserson John McCarthy (1927
More informationFaculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University
NAME: STUDENT NUMBER:. Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University Examimer: Prof. Mathieu Blanchette December 8 th 2005,
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 informationWeek 12: Running Time and Performance
Week 12: Running Time and Performance 1 Most of the problems you have written in this class run in a few seconds or less Some kinds of programs can take much longer: Chess algorithms (Deep Blue) Routing
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 informationDesign and Analysis of Algorithms. Comp 271. Mordecai Golin. Department of Computer Science, HKUST
Design and Analysis of Algorithms Revised 05/02/03 Comp 271 Mordecai Golin Department of Computer Science, HKUST Information about the Lecturer Dr. Mordecai Golin Office: 3559 Email: golin@cs.ust.hk http://www.cs.ust.hk/
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 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 informationPractice Problems for the Final
ECE-250 Algorithms and Data Structures (Winter 2012) Practice Problems for the Final Disclaimer: Please do keep in mind that this problem set does not reflect the exact topics or the fractions of each
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 03 / 19 / 2018 Instructor: Michael Eckmann Today s Topics Questions? Comments? Change making algorithm Greedy algorithm implementation Divide and conquer recursive
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 informationA Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 3 Parallel Prefix, Pack, and Sorting
A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 3 Parallel Prefix, Pack, and Sorting Dan Grossman Last Updated: November 2012 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 03 / 25 / 2013 Instructor: Michael Eckmann Today s Topics Comments/Questions? More on Recursion Including Dynamic Programming technique Divide and Conquer techniques
More informationCS 483. Jana Kosecka CS Dept Eng. Building
CS 483 Jana Kosecka CS Dept. 4444 Eng. Building kosecka@gmu.edu Course Info Course webpage: from the syllabus on http://cs.gmu.edu/courses/ Information you will find course syllabus, time table office
More informationDesign and Analysis of Computer Algorithm Lecture 1. Assoc. Prof.Pradondet Nilagupta Department of Computer Engineering
Design and Analysis of Computer Algorithm Lecture 1 Assoc. Prof.Pradondet Nilagupta Department of Computer Engineering pom@ku.ac.th Acknowledgement This lecture note has been summarized from lecture note
More informationAlgorithms and Data Structures
Algorithms and Data Structures or, Classical Algorithms of the 50s, 60s, 70s Richard Mayr Slides adapted from Mary Cryan (2015/16) with small changes. School of Informatics University of Edinburgh ADS
More informationComputer Algorithms. Introduction to Algorithm
Computer Algorithms Introduction to Algorithm CISC 4080 Yanjun Li 1 What is Algorithm? An Algorithm is a sequence of well-defined computational steps that transform the input into the output. These steps
More informationCSE 332: Data Structures & Parallelism Lecture 12: Comparison Sorting. Ruth Anderson Winter 2019
CSE 332: Data Structures & Parallelism Lecture 12: Comparison Sorting Ruth Anderson Winter 2019 Today Sorting Comparison sorting 2/08/2019 2 Introduction to sorting Stacks, queues, priority queues, and
More informationNotes on Minimum Spanning Trees. Red Rule: Given a cycle containing no red edges, select a maximum uncolored edge on the cycle, and color it red.
COS 521 Fall 2009 Notes on Minimum Spanning Trees 1. The Generic Greedy Algorithm The generic greedy algorithm finds a minimum spanning tree (MST) by an edge-coloring process. Initially all edges are uncolored.
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 informationAnalysis of Algorithms - Introduction -
Analysis of Algorithms - Introduction - Andreas Ermedahl MRTC (Mälardalens Real-Time Research Center) andreas.ermedahl@mdh.se Autumn 004 Administrative stuff Course leader: Andreas Ermedahl Email: andreas.ermedahl@mdh.se
More informationHash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell
Hash Tables CS 311 Data Structures and Algorithms Lecture Slides Wednesday, April 22, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005
More informationCSE 373: Data Structures and Algorithms
CSE 373: Data Structures and Algorithms Lecture 21: Finish Sorting, P vs NP Instructor: Lilian de Greef Quarter: Summer 2017 Today Announcements Finish up sorting Radix Sort Final comments on sorting Complexity
More information1. For the sieve technique we solve the problem, recursively mathematically precisely accurately 2. We do sorting to, keep elements in random positions keep the algorithm run in linear order keep the algorithm
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 informationDynamic Programming. Lecture Overview Introduction
Lecture 12 Dynamic Programming 12.1 Overview Dynamic Programming is a powerful technique that allows one to solve many different types of problems in time O(n 2 ) or O(n 3 ) for which a naive approach
More informationCS 4349 Lecture August 21st, 2017
CS 4349 Lecture August 21st, 2017 Main topics for #lecture include #administrivia, #algorithms, #asymptotic_notation. Welcome and Administrivia Hi, I m Kyle! Welcome to CS 4349. This a class about algorithms.
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 informationGrade 6 Math Circles November 6 & Relations, Functions, and Morphisms
Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Relations Let s talk about relations! Grade 6 Math Circles November 6 & 7 2018 Relations, Functions, and
More informationWhy study algorithms? CS 561, Lecture 1. Today s Outline. Why study algorithms? (II)
Why study algorithms? CS 561, Lecture 1 Jared Saia University of New Mexico Seven years of College down the toilet - John Belushi in Animal House Q: Can I get a programming job without knowing something
More informationCS 171: Introduction to Computer Science II. Quicksort
CS 171: Introduction to Computer Science II Quicksort Roadmap MergeSort Recursive Algorithm (top-down) Practical Improvements Non-recursive algorithm (bottom-up) Analysis QuickSort Algorithm Analysis Practical
More informationCS 361 Algorithms & Data Structures Lecture 1. Prof. Tom Hayes University of New Mexico
CS 361 Algorithms & Data Structures Lecture 1 Prof. Tom Hayes University of New Mexico 8-21-2012 1 Who we are Prof. Tom Hayes, hayes@cs.unm.edu Office: FEC 149 Hours: TuW 2:00-2:50 and by appt Phone: 277-9328
More informationLECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS
Department of Computer Science University of Babylon LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS By Faculty of Science for Women( SCIW), University of Babylon, Iraq Samaher@uobabylon.edu.iq
More informationFinal Exam Solutions
Introduction to Algorithms December 14, 2010 Massachusetts Institute of Technology 6.006 Fall 2010 Professors Konstantinos Daskalakis and Patrick Jaillet Final Exam Solutions Final Exam Solutions Problem
More informationAlgorithms and Data Structures. Algorithms and Data Structures. Algorithms and Data Structures. Algorithms and Data Structures
Richard Mayr Slides adapted from Mary Cryan (2015/16) with some changes. School of Informatics University of Edinburgh ADS (2018/19) Lecture 1 slide 1 ADS (2018/19) Lecture 1 slide 3 ADS (2018/19) Lecture
More informationDIVIDE AND CONQUER ALGORITHMS ANALYSIS WITH RECURRENCE EQUATIONS
CHAPTER 11 SORTING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM NANCY M. AMATO AND
More informationOverview of UE 101: Algorithms and Programming
Overview of UE 101: Algorithms and Programming Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. Aug 2, 2017 Outline 1 What we study 2 Programs 3 Algorithms
More informationCSE 373: Data Structures and Algorithms
CSE 373: Data Structures and Algorithms Lecture 21: Finish Sorting, P vs NP Instructor: Lilian de Greef Quarter: Summer 2017 Today Announcements Finish up sorting Radix Sort Final comments on sorting Complexity
More informationDIVIDE & CONQUER. Problem of size n. Solution to sub problem 1
DIVIDE & CONQUER Definition: Divide & conquer is a general algorithm design strategy with a general plan as follows: 1. DIVIDE: A problem s instance is divided into several smaller instances of the same
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 informationLecture 6: Sequential Sorting
15-150 Lecture 6: Sequential Sorting Lecture by Dan Licata February 2, 2012 Today s lecture is about sorting. Along the way, we ll learn about divide and conquer algorithms, the tree method, and complete
More informationDesign and Analysis of Algorithms
Design and Analysis of Algorithms CSE 5311 Lecture 8 Sorting in Linear Time Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 Sorting So Far
More informationEECS 3101: Introduction to the Design and Analysis of Algorithms Instructor: Suprakash Datta (datta[at]cse.yorku.ca) ext 77875
: Introduction to the Design and Analysis of Algorithms Instructor: Suprakash Datta (datta[at]cse.yorku.ca) ext 77875 Lectures: MW 4:00 5:30 PM, DB 0001 Tutorials: Th 4:00 5:30 PM, DB 0001 Office hours
More informationCSC236 Week 5. Larry Zhang
CSC236 Week 5 Larry Zhang 1 Logistics Test 1 after lecture Location : IB110 (Last names A-S), IB 150 (Last names T-Z) Length of test: 50 minutes If you do really well... 2 Recap We learned two types of
More informationCSE 373: Data Structures and Algorithms
CSE 373: Data Structures and Algorithms Lecture 19: Comparison Sorting Algorithms Instructor: Lilian de Greef Quarter: Summer 2017 Today Intro to sorting Comparison sorting Insertion Sort Selection Sort
More informationMUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala
MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com Reference MCQ s For MIDTERM EXAMS CS502- Design and Analysis of Algorithms 1. For the sieve technique we solve
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 informationCSE373: Data Structure & Algorithms Lecture 21: More Comparison Sorting. Aaron Bauer Winter 2014
CSE373: Data Structure & Algorithms Lecture 21: More Comparison Sorting Aaron Bauer Winter 2014 The main problem, stated carefully For now, assume we have n comparable elements in an array and we want
More informationCMPSCI 187: Programming With Data Structures. Lecture 5: Analysis of Algorithms Overview 16 September 2011
CMPSCI 187: Programming With Data Structures Lecture 5: Analysis of Algorithms Overview 16 September 2011 Analysis of Algorithms Overview What is Analysis of Algorithms? L&C s Dishwashing Example Being
More informationQuickSort
QuickSort 7 4 9 6 2 2 4 6 7 9 4 2 2 4 7 9 7 9 2 2 9 9 1 QuickSort QuickSort on an input sequence S with n elements consists of three steps: n n n Divide: partition S into two sequences S 1 and S 2 of about
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 informationUCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis
UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Lecture 16 Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/ Lecture 16 Notes Goals for this week Graph basics Types
More informationCurriculum Map Grade(s): Subject: AP Computer Science
Curriculum Map Grade(s): 11-12 Subject: AP Computer Science (Semester 1 - Weeks 1-18) Unit / Weeks Content Skills Assessments Standards Lesson 1 - Background Chapter 1 of Textbook (Weeks 1-3) - 1.1 History
More informationCSE373: Data Structure & Algorithms Lecture 18: Comparison Sorting. Dan Grossman Fall 2013
CSE373: Data Structure & Algorithms Lecture 18: Comparison Sorting Dan Grossman Fall 2013 Introduction to Sorting Stacks, queues, priority queues, and dictionaries all focused on providing one element
More informationAlgorithms Lab 3. (a) What is the minimum number of elements in the heap, as a function of h?
Algorithms Lab 3 Review Topics covered this week: heaps and heapsort quicksort In lab exercises (collaboration level: 0) The in-lab problems are meant to be be solved during the lab and to generate discussion
More informationCS2 Algorithms and Data Structures Note 1
CS2 Algorithms and Data Structures Note 1 Analysing Algorithms This thread of the course is concerned with the design and analysis of good algorithms and data structures. Intuitively speaking, an algorithm
More informationAlgorithm Performance Factors. Memory Performance of Algorithms. Processor-Memory Performance Gap. Moore s Law. Program Model of Memory I
Memory Performance of Algorithms CSE 32 Data Structures Lecture Algorithm Performance Factors Algorithm choices (asymptotic running time) O(n 2 ) or O(n log n) Data structure choices List or Arrays Language
More informationIntroduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.
Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Practice Final Practice Final Do not open this exam booklet until
More informationIntroduction to Programming I
Still image from YouTube video P vs. NP and the Computational Complexity Zoo BBM 101 Introduction to Programming I Lecture #09 Development Strategies, Algorithmic Speed Erkut Erdem, Aykut Erdem & Aydın
More informationMPATE-GE 2618: C Programming for Music Technology. Syllabus
MPATE-GE 2618: C Programming for Music Technology Instructor Dr. Schuyler Quackenbush schuyler.quackenbush@nyu.edu Lab Teaching Assistant TBD Description Syllabus MPATE-GE 2618: C Programming for Music
More informationCOT 5407: Introduction to Algorithms. Giri Narasimhan. ECS 254A; Phone: x3748
COT 5407: Introduction to Algorithms Giri Narasimhan ECS 254A; Phone: x3748 giri@cis.fiu.edu http://www.cis.fiu.edu/~giri/teach/5407s17.html https://moodle.cis.fiu.edu/v3.1/course/view.php?id=1494 8/28/07
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 informationCSE373: Data Structure & Algorithms Lecture 23: More Sorting and Other Classes of Algorithms. Catie Baker Spring 2015
CSE373: Data Structure & Algorithms Lecture 23: More Sorting and Other Classes of Algorithms Catie Baker Spring 2015 Admin No class on Monday Extra time for homework 5 2 Sorting: The Big Picture Surprising
More informationAlgorithms and Data Structures
Algorithms and Data Structures Spring 2019 Alexis Maciel Department of Computer Science Clarkson University Copyright c 2019 Alexis Maciel ii Contents 1 Analysis of Algorithms 1 1.1 Introduction.................................
More informationAlgorithms Exam TIN093/DIT600
Algorithms Exam TIN093/DIT600 Course: Algorithms Course code: TIN 093 (CTH), DIT 600 (GU) Date, time: 22nd October 2016, 14:00 18:00 Building: M Responsible teacher: Peter Damaschke, Tel. 5405 Examiner:
More informationCSE 373: Data Structures and Algorithms
CSE 373: Data Structures and Algorithms Lecture 20: More Sorting Instructor: Lilian de Greef Quarter: Summer 2017 Today: More sorting algorithms! Merge sort analysis Quicksort Bucket sort Radix sort Divide
More informationCPSC 320: Intermediate Algorithm Design and Analysis. Tutorial: Week 3
CPSC 320: Intermediate Algorithm Design and Analysis Author: Susanne Bradley Tutorial: Week 3 At the time of this week s tutorial, we were approaching the end of our stable matching unit and about to start
More informationCS61BL. Lecture 5: Graphs Sorting
CS61BL Lecture 5: Graphs Sorting Graphs Graphs Edge Vertex Graphs (Undirected) Graphs (Directed) Graphs (Multigraph) Graphs (Acyclic) Graphs (Cyclic) Graphs (Connected) Graphs (Disconnected) Graphs (Unweighted)
More informationTHE DESIGN AND ANALYSIS OF COMPUTER ALGORITHMS
2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. THE DESIGN AND ANALYSIS OF COMPUTER ALGORITHMS Alfred V. Aho Bell
More informationLecture 18. What we ve done and what s to come
Lecture 18 What we ve done and what s to come Today What just happened? A whirlwind tour of CS161 What s next? A few gems from future algorithms classes It s been a fun ride What have we learned? 17 lectures
More informationCSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer
CSC 8301- Design and Analysis of Algorithms Lecture 5 Decrease and Conquer Algorithm Design Technique Decrease-and-Conquer This algorithm design technique is based on exploiting a relationship between
More informationVE281 Data Structures and Algorithms. Introduction and Asymptotic Algorithm Analysis
VE281 Data Structures and Algorithms Introduction and Asymptotic Algorithm Analysis Time and Location Time: Tuesday 10:00-11:40 am, Thursday 10:00-11:40 am. Location: Dong Xia Yuan 200 2 Instructor Weikang
More information15-451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015
15-451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015 Dynamic Programming is a powerful technique that allows one to solve many different types
More informationWhat next? CSE332: Data Abstractions Lecture 20: Parallel Prefix and Parallel Sorting. The prefix-sum problem. Parallel prefix-sum
What next? CSE332: Data Abstractions Lecture 20: Parallel Prefix and Parallel Sorting Dan Grossman Spring 2010 Done: Simple ways to use parallelism for counting, summing, finding Even though in practice
More informationHomework Assignment #3. 1 (5 pts) Demonstrate how mergesort works when sorting the following list of numbers:
CISC 4080 Computer Algorithms Spring, 2019 Homework Assignment #3 1 (5 pts) Demonstrate how mergesort works when sorting the following list of numbers: 6 1 4 2 3 8 7 5 2 Given the following array (list),
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 8: Sorting http://courses.cs.cornell.edu/cs2110/2018su Lecture 7 Recap 2 Introduced a formal notation for analysing the
More informationJana Kosecka. Linear Time Sorting, Median, Order Statistics. Many slides here are based on E. Demaine, D. Luebke slides
Jana Kosecka Linear Time Sorting, Median, Order Statistics Many slides here are based on E. Demaine, D. Luebke slides Insertion sort: Easy to code Fast on small inputs (less than ~50 elements) Fast on
More informationMergesort again. 1. Split the list into two equal parts
Quicksort Mergesort again 1. Split the list into two equal parts 5 3 9 2 8 7 3 2 1 4 5 3 9 2 8 7 3 2 1 4 Mergesort again 2. Recursively mergesort the two parts 5 3 9 2 8 7 3 2 1 4 2 3 5 8 9 1 2 3 4 7 Mergesort
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 informationCSE 373: Data Structures and Algorithms
CSE 373: Data Structures and Algorithms Lecture 19: Comparison Sorting Algorithms Instructor: Lilian de Greef Quarter: Summer 2017 Today Intro to sorting Comparison sorting Insertion Sort Selection Sort
More informationCoventry University
122OM: oventry University david.croft@coventry.ac.uk 2017 Overview 1 2 3 4 5 6 7 Expectations You have all attempted the green odio exercises for this week. Mark % 100 80 60 40 20 122OM results 2016-17
More informationCSC Design and Analysis of Algorithms
CSC : Lecture 7 CSC - Design and Analysis of Algorithms Lecture 7 Transform and Conquer I Algorithm Design Technique CSC : Lecture 7 Transform and Conquer This group of techniques solves a problem by a
More informationSankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment
Class: V - CE Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology Sub: Design and Analysis of Algorithms Analysis of Algorithm: Assignment
More informationECE250: Algorithms and Data Structures Final Review Course
ECE250: Algorithms and Data Structures Final Review Course Ladan Tahvildari, PEng, SMIEEE Professor Software Technologies Applied Research (STAR) Group Dept. of Elect. & Comp. Eng. University of Waterloo
More information/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17
01.433/33 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/2/1.1 Introduction In this lecture we ll talk about a useful abstraction, priority queues, which are
More informationLast week: Breadth-First Search
1 Last week: Breadth-First Search Set L i = [] for i=1,,n L 0 = {w}, where w is the start node For i = 0,, n-1: For u in L i : For each v which is a neighbor of u: If v isn t yet visited: - mark v as visited,
More informationDivide-and-Conquer. Dr. Yingwu Zhu
Divide-and-Conquer Dr. Yingwu Zhu Divide-and-Conquer The most-well known algorithm design technique: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances independently
More informationWelcome to CS 241 Systems Programming at Illinois
Welcome to CS 241 Systems Programming at Illinois Robin Kravets Copyright : University of Illinois CS 241 Staff 1 The Team Robin Kravets Office: 3114 SC rhk@illinois.edu TAs Wade Fagen, Farhana Ashraf,
More informationComputer Science Approach to problem solving
Computer Science Approach to problem solving If my boss / supervisor / teacher formulates a problem to be solved urgently, can I write a program to efficiently solve this problem??? Polynomial-Time Brute
More informationLECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS
Department of Computer Science University of Babylon LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS By Faculty of Science for Women( SCIW), University of Babylon, Iraq Samaher@uobabylon.edu.iq
More informationCSC Design and Analysis of Algorithms. Lecture 7. Transform and Conquer I Algorithm Design Technique. Transform and Conquer
// CSC - Design and Analysis of Algorithms Lecture 7 Transform and Conquer I Algorithm Design Technique Transform and Conquer This group of techniques solves a problem by a transformation to a simpler/more
More informationIntroduction to Computers and Programming. Today
Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 10 April 8 2004 Today How to determine Big-O Compare data structures and algorithms Sorting algorithms 2 How to determine Big-O Partition
More information