A Simple Algorithm for Stable Minimum Storage Merging Pok-Son Kim Kookmin University, Department of Mathematics, Seoul 135-702, Korea Arne Kutzner Seokyeong.

Slides:



Advertisements
Similar presentations
CPSC 411 Design and Analysis of Algorithms Set 2: Sorting Lower Bound Prof. Jennifer Welch Spring 2011 CPSC 411, Spring 2011: Set 2 1.
Advertisements

Introduction to Algorithms Quicksort
Analysis of Algorithms
Counting the bits Analysis of Algorithms Will it run on a larger problem? When will it fail?
QuickSort Average Case Analysis An Incompressibility Approach Brendan Lucier August 2, 2005.
Heapsort O(n lg n) worst case Another design paradigm –Use of a data structure (heap) to manage information during execution of algorithm Comparision-based.
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
Sorting Comparison-based algorithm review –You should know most of the algorithms –We will concentrate on their analyses –Special emphasis: Heapsort Lower.
MS 101: Algorithms Instructor Neelima Gupta
© The McGraw-Hill Companies, Inc., Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
1 Sorting Problem: Given a sequence of elements, find a permutation such that the resulting sequence is sorted in some order. We have already seen: –Insertion.
CS 171: Introduction to Computer Science II Quicksort.
Advanced Topics in Algorithms and Data Structures Lecture 6.1 – pg 1 An overview of lecture 6 A parallel search algorithm A parallel merging algorithm.
Advanced Topics in Algorithms and Data Structures Page 1 Parallel merging through partitioning The partitioning strategy consists of: Breaking up the given.
Lecture 5: Linear Time Sorting Shang-Hua Teng. Sorting Input: Array A[1...n], of elements in arbitrary order; array size n Output: Array A[1...n] of the.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
CPSC 411, Fall 2008: Set 2 1 CPSC 411 Design and Analysis of Algorithms Set 2: Sorting Lower Bound Prof. Jennifer Welch Fall 2008.
Parallel Merging Advanced Algorithms & Data Structures Lecture Theme 15 Prof. Dr. Th. Ottmann Summer Semester 2006.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Data Structures Review Session 1
Sorting Lower Bound Andreas Klappenecker based on slides by Prof. Welch 1.
Analysis of Algorithms CS 477/677
The Complexity of Algorithms and the Lower Bounds of Problems
MergeSort Source: Gibbs & Tamassia. 2 MergeSort MergeSort is a divide and conquer method of sorting.
Ch. 8 & 9 – Linear Sorting and Order Statistics What do you trade for speed?
David Luebke 1 10/13/2015 CS 332: Algorithms Linear-Time Sorting Algorithms.
CSC 41/513: Intro to Algorithms Linear-Time Sorting Algorithms.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
On Optimal and Efficient in Place Merging Pok-Son Kim Kookmin University, Department of Mathematics, Seoul , Korea Arne Kutzner Seokyeong University,
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
The Selection Problem. 2 Median and Order Statistics In this section, we will study algorithms for finding the i th smallest element in a set of n elements.
Mudasser Naseer 1 11/5/2015 CSC 201: Design and Analysis of Algorithms Lecture # 8 Some Examples of Recursion Linear-Time Sorting Algorithms.
Chapter 18: Searching and Sorting Algorithms. Objectives In this chapter, you will: Learn the various search algorithms Implement sequential and binary.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Sorting Data Structures and Algorithms (60-254). Sorting Sorting is one of the most well-studied problems in Computer Science The ultimate reference on.
1 Parallel Sorting Algorithm. 2 Bitonic Sequence A bitonic sequence is defined as a list with no more than one LOCAL MAXIMUM and no more than one LOCAL.
Chapter 9 Sorting. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step is.
Lecture 14 Lower Bounds Decision tree model Linear-time reduction.
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
Review Quick Sort Quick Sort Algorithm Time Complexity Examples
Experimental Study on the Five Sort Algorithms You Yang, Ping Yu, Yan Gan School of Computer and Information Science Chongqing Normal University Chongqing,
Merge Sort Presentation By: Justin Corpron. In the Beginning… John von Neumann ( ) Stored program Developed merge sort for EDVAC in 1945.
Sorting Lower Bounds n Beating Them. Recap Divide and Conquer –Know how to break a problem into smaller problems, such that –Given a solution to the smaller.
Data Structures and Algorithms Instructor: Tesfaye Guta [M.Sc.] Haramaya University.
Lecture 5 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
1 Algorithms Searching and Sorting Algorithm Efficiency.
Polygon Triangulation
Advanced Sorting 7 2  9 4   2   4   7
Lecture 2 Algorithm Analysis
Decision Trees DEFINITION: DECISION TREE A decision tree is a tree in which the internal nodes represent actions, the arcs represent outcomes of an action,
Summary of lectures Introduction to Algorithm Analysis and Design (Chapter 1-3). Lecture Slides Recurrence and Master Theorem (Chapter 4). Lecture Slides.
Introduction to Algorithms
Quick-Sort 9/12/2018 3:26 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
MergeSort Source: Gibbs & Tamassia.
Lecture 5 Algorithm Analysis
Analysis of Algorithms
Lecture 5 Algorithm Analysis
Data Structures Review Session
CS200: Algorithm Analysis
Lecture 6 Algorithm Analysis
Divide and Conquer Algorithms Part I
Lecture 6 Algorithm Analysis
Linear-Time Sorting Algorithms
Lecture 5 Algorithm Analysis
The Selection Problem.
Lecture 5 Algorithm Analysis
Presentation transcript:

