May 2007Sorting NetworksSlide 1 Sorting Networks A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.

Slides:



Advertisements
Similar presentations
II Extreme Models Study the two extremes of parallel computation models: Abstract SM (PRAM); ignores implementation issues Concrete circuit model; incorporates.
Advertisements

Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Apr. 2007SatisfiabilitySlide 1 Satisfiability A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Nov. 2005Math in ComputersSlide 1 Math in Computers A Lesson in the “Math + Fun!” Series.
May 2005Special NumbersSlide 1 Special Numbers A Lesson in the “Math + Fun!” Series.
Traffic Flow Analysis Steve Prevette Burnt Hills & Big Flats RR Pasco WA Fluor Hanford City University.
Apr. 2007Mathematical IllusionsSlide 1 Mathematical Illusions A Lesson in the “Math + Fun!” Series.
May 2015String MatchingSlide 1 String Matching A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
May 2015Binary SearchSlide 1 Binary Search A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
May 2007Task SchedulingSlide 1 Task Scheduling A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Apr. 2015SatisfiabilitySlide 1 Satisfiability A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
June 2007Malfunction DiagnosisSlide 1 Malfunction Diagnosis A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Apr. 2007Placement and RoutingSlide 1 Placement and Routing A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Mar. 2015Easy, Hard, Impossible!Slide 1 Easy, Hard, Impossible! A Lecture in CE Freshman Seminar Series: Puzzling Problems in Computer Engineering.
Dec. 2004Math CrosswordsSlide 1 Math Crosswords A Lesson in the “Math + Fun!” Series.
Apr. 2007Easy, Hard, Impossible!Slide 1 Easy, Hard, Impossible! A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
May 2007Binary SearchSlide 1 Binary Search A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Mesh connected networks. Sorting algorithms Efficient Parallel Algorithms COMP308.
HandoutMay 2007Sorting Networks A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
May 2012Malfunction DiagnosisSlide 1 Malfunction Diagnosis A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
May 2012Task SchedulingSlide 1 Task Scheduling A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Apr. 2015Placement and RoutingSlide 1 Placement and Routing A Lecture in CE Freshman Seminar Series: Puzzling Problems in Computer Engineering.
May 2007String MatchingSlide 1 String Matching A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
HandoutLecture 9Sorting Networks Rearranging Trains BADC Stub or lead BADC Sorted order BADC Stub or lead Stack or LIFO data structure in CE BADC Stub.
Router Architectures An overview of router architectures.
FIREWALL TECHNOLOGIES Tahani al jehani. Firewall benefits  A firewall functions as a choke point – all traffic in and out must pass through this single.
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Switching Techniques Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
Computer Networks: Switching and Queuing Ivan Marsic Rutgers University Chapter 4 – Switching and Queuing Delay Models.
Neural Networks in Computer Science n CS/PY 231 Lab Presentation # 1 n January 14, 2005 n Mount Union College.
May 2015Sorting NetworksSlide 1 Sorting Networks A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
Sorting: Parallel Compare Exchange Operation A parallel compare-exchange operation. Processes P i and P j send their elements to each other. Process P.
Antenna Arrays and Automotive Applications
CE2303 Railway Engineering
CMSC201 Computer Science I for Majors Lecture 19 – Recursion (Continued) Prof. Katherine Gibson Prof. Jeremy Dixon Based on slides from UPenn’s.
Lecture 2 Algorithm Analysis
Exams hints The exam will cover the same topics covered in homework. If there was no homework problem on the topic, then there will not be any exam question.
Lecture 4 Sorting Networks
ECE 3301 General Electrical Engineering
Mesh connected networks. Sorting algorithms
7.1 What is a Sorting Network?
COSC160: Data Structures Binary Trees
Mathematical Illusions
IST 220 Lectures for: Dec. 8, 2009 Dec. 10, 2009
CS4470 Computer Networking Protocols
NET323 D: Network Protocols
Recommender Systems A Lecture in the Freshman Seminar Series:
Chapter 14 User Datagram Protocol (UDP)
3D Models from 2D Images A Lecture in the Freshman Seminar Series:
Satisfiability A Lecture in CE Freshman Seminar Series:
NET323 D: Network Protocols
Recommender Systems A Lecture in the Freshman Seminar Series:
Pipelined Computations
Easy, Hard, Impossible! A Lecture in CE Freshman Seminar Series:
Data Structures and Algorithms for Information Processing
Network Systems and Throughput Preservation
Placement and Routing A Lecture in CE Freshman Seminar Series:
Sorting Networks A Lecture in CE Freshman Seminar Series:
3D Models from 2D Images A Lecture in the Freshman Seminar Series:
Easy, Hard, Impossible! A Lecture in CE Freshman Seminar Series:
Malfunction Diagnosis
Last Class We Covered Recursion Stacks Parts of a recursive function:
Binary Search A Lecture in CE Freshman Seminar Series:
Computer Networks: Switching and Queuing
Mathematical Illusions
CSC321: Neural Networks Lecture 11: Learning in recurrent networks
Task Scheduling A Lecture in CE Freshman Seminar Series:
Switching Chapter 2 Slides Prepared By: -
WJEC GCSE Computer Science
Presentation transcript:

