Vorlesung Datenstrukturen und Algorithmen Letzte Vorlesung Felix Friedrich, Map/Reduce Sorting Networks Prüfung
|
|
- Tracey Jennings
- 5 years ago
- Views:
Transcription
1 Vorlesung Datenstrukturen und Algorithmen Letzte Vorlesung 28 Felix Friedrich, Map/Reduce Sorting Networks Prüfung
2 MAP AND REDUCE AND MAP/REDUCE 2
3 Summing a Vector Accumulator Divide and conquer Q: Why is the result the same? A: associativity: (a+b) + c = a + (b+c) 3
4 Summing a Vector Divide and conquer Is this correct? Only if the operation is commutative: a + b = b + a 4
5 Reductions Simple examples: sum, max Reductions over programmer-defined operations operation properties (associativity / commutativity) define the correct executions supported in most parallel languages / frameworks powerful construct 5
6 C++ Reduction std::accumulate (requires associativity) std::reduce (requires commutativity, from C++7, can specify execution policy) std::vector<double> v;... double result = std::accumulate( v.begin(), v.end(),., [](double a, double b){return a + b;} ); 6
7 Elementwise Multiplication Map Multiply x x x x x x x x + 7
8 Scalar Product Map Multiply x x x x x x x x Reduce + Accumulate
9 C++ Scalar Product (map + reduce) // example data std::vector<double> v(24,.5); auto v2 = v; std::vector<double> result(24); // map std::transform(v.begin(), v.end(), v2.begin(), result.begin(), [](double a, double b){return a*b;}); // reduce double value = std::accumulate(result.begin(), result.end(),.); // = 256 9
10 Map & Reduce = MapReduce Combination of two parallelisation patterns result = f in f in 2 f(in 3 ) f(in 4 ) f = map = reduce (associative) Examples: numerical reduction, word count in document, (word, document) list, maximal temperature per month over 5 years (etc.)
11 Motivating Example Maximal Temperature per Month for 5 years Input: 5 * 365 Days / Temperature pairs Output: 2 Months / Max Temperature pairs Assume we (you and me) had to do this together. How would we distribute the work? What is the generic model? How would we be ideally prepared for different reductions (min, max, avg)?
12 Maximal Temperature per Month: Map data / 5 / 8 / / 2 3 / /2 5/9 5/2... 7/28 7/ /4 3/8... each map-process gets day/temperature pairs and maps them to month/temperature pairs... 2
13 Maximal Temperature per Month: Shuffle / -5 / -8 / / 2 3 / /2 5/9 5/2... 7/28 7/ /4 3/ Jan Feb Mar April Dec / -5 / -8 / / 3 2 / 4 2 / / 3 3 / 4 3 / / 23 4 / 24 4 / data gets sorted / shuffled by month 2 / 2 / -2 2/
14 Maximal Temperature per Month: Reduce Jan Feb Mar April Dec / -5 / -8 / / 3 2 / 4 2 / / 3 3 / 4 3 / / 23 4 / 24 4 / / 2 / -2 2/ 2 each reduce process gets its own... month with values and applies the reduction (here: max value) to it Jan Feb Mar April Dec
15 Map/Reduce A strategy for implementing parallel algorithms. map: A master worker takes the problem input, divides it into smaller sub-problems, and distributes the sub-problems to workers (threads). reduce: The master worker collects sub-solutions from the workers and combines them in some way to produce the overall answer. 5
16 Map/Reduce Frameworks and tools have been written to perform map/reduce. MapReduce framework by Google Hadoop framework by Yahoo! related to the ideas of Big Data and Cloud Computing also related to functional programming (and actually not that new) and available with the Streams concept in Java (>=8) Map and reduce are user-supplied plug-ins, the rest is provided by the frameworks. Jeffrey Dean and Sanjay Ghemawat. 28. MapReduce: simplified data processing on large clusters. Commun. ACM 5, (January 28), 7-3. DOI=.45/
17 MapReduce on Clusters You may have heard of Google s map/reduce or Amazon's Hadoop Idea: Perform maps/reduces on data using many machines The system takes care of distributing the data and managing fault tolerance You just write code to map one element (key-value part) and reduce elements (key-value pairs) to a combined result Separates how to do recursive divide-and-conquer from what computation to perform Old idea in higher-order functional programming transferred to large-scale distributed computing 7
18 Example Count word occurences in a very large file File = GBytes how are you today do you like the weather outside I do I do I wish you the very best for your exams. 8
19 Mappers key/value pairs (e.g. position / string) part <, "how are you today"> <5, "do you like..."> mapper huge file part 2 <35, "I do"> <39, "I do"> mapper 2 DISTRIBUTED part 3 <43, "I wish you the very best"> <7, "for your exams"> mapper 3 9
20 Mappers input output key/value pairs (e.g. position / string) key/value pairs (word, count) <, "how are you today"> <5, "do you like..."> mapper <"how",> <"are",> <"you",>... <35, "I do"> <39, "I do"> mapper 2 <"I",> <"do",> <"I",> <"do",> <43, "I wish you the very best"> <7, "for your exams"> mapper 3 <"I",> <"wish",> <"you",>... 2
21 Shuffle / Sort key/value pairs (word, count) unique key/value pairs (shuffled) (word, counts) mapper mapper 2 <"how",> <"are",> <"you",>... <"I",> <"do",> <"I",> <"do",> <"are",> <"best",>... <"do",,,> <"for",>... reducer reducer 2 DISTRIBUTED mapper 3 <"I",> <"wish",> <"you",>... 2
22 Reduce input unique key/value pairs (shuffled) (word, counts) output target file(s) <"are",> <"best",>... reducer are best you 3... <"do",,,> <"for",>... reducer 2 do 3 for I
23 SORTING NETWORKS 23
24 Lower bound on sorting Horrible algorithms: Ω(n 2 ) Bogo Sort Stooge Sort Simple algorithms: O(n 2 ) Insertion sort Selection sort Bubble Sort Shell sort Fancier algorithms: O(n log n) Heap sort Merge sort Quick sort (avg) Comparison lower bound: (n log n) 24
25 Comparator x y < min(x,y) max(x,y) x min(x,y) shorter notation: y max(x,y) 25
26 void compare(int&a, int&b, boolean dir) { if (dir==(a,b)){ std::swap(a,b); } } a b >< a b 26
27 Sorting Networks
28 Sorting Networks are Oblivious (and Redundant) Oblivious comparison tree :2 x x 2 x 3 x 4 3:4 3:4 :3 :4 2:3 2:4 2:4 2:4 2:3 2:3 :4 :4 :3 :3 2:3 4:3 2: 4: 2:4 3:4 2: 3: :3 4:3 :2 4:2 :4 3:4 :2 3:2 redundant cases 28
29 Recursive Construction : Insertion x x 2 x 3... sorting network x n x n x n+ 29
30 Recursive Construction: Selection x x 2 x sorting network... x n x n x n+ 3
31 Applied recursively.. insertion sort bubble sort with parallelism: insertion sort = bubble sort! 3
32 Question How many steps does a computer with infinite number of processors (comparators) require in order to sort using parallel bubble sort? Answer: 2n 3 Can this be improved? How many comparisons? Answer: (n-) n/2 How many comparators are required (at a time)? Answer: n/2 Reusable comparators: n- 32
33 Improving parallel Bubble Sort Odd-Even Transposition Sort:
34 void oddeventranspositionsort(std::vector<t>& v, boolean dir) { for (int i = ; i<v.size(); ++i){ for (int j = i % 2; j+<n; j+=2) compare(v[i],v[j],dir); } } 34
35 Improvement? Same number of comparators (at a time) Same number of comparisons But less parallel steps (depth): n In a massively parallel setup, bubble sort is thus not too bad. But it can go better... 35
36 Parallel sorting depth = 4 depth = 3 Prove that the two networks above sort four numbers. Easy? 36
37 Zero-one-principle Theorem: If a network with n input lines sorts all 2 n sequences of s and s into non-decreasing order, it will sort any arbitrary sequence of n numbers in nondecreasing order. 37
38 Proof Assume a monotonic function f(x) with f8 x2 3 f(y) 5 9 whenever 5 8 9x 2 3 y and Argue: a network If x is sorted Nby that a network sorts. N Let N transform (x, x 2,, x n ) into then also any monotonic function of x. (y, y 2,, y n ), then it also transforms (f(x - 4 ), f(x 99 2 ), 9, f(x - 2 n )) 4 into 9 99 (f(y ), f(y 2 ),, f(y n )). Assume y i > y i+ for some i, then consider the monotonic function Show: If x is not sorted by the network, then there is a monotonic function f that maps x to s and s and f(x) is not sorted by the network f(x) = ቊ, if x < y i, if x y i N converts x not sorted by N there is an f x, n not sorted by N (f(x ), f(x 2 ),, f(x n )) into f y, f(y 2, f y i, f y i+,, f(y n )) f sorted by N for all f, n x sorted by N for all x 38
39 Proof Assume a monotonic function f(x) with f x f(y) whenever x y and a network N that sorts. Let N transform (x, x 2,, x n ) into (y, y 2,, y n ), then it also transforms (f(x ), f(x 2 ),, f(x n )) into (f(y ), f(y 2 ),, f(y n )). Assume y i > y i+ for some i, then consider the monotonic function N converts f(x) = ቊ, if x < y i, if x y i All comparators must act in the same way for the f(x i ) as they do for the x i (f(x ), f(x 2 ),, f(x n )) into f y, f(y 2, f y i, f y i+,, f(y n )) 39
40 Bitonic Sort Bitonic (Merge) Sort is a parallel algorithm for sorting If enough processors are available, sort breaks the lower bound on sorting for comparison sort algorithm Asymptotic Runtime of O n log 2 n (sequential execution) Very good asymptotic runtime in the parallel case (as we'll see below). Worst = Average = Best case 4
41 Bitonic Sequence (x, x 2,, x n ) is, if it can be circularly shifted such that it is first monotonically increasing and then monontonically decreasing. (, 2, 3, 4, 5, 3,, ) (4, 3, 2,, 2, 4, 6, 5) 4
42 Bitonic - Sequences i j k i j k 42
43 The Half-Cleaner void halfclean(std::vector<t>& a, int lo, int n, boolean dir){ for (int i=lo; i<lo+n/2; i++) compare(a[i],a[i+n/2], dir); } clean 43
44 The Half-Cleaner void halfclean(std::vector<t>& a, int lo, int n, boolean dir){ for (int i=lo; i<lo+n/2; i++) compare(a[i],a[i+n/2], dir); } clean 44
45 Bitonic Split Example + 45
46 Lemma Input: a sequence of s and s, then for the output of the half-cleaner it holds that Upper and lower half is [One of the two halfs is clean (only s or s)] Every number in upper half every number in the lower half 46
47 Proof: All cases top bottom top bottom clean 47
48 top bottom top bottom clean 48
49 top bottom top bottom clean 49
50 top bottom top bottom clean 5
51 The four remaining cases ( ) top bottom top bottom clean top bottom top bottom clean top bottom top bottom clean top bottom top bottom clean 5
52 Construction BitonicToSorted halfclean halfclean halfclean half clean half clean half clean half clean sorted 52
53 Recursive Construction ToSorted(n) halfclean (n) ToSorted (n/2) ToSorted (n/2) 53
54 BitonicToSorted sorts a Bitonic Sequence void ToSorted (std::vector<int>& a, int lo, int n, boolean dir){ if (n>){ halfclean(a, lo, n, dir); } } ToSorted(a, lo, n/2, dir); ToSorted(a, lo+m, n-n/2, dir); halfclean (n) ToSorted (n/2) sorted ToSorted (n/2) 54
55 Bi-Merger sorted sorted sorted reverse sorted bimerge half-cleaner Bi-Merger on two sorted sequences acts like a half-cleaner on a sequence (when one of the sequences is reversed) 55
56 Bi-Merger sorted sorted void bimerge(std::vector<t>& a, int lo, int n, boolean dir){ for (int i=; i<n/2; i++) compare(a[lo+i],a[lo+n-i-], dir); } bimerge Bi-Merger on two sorted sequences acts like a half-cleaner on a sequence (when one of the sequences is reversed) 56
57 Merger Merger 57 bimerge (n) halfclean (n/2) halfclean (n/2) half clean half clean half clean half clean sorted sorted sorted
58 Merger sorted sorted bimerge (n) ToSorted (n/2) ToSorted (n/2) sorted Merger 58
59 BitonicMerge sorts a Halfsorted Sequence void Merge (std::vector<int>& a, int lo, int n, boolean dir){ if (n>){ int m=n/2; } } bimerge(a,lo,n,dir); ToSorted(a, lo, m, dir); sorted ToSorted(a, lo+m, n-m, dir); sorted bimerge ToSorted (n/2) ToSorted (n/2) sorted 59
60 Recursive Construction of a Sorter Sort(n) Sort (n/2) Sort (n/2) Merge (n) 6
61 private void Sort(std::vector&<T> a, int lo, int n, boolean dir){ if (n>){ int m=n/2; Sort(a, lo, m, ASCENDING); } } Sort(a, lo+m, n-m, DESCENDING); Merge(a, lo, n, dir); Sort (n/2) Sort (n/2) Merge (n) 6
62 Example half clean half clean bimerge half clean half clean halfclean half clean half clean half clean half clean bimerge half clean half clean bimerge halfclean half clean half clean Merge(2) Merge(4) Merge (8) 62
63 Merger (8) Example 63 Merger(4) Merger (2) bi-merger half cleaner half cleaner half cleane r half cleane r half cleane r half cleane r bimerger half cleane r half cleane r bimerger half cleane r half cleane r half cleane r half cleane r half cleane r half cleane r
64 Bitonic Merge Sort How many steps? #mergers log n i= log n log 2 i = i= i log 2 = log n (log n + ) 2 = O(log 2 n) #steps / merger 64
65 Zur Prüfung findet statt am von 9: : (2h) Inhalt: Datenstrukturen und Algorithmen, C++ Advanced, Parallel Programming, Hilfsmittel: 4 A4 Seiten, handgeschrieben oder min. Pt Fontsize. Kopieren ist erlaubt aber nicht clever. Handgeschriebenes vom Tablet drucken ist auch erlaubt, wenn dabei die Schrift nicht wesentlich verkleinert wird (in Relation zur sonst üblichen Schreibschrift). 65
66 Vorschlag: Q&A vor der Prüfung. Schulferien ab 6.Juli -- Termin sollte vorher sein. Für Sie: je später desto besser. Vorschlag: +/- 2. Juli. 66
67 Vorbereitung Übungen machen / gemacht haben. [morgen, Freitag. Juni, finden Übungen statt. Besprechung Übung 3.] Können Sie die Vorlesungsinhalte einem Kollegen (ohne Folien) erklären? Alte Prüfungen stehen auf der Webseite zur Verfügung. Die alten Prüfungen von Prof. Widmayer enthalten Material, das nicht behandelt wurde (geometrische Algorithmen, branch-and-bound) Die "neuen" Prüfungen bei mir enthalten Material, das in den Vorlesungen von Widmayer/Püschel nicht behandelt wurden (insbesondere C++ / Parallel Programming) 67
68 Ausschlüsse NICHT Prüfungsstoff sind Details der längeren Beweise (Laufzeit Algorithmus Blum, Analyse Ranomisierter Quicksort, Amortisierte Analyse von Move-To-Front, Beweis Theorem Universelles Hashing, Beweis Fibonacci Zahlen mit Erzeugendenfunktion, Beweis Amortisierte Kosten Fibonacci Heap, Atomare Register / RMW Operationen / Lock Free Programming Hardware Architekturen, Pipelining, Peterson Algorithmus 68
69 Ich bin weiterhin erreichbar unter 69
Sorting Pearson Education, Inc. All rights reserved.
1 19 Sorting 2 19.1 Introduction (Cont.) Sorting data Place data in order Typically ascending or descending Based on one or more sort keys Algorithms Insertion sort Selection sort Merge sort More efficient,
More informationParallel Sorting Algorithms
CSC 391/691: GPU Programming Fall 015 Parallel Sorting Algorithms Copyright 015 Samuel S. Cho Sorting Algorithms Review Bubble Sort: O(n ) Insertion Sort: O(n ) Quick Sort: O(n log n) Heap Sort: O(n log
More informationBig Data Management and NoSQL Databases
NDBI040 Big Data Management and NoSQL Databases Lecture 2. MapReduce Doc. RNDr. Irena Holubova, Ph.D. holubova@ksi.mff.cuni.cz http://www.ksi.mff.cuni.cz/~holubova/ndbi040/ Framework A programming model
More informationCS475 Parallel Programming
CS475 Parallel Programming Sorting Wim Bohm, Colorado State University Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 license. Sorting
More informationCSE373: Data Structures & Algorithms Lecture 22: Parallel Reductions, Maps, and Algorithm Analysis. Kevin Quinn Fall 2015
CSE373: Data Structures & Algorithms Lecture 22: Parallel Reductions, Maps, and Algorithm Analysis Kevin Quinn Fall 2015 Outline Done: How to write a parallel algorithm with fork and join Why using divide-and-conquer
More informationCSC630/CSC730 Parallel & Distributed Computing
CSC630/CSC730 Parallel & Distributed Computing Parallel Sorting Chapter 9 1 Contents General issues Sorting network Bitonic sort Bubble sort and its variants Odd-even transposition Quicksort Other Sorting
More informationLecture 3: Sorting 1
Lecture 3: Sorting 1 Sorting Arranging an unordered collection of elements into monotonically increasing (or decreasing) order. S = a sequence of n elements in arbitrary order After sorting:
More informationAlgorithms & Data Structures 2
Algorithms & Data Structures 2 Introduction WS2017 B. Anzengruber-Tanase (Institute for Pervasive Computing, JKU Linz) (Institute for Pervasive Computing, JKU Linz) CONTACT Vorlesung DI Bernhard Anzengruber,
More informationThe MapReduce Framework
The MapReduce Framework In Partial fulfilment of the requirements for course CMPT 816 Presented by: Ahmed Abdel Moamen Agents Lab Overview MapReduce was firstly introduced by Google on 2004. MapReduce
More informationCOMP Data Structures
COMP 2140 - Data Structures Shahin Kamali Topic 5 - Sorting University of Manitoba Based on notes by S. Durocher. COMP 2140 - Data Structures 1 / 55 Overview Review: Insertion Sort Merge Sort Quicksort
More informationMapReduce: A Programming Model for Large-Scale Distributed Computation
CSC 258/458 MapReduce: A Programming Model for Large-Scale Distributed Computation University of Rochester Department of Computer Science Shantonu Hossain April 18, 2011 Outline Motivation MapReduce Overview
More informationCSE 373 NOVEMBER 8 TH COMPARISON SORTS
CSE 373 NOVEMBER 8 TH COMPARISON SORTS ASSORTED MINUTIAE Bug in Project 3 files--reuploaded at midnight on Monday Project 2 scores Canvas groups is garbage updated tonight Extra credit P1 done and feedback
More informationChapter 19. Sorting Networks Model of Computation. By Sariel Har-Peled, December 17,
Chapter 19 Sorting Networks By Sariel Har-Peled, December 17, 2012 1 19.1 Model of Computation It is natural to ask if one can perform a computational task considerably faster by using a different architecture
More informationParallel Systems Course: Chapter VIII. Sorting Algorithms. Kumar Chapter 9. Jan Lemeire ETRO Dept. November Parallel Sorting
Parallel Systems Course: Chapter VIII Sorting Algorithms Kumar Chapter 9 Jan Lemeire ETRO Dept. November 2014 Overview 1. Parallel sort distributed memory 2. Parallel sort shared memory 3. Sorting Networks
More informationNetwork Algorithms. Distributed Sorting
Network Algorithms Distributed Sorting Stefan Schmid @ T-Labs, 2 Sorting Distributed Sorting Graph with n nodes {v,,v n } and n values. Goal: node vi should store i-th smallest value. v 6 v 2 2 v 3 7 v
More informationSearch Engines Chapter 2 Architecture Felix Naumann
Search Engines Chapter 2 Architecture 28.4.2009 Felix Naumann Overview 2 Basic Building Blocks Indexing Text Acquisition iti Text Transformation Index Creation Querying User Interaction Ranking Evaluation
More informationParallel Systems Course: Chapter VIII. Sorting Algorithms. Kumar Chapter 9. Jan Lemeire ETRO Dept. Fall Parallel Sorting
Parallel Systems Course: Chapter VIII Sorting Algorithms Kumar Chapter 9 Jan Lemeire ETRO Dept. Fall 2017 Overview 1. Parallel sort distributed memory 2. Parallel sort shared memory 3. Sorting Networks
More informationThe MapReduce Abstraction
The MapReduce Abstraction Parallel Computing at Google Leverages multiple technologies to simplify large-scale parallel computations Proprietary computing clusters Map/Reduce software library Lots of other
More informationIntroduction to MapReduce. Adapted from Jimmy Lin (U. Maryland, USA)
Introduction to MapReduce Adapted from Jimmy Lin (U. Maryland, USA) Motivation Overview Need for handling big data New programming paradigm Review of functional programming mapreduce uses this abstraction
More informationIntroduction to MapReduce
Introduction to MapReduce April 19, 2012 Jinoh Kim, Ph.D. Computer Science Department Lock Haven University of Pennsylvania Research Areas Datacenter Energy Management Exa-scale Computing Network Performance
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 informationSorting. Dr. Baldassano Yu s Elite Education
Sorting Dr. Baldassano Yu s Elite Education Last week recap Algorithm: procedure for computing something Data structure: system for keeping track for information optimized for certain actions Good algorithms
More informationMap Reduce Group Meeting
Map Reduce Group Meeting Yasmine Badr 10/07/2014 A lot of material in this presenta0on has been adopted from the original MapReduce paper in OSDI 2004 What is Map Reduce? Programming paradigm/model for
More informationModern and Lucid C++ for Professional Programmers. Week 15 Exam Preparation. Department I - C Plus Plus
Department I - C Plus Plus Modern and Lucid C++ for Professional Programmers Week 15 Exam Preparation Thomas Corbat / Prof. Peter Sommerlad Rapperswil, 08.01.2019 HS2018 Prüfung 2 Durchführung Mittwoch
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 informationCS6030 Cloud Computing. Acknowledgements. Today s Topics. Intro to Cloud Computing 10/20/15. Ajay Gupta, WMU-CS. WiSe Lab
CS6030 Cloud Computing Ajay Gupta B239, CEAS Computer Science Department Western Michigan University ajay.gupta@wmich.edu 276-3104 1 Acknowledgements I have liberally borrowed these slides and material
More informationTaking Stock. IE170: Algorithms in Systems Engineering: Lecture 5. The Towers of Hanoi. Divide and Conquer
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 5 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 24, 2007 Last Time In-Place, Out-of-Place Count
More informationLecture 11 Parallel Computation Patterns Reduction Trees
ECE408 Applied Parallel Programming Lecture 11 Parallel Computation Patterns Reduction Trees 1 Objective To master Reduction Trees, arguably the most widely used parallel computation pattern Basic concept
More informationIntroduction to MapReduce. Adapted from Jimmy Lin (U. Maryland, USA)
Introduction to MapReduce Adapted from Jimmy Lin (U. Maryland, USA) Motivation Overview Need for handling big data New programming paradigm Review of functional programming mapreduce uses this abstraction
More informationCSE Lecture 11: Map/Reduce 7 October Nate Nystrom UTA
CSE 3302 Lecture 11: Map/Reduce 7 October 2010 Nate Nystrom UTA 378,000 results in 0.17 seconds including images and video communicates with 1000s of machines web server index servers document servers
More informationLecture 8 Parallel Algorithms II
Lecture 8 Parallel Algorithms II Dr. Wilson Rivera ICOM 6025: High Performance Computing Electrical and Computer Engineering Department University of Puerto Rico Original slides from Introduction to Parallel
More informationA Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 2 Analysis of Fork-Join Parallel Programs
A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 2 Analysis of Fork-Join Parallel Programs Dan Grossman Last Updated: January 2016 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/
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 informationSorting. Sorting in Arrays. SelectionSort. SelectionSort. Binary search works great, but how do we create a sorted array in the first place?
Sorting Binary search works great, but how do we create a sorted array in the first place? Sorting in Arrays Sorting algorithms: Selection sort: O(n 2 ) time Merge sort: O(nlog 2 (n)) time Quicksort: O(n
More informationCSE 332: Data Structures & Parallelism Lecture 15: Analysis of Fork-Join Parallel Programs. Ruth Anderson Autumn 2018
CSE 332: Data Structures & Parallelism Lecture 15: Analysis of Fork-Join Parallel Programs Ruth Anderson Autumn 2018 Outline Done: How to use fork and join to write a parallel algorithm Why using divide-and-conquer
More informationO(n): printing a list of n items to the screen, looking at each item once.
UNIT IV Sorting: O notation efficiency of sorting bubble sort quick sort selection sort heap sort insertion sort shell sort merge sort radix sort. O NOTATION BIG OH (O) NOTATION Big oh : the function f(n)=o(g(n))
More informationMore PRAM Algorithms. Techniques Covered
More PRAM Algorithms Arvind Krishnamurthy Fall 24 Analysis technique: Brent s scheduling lemma Techniques Covered Parallel algorithm is simply characterized by W(n) and S(n) Parallel techniques: Scans
More informationSORTING AND SELECTION
2 < > 1 4 8 6 = 9 CHAPTER 12 SORTING AND SELECTION ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016)
More informationAlgorithms and Applications
Algorithms and Applications 1 Areas done in textbook: Sorting Algorithms Numerical Algorithms Image Processing Searching and Optimization 2 Chapter 10 Sorting Algorithms - rearranging a list of numbers
More informationSorting. Riley Porter. CSE373: Data Structures & Algorithms 1
Sorting Riley Porter 1 Introduction to Sorting Why study sorting? Good algorithm practice! Different sorting algorithms have different trade-offs No single best sort for all scenarios Knowing one way to
More informationJava runtime environment windows xp. Java runtime environment windows xp.zip
Java runtime environment 1 6 24 windows xp Java runtime environment 1 6 24 windows xp.zip Java Runtime Environment 1.6.0.24. By Oracle included as part of the Java 2 Runtime Environment, Windows XP 64-bit
More informationSorting Networks. March 2, How much time does it take to compute the value of this circuit?
Sorting Networks March 2, 2005 1 Model of Computation Can we do better by using different computes? Example: Macaroni sort. Can we do better by using the same computers? How much time does it take to compute
More informationCSC 447: Parallel Programming for Multi- Core and Cluster Systems
CSC 447: Parallel Programming for Multi- Core and Cluster Systems Parallel Sorting Algorithms Instructor: Haidar M. Harmanani Spring 2016 Topic Overview Issues in Sorting on Parallel Computers Sorting
More informationDivide and Conquer Algorithms: Advanced Sorting
Divide and Conquer Algorithms: Advanced Sorting (revisit) Properties of Growth-rate functions(1/3) 1. You can ignore low-order terms in an algorithm's growth-rate function. O(n 3 +4n 2 +3n) it is also
More informationSorting Algorithms. Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar
Sorting Algorithms Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar To accompany the text ``Introduction to Parallel Computing'', Addison Wesley, 2003. Topic Overview Issues in Sorting on Parallel
More informationQuicksort (Weiss chapter 8.6)
Quicksort (Weiss chapter 8.6) Recap of before Easter We saw a load of sorting algorithms, including mergesort To mergesort a list: Split the list into two halves Recursively mergesort the two halves Merge
More informationInstructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.
CMSC 341 Fall 2013 Data Structures Final Exam B Name: Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII. /12 TOTAL: /100 Instructions 1. This is a closed-book, closed-notes exam. 2. You
More informationFrequent Item Set using Apriori and Map Reduce algorithm: An Application in Inventory Management
Frequent Item Set using Apriori and Map Reduce algorithm: An Application in Inventory Management Kranti Patil 1, Jayashree Fegade 2, Diksha Chiramade 3, Srujan Patil 4, Pradnya A. Vikhar 5 1,2,3,4,5 KCES
More informationHow to Implement MapReduce Using. Presented By Jamie Pitts
How to Implement MapReduce Using Presented By Jamie Pitts A Problem Seeking A Solution Given a corpus of html-stripped financial filings: Identify and count unique subjects. Possible Solutions: 1. Use
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 informationParallel Computing: MapReduce Jin, Hai
Parallel Computing: MapReduce Jin, Hai School of Computer Science and Technology Huazhong University of Science and Technology ! MapReduce is a distributed/parallel computing framework introduced by Google
More informationSorting (Chapter 9) Alexandre David B2-206
Sorting (Chapter 9) Alexandre David B2-206 Sorting Problem Arrange an unordered collection of elements into monotonically increasing (or decreasing) order. Let S = . Sort S into S =
More informationCSE 332: Analysis of Fork-Join Parallel Programs. Richard Anderson Spring 2016
CSE 332: Analysis of Fork-Join Parallel Programs Richard Anderson Spring 2016 1 New Story: Shared Memory with Threads Threads, each with own unshared call stack and program counter Heap for all objects
More informationClustering Lecture 8: MapReduce
Clustering Lecture 8: MapReduce Jing Gao SUNY Buffalo 1 Divide and Conquer Work Partition w 1 w 2 w 3 worker worker worker r 1 r 2 r 3 Result Combine 4 Distributed Grep Very big data Split data Split data
More informationA Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 2 Analysis of Fork-Join Parallel Programs
A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 2 Analysis of Fork-Join Parallel Programs Steve Wolfman, based on work by Dan Grossman (with small tweaks by Alan Hu) Learning
More informationDeveloping MapReduce Programs
Cloud Computing Developing MapReduce Programs Dell Zhang Birkbeck, University of London 2017/18 MapReduce Algorithm Design MapReduce: Recap Programmers must specify two functions: map (k, v) * Takes
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 informationInformation Coding / Computer Graphics, ISY, LiTH
Sorting on GPUs Revisiting some algorithms from lecture 6: Some not-so-good sorting approaches Bitonic sort QuickSort Concurrent kernels and recursion Adapt to parallel algorithms Many sorting algorithms
More informationDATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305
Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n
More informationCS : Data Structures
CS 600.226: Data Structures Michael Schatz Nov 30, 2016 Lecture 35: Topological Sorting Assignment 10: Due Monday Dec 5 @ 10pm Remember: javac Xlint:all & checkstyle *.java & JUnit Solutions should be
More informationCSE 373 MAY 24 TH ANALYSIS AND NON- COMPARISON SORTING
CSE 373 MAY 24 TH ANALYSIS AND NON- COMPARISON SORTING ASSORTED MINUTIAE HW6 Out Due next Wednesday ASSORTED MINUTIAE HW6 Out Due next Wednesday Only two late days allowed ASSORTED MINUTIAE HW6 Out Due
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 informationMapReduce: Simplified Data Processing on Large Clusters
MapReduce: Simplified Data Processing on Large Clusters Jeffrey Dean and Sanjay Ghemawat OSDI 2004 Presented by Zachary Bischof Winter '10 EECS 345 Distributed Systems 1 Motivation Summary Example Implementation
More informationSorting (Chapter 9) Alexandre David B2-206
Sorting (Chapter 9) Alexandre David B2-206 1 Sorting Problem Arrange an unordered collection of elements into monotonically increasing (or decreasing) order. Let S = . Sort S into S =
More informationClustering Documents. Document Retrieval. Case Study 2: Document Retrieval
Case Study 2: Document Retrieval Clustering Documents Machine Learning for Big Data CSE547/STAT548, University of Washington Sham Kakade April, 2017 Sham Kakade 2017 1 Document Retrieval n Goal: Retrieve
More informationCS 61C: Great Ideas in Computer Architecture. MapReduce
CS 61C: Great Ideas in Computer Architecture MapReduce Guest Lecturer: Justin Hsia 3/06/2013 Spring 2013 Lecture #18 1 Review of Last Lecture Performance latency and throughput Warehouse Scale Computing
More informationMarch 3, George Mason University Sorting Networks. Indranil Banerjee. Parallel Sorting: Hardware Level Parallelism
Sorting George Mason University ibanerje@gmu.edu March 3, 2016 Sorting GMU March 3, 2016 1 / 19 There are mainly two approaches to sorting in parallel: 1 Non-oblivious: Comparisons are data dependent Example:
More informationIS 709/809: Computational Methods in IS Research. Algorithm Analysis (Sorting)
IS 709/809: Computational Methods in IS Research Algorithm Analysis (Sorting) Nirmalya Roy Department of Information Systems University of Maryland Baltimore County www.umbc.edu Sorting Problem Given an
More informationMap-Reduce. John Hughes
Map-Reduce John Hughes The Problem 850TB in 2006 The Solution? Thousands of commodity computers networked together 1,000 computers 850GB each How to make them work together? Early Days Hundreds of ad-hoc
More informationInformation Retrieval
Information Retrieval Assignment 5: Finding Frequent Word Co-Occurrences Patrick Schäfer (patrick.schaefer@hu-berlin.de) Marc Bux (buxmarcn@informatik.hu-berlin.de) Collocation two terms co-occur if they
More informationAnalyze the obvious algorithm, 5 points Here is the most obvious algorithm for this problem: (LastLargerElement[A[1..n]:
CSE 101 Homework 1 Background (Order and Recurrence Relations), correctness proofs, time analysis, and speeding up algorithms with restructuring, preprocessing and data structures. Due Thursday, April
More information(Refer Slide Time: 01.26)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture # 22 Why Sorting? Today we are going to be looking at sorting.
More informationModern and Lucid C++ Advanced for Professional Programmers. Part 0 - Introduction. Department I - C Plus Plus
Department I - C Plus Plus Modern and Lucid C++ Advanced for Professional Programmers Part 0 - Introduction Thomas Corbat / Prof. Peter Sommerlad Rapperswil, 23.2.2018 HS2018 Modul: C++ Advanced (M_CPlA)
More informationCS 445: Data Structures Final Examination: Study Guide
CS 445: Data Structures Final Examination: Study Guide Java prerequisites Classes, objects, and references Access modifiers Arguments and parameters Garbage collection Self-test questions: Appendix C Designing
More informationClustering Documents. Case Study 2: Document Retrieval
Case Study 2: Document Retrieval Clustering Documents Machine Learning for Big Data CSE547/STAT548, University of Washington Sham Kakade April 21 th, 2015 Sham Kakade 2016 1 Document Retrieval Goal: Retrieve
More informationDepartment of Computer Science San Marcos, TX Report Number TXSTATE-CS-TR Clustering in the Cloud. Xuan Wang
Department of Computer Science San Marcos, TX 78666 Report Number TXSTATE-CS-TR-2010-24 Clustering in the Cloud Xuan Wang 2010-05-05 !"#$%&'()*+()+%,&+!"-#. + /+!"#$%&'()*+0"*-'(%,1$+0.23%(-)+%-+42.--3+52367&.#8&+9'21&:-';
More informationCSE 373. Sorting 1: Bogo Sort, Stooge Sort, Bubble Sort reading: Weiss Ch. 7. slides created by Marty Stepp
CSE 373 Sorting 1: Bogo Sort, Stooge Sort, Bubble Sort reading: Weiss Ch. 7 slides created by Marty Stepp http://www.cs.washington.edu/373/ University of Washington, all rights reserved. 1 Sorting sorting:
More information08 A: Sorting III. CS1102S: Data Structures and Algorithms. Martin Henz. March 10, Generated on Tuesday 9 th March, 2010, 09:58
08 A: Sorting III CS1102S: Data Structures and Algorithms Martin Henz March 10, 2010 Generated on Tuesday 9 th March, 2010, 09:58 CS1102S: Data Structures and Algorithms 08 A: Sorting III 1 1 Recap: Sorting
More informationCSE 143 Lecture 16 (B)
CSE 143 Lecture 16 (B) Sorting reading: 13.1, 13.3-13.4 slides created by Marty Stepp http://www.cs.washington.edu/143/ Sorting sorting: Rearranging the values in an array or collection into a specific
More informationDo you remember any iterative sorting methods? Can we produce a good sorting method by. We try to divide and conquer: break into subproblems
MERGESORT 315 Sorting Recursively Do you remember any iterative sorting methods? How fast are they? Can we produce a good sorting method by thinking recursively? We try to divide and conquer: break into
More informationUE Algorithmen und Datenstrukturen 1 UE Praktische Informatik 1. Übung 9. Sorting
UE Algorithmen und Datenstrukturen 1 UE Praktische Informatik 1 Übung 9 Sorting Institut für Pervasive Computing Johannes Kepler Universität Linz Altenberger Straße 69, A-4040 Linz Sorting :: Problem given:
More informationCS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total
CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Please check your tutorial (TUT) section from the list below: TUT 101: F 11:30, MC 4042 TUT 102: M 10:30, MC 4042 TUT 103: M 11:30, MC 4058 TUT 104: F 10:30,
More informationInformatik II. Andreas Bärtschi, Andreea Ciuprina, Felix Friedrich, Patrick Gruntz, Hermann Lehner, Max Rossmannek, Chris Wendler FS 2018
1 Informatik II Übung 5 Andreas Bärtschi, Andreea Ciuprina, Felix Friedrich, Patrick Gruntz, Hermann Lehner, Max Rossmannek, Chris Wendler FS 2018 Heutiges Programm 2 1 Feedback letzte Übung 2 Wiederholung
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 informationCS/COE 1501
CS/COE 1501 www.cs.pitt.edu/~lipschultz/cs1501/ Sorting The sorting problem Given a list of n items, place the items in a given order Ascending or descending Numerical Alphabetical etc. First, we ll review
More informationIntroduction to MapReduce
732A54 Big Data Analytics Introduction to MapReduce Christoph Kessler IDA, Linköping University Towards Parallel Processing of Big-Data Big Data too large to be read+processed in reasonable time by 1 server
More informationMerge Sort. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong
Department of Computer Science and Engineering Chinese University of Hong Kong In this lecture, we will design the merge sort which sorts n elements in O(n log n) time. The algorithm illustrates a technique
More informationChapter 5. The MapReduce Programming Model and Implementation
Chapter 5. The MapReduce Programming Model and Implementation - Traditional computing: data-to-computing (send data to computing) * Data stored in separate repository * Data brought into system for computing
More information7. Sorting I. 7.1 Simple Sorting. Problem. Algorithm: IsSorted(A) 1 i j n. Simple Sorting
Simple Sorting 7. Sorting I 7.1 Simple Sorting Selection Sort, Insertion Sort, Bubblesort [Ottman/Widmayer, Kap. 2.1, Cormen et al, Kap. 2.1, 2.2, Exercise 2.2-2, Problem 2-2 19 197 Problem Algorithm:
More informationMapReduce for Data Intensive Scientific Analyses
apreduce for Data Intensive Scientific Analyses Jaliya Ekanayake Shrideep Pallickara Geoffrey Fox Department of Computer Science Indiana University Bloomington, IN, 47405 5/11/2009 Jaliya Ekanayake 1 Presentation
More informationFaster Sorting Methods
Faster Sorting Methods Chapter 9 Contents Merge Sort Merging Arrays Recursive Merge Sort The Efficiency of Merge Sort Iterative Merge Sort Merge Sort in the Java Class Library Contents Quick Sort The 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 informationMap Reduce & Hadoop Recommended Text:
Map Reduce & Hadoop Recommended Text: Hadoop: The Definitive Guide Tom White O Reilly 2010 VMware Inc. All rights reserved Big Data! Large datasets are becoming more common The New York Stock Exchange
More informationProblem. Input: An array A = (A[1],..., A[n]) with length n. Output: a permutation A of A, that is sorted: A [i] A [j] for all. 1 i j n.
Problem 5. Sorting Simple Sorting, Quicksort, Mergesort Input: An array A = (A[1],..., A[n]) with length n. Output: a permutation A of A, that is sorted: A [i] A [j] for all 1 i j n. 98 99 Selection Sort
More informationTI-No. 4002TI05.doc PAGE NO. : 1/1. Settings after Installation of the Firmware Version 74
TI-No. 4002TI05.doc PAGE NO. : 1/1 DEVELOP Technical Information MODEL NAME : D 4500/5500iD MODEL CODE : 4002/4003 TI-INFO-NO. : 05 DATE : 13.07.2001 SUBJECT : Firmware MSC/Message/IR Version 74 PERFORMANCE
More informationSearching and Sorting
Searching and Sorting Sequential search sequential search: Locates a target value in an array/list by examining each element from start to finish. How many elements will it need to examine? Example: Searching
More information... Chair of Mobile Business & Multilateral Security. Lecture 14 Business Informatics 2 (PWIN) Q&A SS 2017
Lecture 14 Business Informatics 2 (PWIN) Q&A SS 2017 Prof. Dr. Kai Rannenberg Akos Grosz, M.Sc. Christopher Schmitz, M.Sc. www.m-chair.de Chair of Mobile Business & Multilateral Security Jenser (Flickr.com)
More informationJeffrey D. Ullman Stanford University
Jeffrey D. Ullman Stanford University for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for third-party components of this work must
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 informationCMSC132, Practice Questions
CMSC132, Practice Questions Notice the final exam can include material not covered by the practice questions. You should practice beyond what is covered in this document. Although solutions will not be
More information