A Simple Algorithm for Stable Minimum Storage Merging Pok-Son Kim Kookmin University, Department of Mathematics, Seoul , Korea Arne Kutzner Seokyeong University, Department of E-Business, Seoul , Korea

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 2 Merging Make one sorted array out of two consecutive sorted arrays , 491, 92

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 3 Lower Bounds for Merging Number of comparisons –Argumentation over the decision tree (see Knuth) Number of assignments –Each element can change its position in the final sequence for

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 4 Notions An algorithm merges two adjacent sequences with “minimum storage” when it needs bits additional space at most. Stability: Merging algorithm preserves the initial ordering of elements with equal value.

We present..... …a simple, asymptotically optimal (regarding comparisons), stable, minimum storage merging algorithm called SPLITMERGE

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 6 SPLITMERGE: Step 1 - Splitting We compute boundaries in our inputs u and v so that we get the following property: u1u1 u2u2 v1v1 v2v2  

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 7 SPLITMERGE: Step 2 – Rotation We rotate u 2 v 1 to v 1 u 2 u1u1 u2u2 v1v1 v2v2 u1u1 u2u2 v1v1 v2v2

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 8 SPLITMERGE: Step 3 – Recursive Application We have: 1. u 1  u 2 and u 1  v 2 2. v 1  u 2 and v 1  v 2 u1u1 u2u2 v1v1 v2v2 left recursionright recursion

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 9 Stability Lemma: SPLITMERGE is stable. Proof: u1u1 u2u2 v1v1 v2v2 u1u1 u2u2 v1v1 v2v2 > rotation !!!!

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 10 How do we split? Repeated halving of two search spaces until these are reduced to single points (the borders of a rotation). For asymmetric inputs one element of the smaller side “freezes” after some time

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 11 Symmetric Splitting – Graphical Description u 21 xu 22 v 21 yv 22   search spaces x  y u 22 v 21   xy u 21 v 22   xy x  y

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 12 Splitting Example   ? ? ?

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 13 Symmetric Splitting – Asymmetric Inputs (1) x u1u1 u3u3 v1v1 v 21 yv 22 v3v3   single search space After some time one element “freezes” (here x) x can “belong” to u 1, u 3 or both x belongs to u 1 means u 1 x  v 3 x belongs to u 3 means xu 3  v 1

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 14 Symmetric Splitting – Asymmetric Inputs (2) x u1u1 u3u3 v1v1 v3v3   Rotation – we distinguish two different cases if x belongs to u 3 : x u1u1 u3u3 v1v1 v3v3 otherwise : x u1u1 u3u3 v1v1 v3v3

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 15 Symmetric Splitting – Asymmetric Inputs (3) Recursion – we distinguish several cases if x belongs to u 1 x u1u1 u3u3 v1v1 v3v3 otherwise x u1u1 u3u3 v1v1 v3v3 left Recursionright Recursion

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 16 Algorithm in Pseudo code

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 17 Some Remarks … The “belongs to” information can be followed from the variables l, r and m

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 18 Worst Case Complexity Lemma: The recursion depth is limited by min, where Corollary: Minimum Storage Algorithm

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 19 Worst Case Complexity (Comparisons) Special case m→ m/2 (1) m10m10 n32n32 m12m12 m22m22 m32m32 m42m42 m11m11 m21m21 n42n42 n22n22 n12n12 n11n11 n21n21 n10n10 m m/2 m/ recursion depth

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 20 Worst Case Complexity (Comparisons) Special case m→ m/2 (2) m10m10 n32n32 m12m12 m22m22 m32m32 m42m42 m11m11 m21m21 n42n42 n22n22 n12n12 n11n11 n21n21 n10n i k recursion level

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 21 Worst Case Complexity (Comparisons) Special case m→ m/2 (3) Overall number of comparisons: Mathematical Machinery

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 22 Worst Case Complexity How to treat the other cases? (1) Example: Maximum spanning case

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 23 Worst Case Complexity How to treat other cases? (2) Trick: Mapping into a corresponding “ m → m/2 case” by the introduction of recursion groups –A recursion group consists of one or several recursion levels –Grouping of recursion levels into recursion groups so that each recursion group holds at most 2 i-1 recursion levels. –Altogether k+1 recursion groups

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 24 Worst Case Complexity How to treat other cases? (3) Mapping for the maximum spanning case:

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 25 Assignments / Worst Case Complexity Theorem: The S PLITMERGE algorithm needs assignments. Sketch of Proof: At most k+1 recursion groups with O(m+n) many assignments for every group

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 26 Benchmarks n,m : lengths of input sequences (m=n) i : number of different input elements t e : execution time in ms #comp : number of comparisons

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 27 Summary Simply structured algorithm using a novel binary partition technique Doesn’t rely on any third algorithm as subpart Short definition in Pseudo Code Asymptotically optimal regarding the number of comparisons Nice Textbook algorithm ?

SOFSEM 2007 A Simple Algorithm for Stable Minimum Storage Merging 28 Thank you very much for your attention