May 2007Sorting NetworksSlide 1 Sorting Networks A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering

May 2007Sorting NetworksSlide 2 About This Presentation EditionReleasedRevised FirstMay 2007 This presentation belongs to the lecture series entitled “Ten Puzzling Problems in Computer Engineering,” devised for a ten-week, one-unit, freshman seminar course by Behrooz Parhami, Professor of Computer Engineering at University of California, Santa Barbara. The material can be used freely in teaching and other educational settings. Unauthorized uses, including any use for financial gain, are prohibited. © Behrooz Parhami

May 2007Sorting NetworksSlide 3 Railroad Tracks and Switches

May 2007Sorting NetworksSlide 4 Railroad Yards Have Many Tracks and Switches

May 2007Sorting NetworksSlide 5 Rearranging Trains BADC Stub or lead BADC Sorted order BADC Stub or lead Stack or LIFO data structure in CE BADC Stub or lead Question: Is there an ordering that cannot be sorted using a stub? Answer: Yes, if engine muse do the movingSorting algorithm BADC Siding Queue or FIFO BADC Track Train cars Engine

May 2007Sorting NetworksSlide 6 Rearrangement with Change of Direction BADC Turnaround loop BADC What types of sorting are possible with a turnaround loop? A wye? BADC Wye B A D C Configuration after the first few steps in sorting the train Complete the sorting process, assuming that it is okay for the engine to end up behind the train

May 2007Sorting NetworksSlide 7 Delivering Train Cars in a Specific Order 1 BADC 2 3 Cars in the train below have been sorted according to their delivery points. However, it is still nontrivial to deposit car A in stub 1, car B in stub 2, and car C in siding 3. Cars can be pulled or pushed by the engine. 1 C 2 3 BAD 1 C 2 3 BA D Is there a better initial ordering of the cars for the deliveries in this puzzle?

May 2007Sorting NetworksSlide 8 Train Passing Puzzle The trains below must pass each other using a siding that can hold only one car or one engine. Show how this can be done. BA21BA21B21 A B21 A 2 1 A B 2A B 1

May 2007Sorting NetworksSlide 9 Fast Combining or Reordering of Train Cars Forming multiple trains from incoming cars BADCBADC Train reordering via a set of stubs Cars are pushed or pulled by an engine Alternatively, movement in one direction may be achieved via sloped rails Switches used to be adjusted manually, but nowadays, electronic control is used

May 2007Sorting NetworksSlide Track 1 Track 2 Track 3 Track 4 Sorting Train Cars in Parallel Compare-exchange Unconditional exchange Target track The net in stick diagram schematic Track 1 Track 2 Track 3 Track Is adding this compare-exchange element sufficient for producing a valid sorting network?

May 2007Sorting NetworksSlide 11 Validating a Sorting Network Stick diagram schematic b a d c Track 1 Track 2 Track 3 Track 4 min(a, b) max(a, b) min(c, d) max(c, d) min(a, b, c, d) max(a, b, c, d) ???? In the example above, it was fairly easy to show the validity of the sorting network. Generally, it is much more difficult How would one establish the validity of this 16-input sorting net? More importantly, how does one come up with this design in the first place?

May 2007Sorting NetworksSlide 12 The Zero-One Principle A sorting net built of comparators is valid if it correctly sorts all 0-1 sequences So, we can validate a sorting network using 2 n rather than n! input patterns n = 12: 2 n = 4096, n! = 479,001,600 (thousands vs. half a billion)

May 2007Sorting NetworksSlide 13 A 16-Input Sorting Network Use 4-input sorters, follow by (4, 4)-mergers, and end with an (8, 8)-merger Using the 0-1 principle, we can validate this network via tests sorter tests(4, 4)-merger tests(8, 8)-merger tests

May 2007Sorting NetworksSlide 14 Insertion Sort and Selection Sort Fig. 7.8 Sorting network based on insertion sort or selection sort. C(n) = n(n – 1)/2 D(n ) = 2n – 3 Cost  Delay =  (n 3 ) Insertion sortSelection sort

May 2007Sorting NetworksSlide 15 The Best Sorting Networks Cost  Delay = 29  9 = 261Cost  Delay = 31  7 = 217 The most cost-effective n-input sorting network may be neither the fastest design, nor the lowest-cost design Criterion 1: The number of sticks or compare-exchange blocks (cost) Criterion 2: The number of compare-exchanges in sequence (delay) Criterion 3: The product of cost and delay (cost-effectiveness) Which 10-input sorting network is better? Cost = 29Cost = 31Delay = 9Delay = 7

May 2007Sorting NetworksSlide 16 Electronic Sorting Networks Electronic sorting networks are built of 2-sorters, building blocks that can sort two inputs Applications of sorting networks: Directing information packets to their destinations in a network router Connecting n processors to n memory modules in a parallel computer abab min(a, b) max(a, b)