CSE465, Spring 2009 March 16 1
|
|
- Nicholas Boone
- 6 years ago
- Views:
Transcription
1 CSE465, Spring 2009 March 16 1 Bucket sort Bucket sort has two meanings. One is similar to that of Counting sort that is described in the book. We assume that every entry to be sorted is in the set {0, 1,..., m 1}. We sort array fragment < A,0, n >using array of buckets B[m]. Bucket_sort(A,n,B,m) { // distribution for (i = 0; i < m; i++) place A[i] in bucket B[A[i]]; // collection for (i = j = 0; j < m; j++ ) { while (B[j] is empty) x = removed from B[j], A[i++] = x; } }
2 CSE465, Spring 2009 March 16 2 Example B[0] B[1] B[2] B[3] B[4] B[5]
3 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
4 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
5 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
6 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
7 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
8 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
9 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
10 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
11 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
12 CSE465, Spring 2009 March 16 3 Distribution: B[0] B[1] B[2] B[3] B[4] B[5]
13 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
14 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
15 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
16 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
17 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
18 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
19 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
20 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
21 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
22 CSE465, Spring 2009 March 16 4 Collection:: B[0] B[1] B[2] B[3] B[4] B[5]
23 CSE465, Spring 2009 March 16 5 Counting sort We can use fragments of another array as buckets. If we place them appropriately, we do not need Collection stage instead, we need to perform Census stage to calculate the placement of the buckets. Counting_sort(A,B,n) { int C[m+1]; // Census // Prepare counters for (i = 0; i < m; C[i++] = 0); // Census of each bucket for (i = 0; i < n; i++) C[A[i]]++; // bucket i will be <B,C[i],C[i+1]> C[m] = n; for (i = m-1; m >= 0; i--) C[i] = C[i+1]-C[i]; // Transfer to buckets for (i = 0; i < n; i++) B[C[A[i]]++] = A[i]; } In this algorithm we are performing a constant number of work per each sorted number we look at it during Census of each bucket and move it during Transfer to buckets and for each bucket to Prepare counters and to compute the bucket limits. Thus the running time is Θ(m + n) Remark. This is a stable sorting method; we do not change relative positions in the order of numbers that are equal; this is important later.
24 CSE465, Spring 2009 March 16 6 Example Array C[6]:
25 CSE465, Spring 2009 March 16 7 After census of buckets: Array C[6]:
26 CSE465, Spring 2009 March 16 8 Computing bucket s left ends: Array C[6]: Array C[6]: Array C[6]: Array C[6]: Array C[6]: Array C[6]: Array C[6]:
27 CSE465, Spring 2009 March 16 9 Transfer: Array C[6]: Array B[10]:
28 CSE465, Spring 2009 March 16 9 Transfer: Array C[6]: Array B[10]:
29 CSE465, Spring 2009 March 16 9 Transfer: Array C[6]: Array B[10]:
30 CSE465, Spring 2009 March 16 9 Transfer: Array C[6]: Array B[10]:
31 CSE465, Spring 2009 March 16 9 Transfer: Array C[6]: Array B[10]:
32 CSE465, Spring 2009 March 16 9 Transfer: Array C[6]: Array B[10]:
33 CSE465, Spring 2009 March 16 9 Transfer: 2343 Array C[6]: Array B[10]:
34 CSE465, Spring 2009 March 16 9 Transfer: 343 Array C[6]: Array B[10]:
35 CSE465, Spring 2009 March 16 9 Transfer: 43 Array C[6]: Array B[10]:
36 CSE465, Spring 2009 March 16 9 Transfer: 3 Array C[6]: Array B[10]:
37 CSE465, Spring 2009 March 16 9 Transfer: Array C[6]: Array B[10]:
38 CSE465, Spring 2009 March Radix sort We will transform Counting Sort into sorting algorithm that is good for sorting numbers in {0, 1,..., m 3 1}. A number k from this range has three digits, k = digit(k,0) + m digit(k,1) + m 2 digit(k,2). Counting_sort(A,B,n) { int C[m+1]; // Census // Prepare counters for (i = 0; i < m; C[i++] = 0); // Census of each bucket for (i = 0; i < n; i++) C[A[i]]++; // bucket i will be <B,C[i],C[i+1]> C[m] = n; for (i = m-1; m >= 0; i--) C[i] = C[i+1]-C[i]; // Transfer to buckets for (i = 0; i < n; i++) B[C[A[i]]++] = A[i]; }
39 CSE465, Spring 2009 March Radix sort We will transform Counting Sort into sorting algorithm that is good for sorting numbers in {0, 1,..., m 3 1}. A number k from this range has three digits, k = digit(k,0) + m digit(k,1) + m 2 digit(k,2). Radix_sort(A,B,n) // preliminary { int C[m+1], *S = A, *T = B, *temp; // Census // Prepare counters for (i = 0; i < m; C[i++] = 0); // Census of each bucket for (i = 0; i < n; i++) C[digit(S[i],0)]++; // bucket i will be <T,C[i],C[i+1]> C[m] = n; for (i = m-1; m >= 0; i--) C[i] = C[i+1]-C[i]; // Transfer to buckets for (i = 0; i < n; i++) T[C[digit(S[i],0)]++] = S[i]; temp = T, T = S, S = temp; } will be transformed into
40 CSE465, Spring 2009 March We can repeat what we did once more, but now wewill look at the next digit: Radix_sort(A,B,n) // still preliminary { int C[m+1], *S = A, *T = B, *temp; for (d = 0; d < 2; d++) { // Census // Prepare counters for (i = 0; i < m; C[i++] = 0); // Census of each bucket for (i = 0; i < n; i++) C[digit(S[i],d)]++; // bucket i will be <T,C[i],C[i+1]> C[m] = n; for (i = m-1; m >= 0; i--) C[i] = C[i+1]-C[i]; // Transfer to buckets for (i = 0; i < n; i++) T[C[digit(S[i],d)]++] = S[i]; temp = T, T = S, S = temp; } } will be transformed into will be transformed into
41 CSE465, Spring 2009 March Now wecan present the final version: Radix_sort(A,B,n) { int C[m+1], *S = A, *T = B, *temp; for (d = 0; d < 3; d++) { // Census // Prepare counters for (i = 0; i < m; C[i++] = 0); // Census of each bucket for (i = 0; i < n; i++) C[digit(S[i],d)]++; // bucket i will be <T,C[i],C[i+1]> C[m] = n; for (i = m-1; m >= 0; i--) C[i] = C[i+1]-C[i]; // Transfer to buckets for (i = 0; i < n; i++) T[C[digit(S[i],d)]++] = S[i]; temp = T, T = S, S = temp; } } will be transformed into will be transformed into will be transformed into
42 CSE465, Spring 2009 March Final remarks on Radix sort. We can Radix sort with any number of digits. Because we compute digits very often, it is good to compute them fast. One good way is to look at the keys that are sorted as strings of unsigned characters. This way wehave mequal to 256 and we do not compute the digits, just read them. This is particularly good if the keys are indeed strings, e.g. names to be sorted alphabetically etc. Interestingly, we can use this approach to sort positive floating point numbers: exponent byte is the most significant, when exponents are equal, we should compare mantissas. If the set to be sorted has many thousands of elements (or millions) we prefer to have fewer passes. We can use pair of bytes/characters, and characters a, b define digit a b.
43 CSE465, Spring 2009 March Lower bound on comparison sorting Counting sort and Radix sort select the place where a sorted number k should be moved based on a function of its value, e.g. digit(k, d). This assumes some knowledge about the range of objects that we are sorting, and is not necessarily useful in every possible range. Therefore we are interested in comparison sorting, i.e. in sorting algorithms in which we do not compute any fuctions of the values of the sorted objects other than comparisons, Boolean functions on pairs of objects. It is easy to show that an algorithm that sorts n numbers must perform, in the worst case, atleast log 2 (n!) comparisons. We may assume that all the objects in the input are distinct. Then there exists exactly one permutation π such that for input a 0, a 1,..., a n 1 the valid output is a π (0), a π (1),..., a π (n 1). There are n! possible permutation and anyone of them is needed for some input. Let Π be the set of permutations that are needed for one of the inputs that would give the answers to comparisons that we have seen so far. Initially, before performing any comparisons, Π = n! input is possible (and thus every permutation). because every Suppose now that we are about to perform a comparison, say a i < a j. Let Π yes be the set of permutations from Π that are consistent with the positive answer, and let Π no be the set of permutations from Π that are consistent with the negative answer. For some val {no, yes} the set Π val is at least as large as the other one. If Π is not empty, then it is possible that val is the answer to the comparison a i < a j. Thus it is possible that as the result of comparison a i < a j we change set Π into Π val and Π val Π 2 1. Consequently, it is possible that after performing k comparisons we have Π n!2 k. On the other hand, after sorting is completed, we have Π ={π} for a certain permutation π, sowehave Π = 1.
44 CSE465, Spring 2009 March Therefore if k is the largest total number of permutation performed by our unknown algorithm for some input, then n!2 k 1 1 n!2 k 2 k n! k log 2 (n!) k Σ n log 2 n. i=2 On the other hand, we can estimate the latter summation as follows: n n Σ log 2 i > log 2 x dx = 1 n 1 ln 2 ln x dx = ln 2 [x ln x x]n 1 = i=2 1 ln 2 1 (n ln n n + 1) = n log 2 n n 1 ln 2. 1
Introduction to. Algorithms. Lecture 10. Prof. Constantinos Daskalakis CLRS
6.006- Introduction to Algorithms Lecture 10 Prof. Constantinos Daskalakis CLRS 8.1-8.4 Menu Show that Θ(n lg n) is the best possible running time for a sorting algorithm. Design an algorithm that sorts
More informationCSE373: Data Structure & Algorithms Lecture 23: More Sorting and Other Classes of Algorithms. Nicki Dell Spring 2014
CSE373: Data Structure & Algorithms Lecture 23: More Sorting and Other Classes of Algorithms Nicki Dell Spring 2014 Admin No class on Monday Extra time for homework 5 J 2 Sorting: The Big Picture Surprising
More informationA Lower Bound for Comparison Sort
A Lower Bound for Comparison Sort Pedro Ribeiro DCC/FCUP 2014/2015 Pedro Ribeiro (DCC/FCUP) A Lower Bound for Comparison Sort 2014/2015 1 / 9 On this lecture Upper and lower bound problems Notion of comparison-based
More informationMath 3012 Applied Combinatorics Lecture 2
August 20, 2015 Math 3012 Applied Combinatorics Lecture 2 William T. Trotter trotter@math.gatech.edu The Road Ahead Alert The next two to three lectures will be an integrated approach to material from
More informationCS3334 Data Structures Lecture 4: Bubble Sort & Insertion Sort. Chee Wei Tan
CS3334 Data Structures Lecture 4: Bubble Sort & Insertion Sort Chee Wei Tan Sorting Since Time Immemorial Plimpton 322 Tablet: Sorted Pythagorean Triples https://www.maa.org/sites/default/files/pdf/news/monthly105-120.pdf
More informationIntroduction to. Algorithms. Lecture 10. Prof. Piotr Indyk
6.006- Introduction to Algorithms Lecture 10 Prof. Piotr Indyk Quiz Rules Do not open this quiz booklet until directed to do so. Read all the instructions on this page When the quiz begins, write your
More informationDivide & conquer. Which works better for multi-cores: insertion sort or merge sort? Why?
1 Sorting... more 2 Divide & conquer Which works better for multi-cores: insertion sort or merge sort? Why? 3 Divide & conquer Which works better for multi-cores: insertion sort or merge sort? Why? Merge
More informationLecture 7: The Principle of Deferred Decisions
Randomized Algorithms Lecture 7: The Principle of Deferred Decisions Sotiris Nikoletseas Professor CEID - ETY Course 2017-2018 Sotiris Nikoletseas, Professor Randomized Algorithms - Lecture 7 1 / 20 Overview
More informationChapter 7: Sorting 7.1. Original
Chapter 7: Sorting 7.1 Original 3 1 4 1 5 9 2 6 5 after P=2 1 3 4 1 5 9 2 6 5 after P=3 1 3 4 1 5 9 2 6 5 after P=4 1 1 3 4 5 9 2 6 5 after P=5 1 1 3 4 5 9 2 6 5 after P=6 1 1 3 4 5 9 2 6 5 after P=7 1
More informationPattern Avoidance in Poset Permutations
Pattern Avoidance in Poset Permutations Sam Hopkins and Morgan Weiler Massachusetts Institute of Technology and University of California, Berkeley Permutation Patterns, Paris; July 5th, 2013 1 Definitions
More informationExercises to Chapter 2 solutions
Exercises to Chapter 2 solutions 1 Exercises to Chapter 2 solutions E2.1 The Manchester code was first used in Manchester Mark 1 computer at the University of Manchester in 1949 and is still used in low-speed
More informationDesign and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Module 6 Lecture - 37 Divide and Conquer: Counting Inversions
Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Module 6 Lecture - 37 Divide and Conquer: Counting Inversions Let us go back and look at Divide and Conquer again.
More informationEECS 452 Midterm Closed book part Winter 2013
EECS 452 Midterm Closed book part Winter 2013 Name: unique name: Sign the honor code: I have neither given nor received aid on this exam nor observed anyone else doing so. Scores: # Points Closed book
More informationCSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi
CSL 356: Analysis and Design of Algorithms Ragesh Jaiswal CSE, IIT Delhi Techniques Greedy Algorithms Divide and Conquer Dynamic Programming Network Flows Computational Intractability Dynamic Programming
More informationPartitions and Permutations
Chapter 5 Partitions and Permutations 5.1 Stirling Subset Numbers 5.2 Stirling Cycle Numbers 5.3 Inversions and Ascents 5.4 Derangements 5.5 Exponential Generating Functions 5.6 Posets and Lattices 1 2
More informationPUTNAM PROBLEMS FINITE MATHEMATICS, COMBINATORICS
PUTNAM PROBLEMS FINITE MATHEMATICS, COMBINATORICS 2014-B-5. In the 75th Annual Putnam Games, participants compete at mathematical games. Patniss and Keeta play a game in which they take turns choosing
More informationACM ICPC World Finals Warmup 2 At UVa Online Judge. 7 th May 2011 You get 14 Pages 10 Problems & 300 Minutes
ACM ICPC World Finals Warmup At UVa Online Judge 7 th May 011 You get 14 Pages 10 Problems & 300 Minutes A Unlock : Standard You are about to finish your favorite game (put the name of your favorite game
More informationMITOCW R7. Comparison Sort, Counting and Radix Sort
MITOCW R7. Comparison Sort, Counting and Radix Sort The following content is provided under a Creative Commons license. B support will help MIT OpenCourseWare continue to offer high quality educational
More informationRandomly Permuting Arrays, More Fun with Indicator Random Variables. CS255 Chris Pollett Feb. 1, 2006.
Randomly Permuting Arrays, More Fun with Indicator Random Variables CS255 Chris Pollett Feb. 1, 2006. Outline Finishing Up The Hiring Problem Randomly Permuting Arrays More uses of Indicator Random Variables
More informationChapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Objectives In this chapter, you will learn about The binary numbering system Boolean logic and gates Building computer circuits
More informationCSE101: Algorithm Design and Analysis. Ragesh Jaiswal, CSE, UCSD
Longest increasing subsequence Problem Longest increasing subsequence: You are given a sequence of integers A[1], A[2],..., A[n] and you are asked to find a longest increasing subsequence of integers.
More informationFall 2015 COMP Operating Systems. Lab #7
Fall 2015 COMP 3511 Operating Systems Lab #7 Outline Review and examples on virtual memory Motivation of Virtual Memory Demand Paging Page Replacement Q. 1 What is required to support dynamic memory allocation
More informationMerge Sort. Note that the recursion bottoms out when the subarray has just one element, so that it is trivially sorted.
1 of 10 Merge Sort Merge sort is based on the divide-and-conquer paradigm. Its worst-case running time has a lower order of growth than insertion sort. Since we are dealing with subproblems, we state each
More informationMITOCW R3. Document Distance, Insertion and Merge Sort
MITOCW R3. Document Distance, Insertion and Merge Sort The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational
More informationCS 758/858: Algorithms
CS 758/858: Algorithms http://www.cs.unh.edu/~ruml/cs758 1 handout: slides Wheeler Ruml (UNH) Class 2, CS 758 1 / 19 Counting Sort O() O() Example Stable Counting Wheeler Ruml (UNH) Class 2, CS 758 2 /
More informationLecture 2. 1 Nondeterministic Communication Complexity
Communication Complexity 16:198:671 1/26/10 Lecture 2 Lecturer: Troy Lee Scribe: Luke Friedman 1 Nondeterministic Communication Complexity 1.1 Review D(f): The minimum over all deterministic protocols
More informationUNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666
UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer Arithmetic ECE 666 Part 6a High-Speed Multiplication - I Israel Koren ECE666/Koren Part.6a.1 Speeding Up Multiplication
More informationEnumeration of Two Particular Sets of Minimal Permutations
3 47 6 3 Journal of Integer Sequences, Vol. 8 (05), Article 5.0. Enumeration of Two Particular Sets of Minimal Permutations Stefano Bilotta, Elisabetta Grazzini, and Elisa Pergola Dipartimento di Matematica
More informationBounds for Cut-and-Paste Sorting of Permutations
Bounds for Cut-and-Paste Sorting of Permutations Daniel Cranston Hal Sudborough Douglas B. West March 3, 2005 Abstract We consider the problem of determining the maximum number of moves required to sort
More informationCS 540-2: Introduction to Artificial Intelligence Homework Assignment #2. Assigned: Monday, February 6 Due: Saturday, February 18
CS 540-2: Introduction to Artificial Intelligence Homework Assignment #2 Assigned: Monday, February 6 Due: Saturday, February 18 Hand-In Instructions This assignment includes written problems and programming
More informationCSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.
CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25 Homework #1 ( Due: Oct 10 ) Figure 1: The laser game. Task 1. [ 60 Points ] Laser Game Consider the following game played on an n n board,
More informationDiscrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting
Discrete Mathematics: Logic Discrete Mathematics: Lecture 15: Counting counting combinatorics: the study of the number of ways to put things together into various combinations basic counting principles
More informationCounting in Algorithms
Counting Counting in Algorithms How many comparisons are needed to sort n numbers? How many steps to compute the GCD of two numbers? How many steps to factor an integer? Counting in Games How many different
More informationPermutations and Combinations
Permutations and Combinations Introduction Permutations and combinations refer to number of ways of selecting a number of distinct objects from a set of distinct objects. Permutations are ordered selections;
More informationEquivalence classes of length-changing replacements of size-3 patterns
Equivalence classes of length-changing replacements of size-3 patterns Vahid Fazel-Rezai Mentor: Tanya Khovanova 2013 MIT-PRIMES Conference May 18, 2013 Vahid Fazel-Rezai Length-Changing Pattern Replacements
More informationarxiv: v1 [math.co] 8 Oct 2012
Flashcard games Joel Brewster Lewis and Nan Li November 9, 2018 arxiv:1210.2419v1 [math.co] 8 Oct 2012 Abstract We study a certain family of discrete dynamical processes introduced by Novikoff, Kleinberg
More informationCMPS 12A Introduction to Programming Programming Assignment 5 In this assignment you will write a Java program that finds all solutions to the n-queens problem, for. Begin by reading the Wikipedia article
More informationWhat is a Sorting Function?
Department of Computer Science University of Copenhagen Email: henglein@diku.dk WG 2.8 2008, Park City, June 15-22, 2008 Outline 1 Sorting algorithms Literature definitions What is a sorting criterion?
More informationSets. Gazihan Alankuş (Based on original slides by Brahim Hnich et al.) August 6, Outline Sets Equality Subset Empty Set Cardinality Power Set
Gazihan Alankuş (Based on original slides by Brahim Hnich et al.) August 6, 2012 Gazihan Alankuş (Based on original slides by Brahim Hnich et al.) Gazihan Alankuş (Based on original slides by Brahim Hnich
More informationCombinational Logic Circuits. Combinational Logic
Combinational Logic Circuits The outputs of Combinational Logic Circuits are only determined by the logical function of their current input state, logic 0 or logic 1, at any given instant in time. The
More informationPermutation Codes Correcting a Single Burst Deletion I: Unstable Deletions
Permutation Codes Correcting a Single Burst Deletion I: Unstable Deletions Yeow Meng Chee, Van Khu Vu, and Xiande Zhang School of Physical and Mathematical Sciences, Nanyang Technological University, Singapore
More informationDATA STRUCTURES USING C
DATA STRUCTURES USING C Lecture-10 Data Structures Different types of Sorting Techniques used in Data Structures Sorting: Definition Sorting: an operation that segregates items into groups according to
More informationTHE GUESS OF DEATH. PSEUDOCODE: The logic for my code will be. Dawson Dill 152BC. A less convinient form of analog hangman
PSEUDOCODE: The logic for my code will be based around these basic systems in my game: a letter picker for the user implemented by the use of a knob and a potentiometer, a button for the user that will
More informationMathematics for Biology
MAT1142 Department of Mathematics University of Ruhuna A.W.L. Pubudu Thilan Logarithms Why do we need logarithms? Sometimes you only care about how big a number is relative to other numbers. The Richter,
More informationWednesday, February 1, 2017
Wednesday, February 1, 2017 Topics for today Encoding game positions Constructing variable-length codes Huffman codes Encoding Game positions Some programs that play two-player games (e.g., tic-tac-toe,
More informationMAS336 Computational Problem Solving. Problem 3: Eight Queens
MAS336 Computational Problem Solving Problem 3: Eight Queens Introduction Francis J. Wright, 2007 Topics: arrays, recursion, plotting, symmetry The problem is to find all the distinct ways of choosing
More informationParking and Railroad Cars
Parking and Railroad Cars CS 007 Algorithm Analysis and Design 5th Semester 1 Rail Road Cars Imagine four railroad cars positioned on the input side of the track numbered 1,2,3,4 respectively. Suppose
More informationTransforming Cabbage into Turnip Genome Rearrangements Sorting By Reversals Greedy Algorithm for Sorting by Reversals Pancake Flipping Problem
Transforming Cabbage into Turnip Genome Rearrangements Sorting By Reversals Greedy Algorithm for Sorting by Reversals Pancake Flipping Problem Approximation Algorithms Breakpoints: a Different Face of
More informationMATH 105: Midterm #1 Practice Problems
Name: MATH 105: Midterm #1 Practice Problems 1. TRUE or FALSE, plus explanation. Give a full-word answer TRUE or FALSE. If the statement is true, explain why, using concepts and results from class to justify
More informationGreedy Algorithms and Genome Rearrangements
Greedy Algorithms and Genome Rearrangements 1. Transforming Cabbage into Turnip 2. Genome Rearrangements 3. Sorting By Reversals 4. Pancake Flipping Problem 5. Greedy Algorithm for Sorting by Reversals
More informationIntroduction to Mathematical Reasoning, Saylor 111
Here s a game I like plying with students I ll write a positive integer on the board that comes from a set S You can propose other numbers, and I tell you if your proposed number comes from the set Eventually
More informationApplications of Advanced Mathematics (C4) Paper B: Comprehension INSERT WEDNESDAY 21 MAY 2008 Time:Upto1hour
ADVANCED GCE 4754/01B MATHEMATICS (MEI) Applications of Advanced Mathematics (C4) Paper B: Comprehension INSERT WEDNESDAY 21 MAY 2008 Afternoon Time:Upto1hour INSTRUCTIONS TO CANDIDATES This insert contains
More informationMITOCW 7. Counting Sort, Radix Sort, Lower Bounds for Sorting
MITOCW 7. Counting Sort, Radix Sort, Lower Bounds for Sorting The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality
More informationCollectives Pattern. Parallel Computing CIS 410/510 Department of Computer and Information Science. Lecture 8 Collective Pattern
Collectives Pattern Parallel Computing CIS 410/510 Department of Computer and Information Science Outline q What are Collectives? q Reduce Pattern q Scan Pattern q Sorting 2 Collectives q Collective operations
More informationHUFFMAN CODING. Catherine Bénéteau and Patrick J. Van Fleet. SACNAS 2009 Mini Course. University of South Florida and University of St.
Catherine Bénéteau and Patrick J. Van Fleet University of South Florida and University of St. Thomas SACNAS 2009 Mini Course WEDNESDAY, 14 OCTOBER, 2009 (1:40-3:00) LECTURE 2 SACNAS 2009 1 / 10 All lecture
More informationAlgorithms and Data Structures CS 372. The Sorting Problem. Insertion Sort - Summary. Merge Sort. Input: Output:
Algorithms and Data Structures CS Merge Sort (Based on slides by M. Nicolescu) The Sorting Problem Input: A sequence of n numbers a, a,..., a n Output: A permutation (reordering) a, a,..., a n of the input
More informationAutomatic Wordfeud Playing Bot
Automatic Wordfeud Playing Bot Authors: Martin Berntsson, Körsbärsvägen 4 C, 073-6962240, mbernt@kth.se Fredric Ericsson, Adolf Lemons väg 33, 073-4224662, fericss@kth.se Course: Degree Project in Computer
More informationcode V(n,k) := words module
Basic Theory Distance Suppose that you knew that an English word was transmitted and you had received the word SHIP. If you suspected that some errors had occurred in transmission, it would be impossible
More informationCSE 312: Foundations of Computing II Quiz Section #1: Counting
CSE 312: Foundations of Computing II Quiz Section #1: Counting Review: Main Theorems and Concepts 1. Product Rule: Suppose there are m 1 possible outcomes for event A 1, then m 2 possible outcomes for
More informationMonday, February 2, Is assigned today. Answers due by noon on Monday, February 9, 2015.
Monday, February 2, 2015 Topics for today Homework #1 Encoding checkers and chess positions Constructing variable-length codes Huffman codes Homework #1 Is assigned today. Answers due by noon on Monday,
More informationGENOMIC REARRANGEMENT ALGORITHMS
GENOMIC REARRANGEMENT ALGORITHMS KAREN LOSTRITTO Abstract. In this paper, I discuss genomic rearrangement. Specifically, I describe the formal representation of these genomic rearrangements as well as
More informationCSE 21 Practice Final Exam Winter 2016
CSE 21 Practice Final Exam Winter 2016 1. Sorting and Searching. Give the number of comparisons that will be performed by each sorting algorithm if the input list of length n happens to be of the form
More informationCollectives Pattern CS 472 Concurrent & Parallel Programming University of Evansville
Collectives Pattern CS 472 Concurrent & Parallel Programming University of Evansville Selection of slides from CIS 410/510 Introduction to Parallel Computing Department of Computer and Information Science,
More informationEntropy, Coding and Data Compression
Entropy, Coding and Data Compression Data vs. Information yes, not, yes, yes, not not In ASCII, each item is 3 8 = 24 bits of data But if the only possible answers are yes and not, there is only one bit
More informationThe Complexity of Sorting with Networks of Stacks and Queues
The Complexity of Sorting with Networks of Stacks and Queues Stefan Felsner Institut für Mathematik, Technische Universität Berlin. felsner@math.tu-berlin.de Martin Pergel Department of Applied Mathematics
More informationApplications of Advanced Mathematics (C4) Paper B: Comprehension WEDNESDAY 21 MAY 2008 Time:Upto1hour
ADVANCED GCE 4754/01B MATHEMATICS (MEI) Applications of Advanced Mathematics (C4) Paper B: Comprehension WEDNESDAY 21 MAY 2008 Afternoon Time:Upto1hour Additional materials: Rough paper MEI Examination
More informationSec 5.1 The Basics of Counting
1 Sec 5.1 The Basics of Counting Combinatorics, the study of arrangements of objects, is an important part of discrete mathematics. In this chapter, we will learn basic techniques of counting which has
More informationStruct: Finding Structure in Permutation Sets
Michael Albert, Christian Bean, Anders Claesson, Bjarki Ágúst Guðmundsson, Tómas Ken Magnússon and Henning Ulfarsson April 26th, 2016 Classical Patterns What is a permutation? π = 431265 = Classical Patterns
More information1 This work was partially supported by NSF Grant No. CCR , and by the URI International Engineering Program.
Combined Error Correcting and Compressing Codes Extended Summary Thomas Wenisch Peter F. Swaszek Augustus K. Uht 1 University of Rhode Island, Kingston RI Submitted to International Symposium on Information
More informationIntegrated Strategy for Generating Permutation
Int J Contemp Math Sciences, Vol 6, 011, no 4, 1167-1174 Integrated Strategy for Generating Permutation Sharmila Karim 1, Zurni Omar and Haslinda Ibrahim Quantitative Sciences Building College of Arts
More information1 Permutations. 1.1 Example 1. Lisa Yan CS 109 Combinatorics. Lecture Notes #2 June 27, 2018
Lisa Yan CS 09 Combinatorics Lecture Notes # June 7, 08 Handout by Chris Piech, with examples by Mehran Sahami As we mentioned last class, the principles of counting are core to probability. Counting is
More informationProgramming Abstractions
Programming Abstractions C S 1 0 6 X Cynthia Lee Today s Topics Sorting! 1. The warm-ups Selection sort Insertion sort 2. Let s use a data structure! Heapsort 3. Divide & Conquer Merge Sort (aka Professor
More informationCSc 110, Spring Lecture 40: Sorting Adapted from slides by Marty Stepp and Stuart Reges
CSc 110, Spring 2017 Lecture 40: Sorting Adapted from slides by Marty Stepp and Stuart Reges 1 Searching How many items are examined worse case for sequential search? How many items are examined worst
More informationIn the game of Chess a queen can move any number of spaces in any linear direction: horizontally, vertically, or along a diagonal.
CMPS 12A Introduction to Programming Winter 2013 Programming Assignment 5 In this assignment you will write a java program finds all solutions to the n-queens problem, for 1 n 13. Begin by reading the
More informationSOME EXAMPLES FROM INFORMATION THEORY (AFTER C. SHANNON).
SOME EXAMPLES FROM INFORMATION THEORY (AFTER C. SHANNON). 1. Some easy problems. 1.1. Guessing a number. Someone chose a number x between 1 and N. You are allowed to ask questions: Is this number larger
More informationDistribution of Primes
Distribution of Primes Definition. For positive real numbers x, let π(x) be the number of prime numbers less than or equal to x. For example, π(1) = 0, π(10) = 4 and π(100) = 25. To use some ciphers, we
More informationMATHEMATICS ON THE CHESSBOARD
MATHEMATICS ON THE CHESSBOARD Problem 1. Consider a 8 8 chessboard and remove two diametrically opposite corner unit squares. Is it possible to cover (without overlapping) the remaining 62 unit squares
More informationGreedy Algorithms. Study Chapters /4/2014 COMP 555 Bioalgorithms (Fall 2014) 1
Greedy Algorithms Study Chapters.1-.2 9//201 COMP Bioalgorithms (Fall 201) 1 Which version of Python? Use version 2.7 or 2.6 Python Information Where to run python? On your preferred platform Windows,
More information18.204: CHIP FIRING GAMES
18.204: CHIP FIRING GAMES ANNE KELLEY Abstract. Chip firing is a one-player game where piles start with an initial number of chips and any pile with at least two chips can send one chip to the piles on
More informationMathematics. (www.tiwariacademy.com) (Chapter 7) (Permutations and Combinations) (Class XI) Exercise 7.3
Question 1: Mathematics () Exercise 7.3 How many 3-digit numbers can be formed by using the digits 1 to 9 if no digit is repeated? Answer 1: 3-digit numbers have to be formed using the digits 1 to 9. Here,
More informationSee-Saw Swap Solitaire and Other Games on Permutations
See-Saw Swap Solitaire and Other Games on Permutations Tom ( sven ) Roby (UConn) Joint research with Steve Linton, James Propp, & Julian West Canada/USA Mathcamp Lewis & Clark College Portland, OR USA
More informationPermutations with short monotone subsequences
Permutations with short monotone subsequences Dan Romik Abstract We consider permutations of 1, 2,..., n 2 whose longest monotone subsequence is of length n and are therefore extremal for the Erdős-Szekeres
More informationLocalization (Position Estimation) Problem in WSN
Localization (Position Estimation) Problem in WSN [1] Convex Position Estimation in Wireless Sensor Networks by L. Doherty, K.S.J. Pister, and L.E. Ghaoui [2] Semidefinite Programming for Ad Hoc Wireless
More informationISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand
Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand ISudoku Abstract In this paper, we will analyze and discuss the Sudoku puzzle and implement different algorithms to solve the puzzle. After
More informationSolutions to Exercises Chapter 6: Latin squares and SDRs
Solutions to Exercises Chapter 6: Latin squares and SDRs 1 Show that the number of n n Latin squares is 1, 2, 12, 576 for n = 1, 2, 3, 4 respectively. (b) Prove that, up to permutations of the rows, columns,
More informationName: Checked: Answer: jack queen king ace
Lab 11 Name: Checked: Objectives: More practice using arrays: 1. Arrays of Strings and shuffling an array 2. Arrays as parameters 3. Collections Preparation Submit DeckOfCards.java and TrianglePanel.java
More informationSection 6.1 #16. Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?
Section 6.1 #16 What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit? page 1 Section 6.1 #38 Two events E 1 and E 2 are called independent if p(e 1
More informationE2.11/ISE2.22 Digital Electronics II
E2.11/ISE2.22 Digital Electronics II roblem Sheet 6 (uestion ratings: A=Easy,, E=Hard. All students should do questions rated A, B or C as a minimum) 1B+ A full-adder is a symmetric function of its inputs
More informationCOS 226 Algorithms and Data Structures Fall Midterm Exam
COS 226 lgorithms and Data Structures Fall 2015 Midterm Exam You have 80 minutes for this exam. The exam is closed book, except that you are allowed to use one page of notes (8.5-by-11, one side, in your
More informationCSE 1400 Applied Discrete Mathematics Permutations
CSE 1400 Applied Discrete Mathematics Department of Computer Sciences College of Engineering Florida Tech Fall 2011 1 Cyclic Notation 2 Re-Order a Sequence 2 Stirling Numbers of the First Kind 2 Problems
More informationCOS 226 Algorithms and Data Structures Fall Midterm Exam
COS 226 lgorithms and Data Structures Fall 2015 Midterm Exam This exam has 8 questions worth a total of 100 points. You have 80 minutes. The exam is closed book, except that you are allowed to use one
More informationMITOCW Recitation 9b: DNA Sequence Matching
MITOCW Recitation 9b: DNA Sequence Matching The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources
More informationCombinatorics in the group of parity alternating permutations
Combinatorics in the group of parity alternating permutations Shinji Tanimoto (tanimoto@cc.kochi-wu.ac.jp) arxiv:081.1839v1 [math.co] 10 Dec 008 Department of Mathematics, Kochi Joshi University, Kochi
More informationOn the size of sets of permutations with bounded VC-dimension
On the size of sets of permutations with bounded VC-dimension Department of Applied Mathematics Charles University, Prague 11 August 2010 / PP 2010 VC-dimension Set systems VC-dimension of a family C of
More informationProblem A. Vera and Outfits
Problem A. Vera and Outfits file: file: Vera owns N tops and N pants. The i-th top and i-th pants have colour i, for 1 i N, where all N colours are different from each other. An outfit consists of one
More informationConstructions of Coverings of the Integers: Exploring an Erdős Problem
Constructions of Coverings of the Integers: Exploring an Erdős Problem Kelly Bickel, Michael Firrisa, Juan Ortiz, and Kristen Pueschel August 20, 2008 Abstract In this paper, we study necessary conditions
More information2017 Denison Spring Programming Contest Granville, Ohio 18 February, 2017
2017 Denison Spring Programming Contest Granville, Ohio 18 February, 2017 Rules: 1. There are six problems to be completed in four hours. 2. All questions require you to read the test data from standard
More informationComputing Permutations with Stacks and Deques
Michael Albert 1 Mike Atkinson 1 Steve Linton 2 1 Department of Computer Science, University of Otago 2 School of Computer Science, University of St Andrews 7th Australia New Zealand Mathematics Convention
More informationMath is Cool Masters
Sponsored by: Algebra II January 6, 008 Individual Contest Tear this sheet off and fill out top of answer sheet on following page prior to the start of the test. GENERAL INSTRUCTIONS applying to all tests:
More informationMA 524 Midterm Solutions October 16, 2018
MA 524 Midterm Solutions October 16, 2018 1. (a) Let a n be the number of ordered tuples (a, b, c, d) of integers satisfying 0 a < b c < d n. Find a closed formula for a n, as well as its ordinary generating
More information