On the Competitiveness of Self Organizing Linear Search J. Ian Munro (University of Waterloo) Competitiveness: How well does an on line algorithm do in.

Slides:



Advertisements
Similar presentations
Routing Complexity of Faulty Networks Omer Angel Itai Benjamini Eran Ofek Udi Wieder The Weizmann Institute of Science.
Advertisements

Introduction to Algorithms Quicksort
110/6/2014CSE Suprakash Datta datta[at]cse.yorku.ca CSE 3101: Introduction to the Design and Analysis of Algorithms.
CSE 4101/5101 Prof. Andy Mirzaian. Lists Move-to-Front Search Trees Binary Search Trees Multi-Way Search Trees B-trees Splay Trees Trees Red-Black.
1 SOFSEM 2007 Weighted Nearest Neighbor Algorithms for the Graph Exploration Problem on Cycles Eiji Miyano Kyushu Institute of Technology, Japan Joint.
Theory of Computing Lecture 3 MAS 714 Hartmut Klauck.
MS 101: Algorithms Instructor Neelima Gupta
§7 Quicksort -- the fastest known sorting algorithm in practice 1. The Algorithm void Quicksort ( ElementType A[ ], int N ) { if ( N < 2 ) return; pivot.
Lower bound for sorting, radix sort COMP171 Fall 2005.
Copyright © 2009 Curt Hill Self Organizing Lists Another form of searchable list.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Competitive Analysis.
Introduction to Algorithms Jiafen Liu Sept
Nattee Niparnan. Recall What is the measurement of algorithm? How to compare two algorithms? Definition of Asymptotic Notation.
Deterministic Selection and Sorting Prepared by John Reif, Ph.D. Analysis of Algorithms.
DIVIDE AND CONQUER APPROACH. General Method Works on the approach of dividing a given problem into smaller sub problems (ideally of same size).  Divide.
UMass Lowell Computer Science Analysis of Algorithms Spring, 2002 Chapter 5 Lecture Randomized Algorithms Sections 5.1 – 5.3 source: textbook.
Evaluation of Algorithms for the List Update Problem Suporn Pongnumkul R. Ravi Kedar Dhamdhere.
Advanced Topics in Algorithms and Data Structures Page 1 Parallel merging through partitioning The partitioning strategy consists of: Breaking up the given.
Self-Organizing Lists1 Self-Organizing Lists Competitive Analysis Lee Wee Sun SoC Modified by Orgad Keller Modified again by.
Lower bound for sorting, radix sort COMP171 Fall 2006.
CS 253: Algorithms Chapter 8 Sorting in Linear Time Credit: Dr. George Bebis.
Comp 122, Spring 2004 Elementary Sorting Algorithms.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
Parallel Routing Bruce, Chiu-Wing Sham. Overview Background Routing in parallel computers Routing in hypercube network –Bit-fixing routing algorithm –Randomized.
Tirgul 8 Universal Hashing Remarks on Programming Exercise 1 Solution to question 2 in theoretical homework 2.
Algorithm Efficiency and Sorting
E.G.M. Petrakissearching1 Searching  Find an element in a collection in the main memory or on the disk  collection: (K 1,I 1 ),(K 2,I 2 )…(K N,I N )
Evaluation of Algorithms for the List Update Problem Suporn Pongnumkul R. Ravi Kedar Dhamdhere.
Binary search trees Definition Binary search trees and dynamic set operations Balanced binary search trees –Tree rotations –Red-black trees Move to front.
Lower Bounds for Comparison-Based Sorting Algorithms (Ch. 8)
Computer Algorithms Lecture 11 Sorting in Linear Time Ch. 8
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Chapter 19: Searching and Sorting Algorithms
Merge Sort. What Is Sorting? To arrange a collection of items in some specified order. Numerical order Lexicographical order Input: sequence of numbers.
Jessie Zhao Course page: 1.
CSC 41/513: Intro to Algorithms Linear-Time Sorting Algorithms.
Elementary Sorting Algorithms Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Introduction to Algorithms Jiafen Liu Sept
Integer Representations and Counting in the Bit Probe Model M. Zaiur Rahman and J. Ian Munro Cheriton School of Computer Science University of Waterloo.
CS 473Lecture X1 CS473-Algorithms I Lecture X1 Properties of Ranks.
Chapter 7: Sorting Algorithms Insertion Sort. Sorting Algorithms  Insertion Sort  Shell Sort  Heap Sort  Merge Sort  Quick Sort 2.
1 Splay trees (Sleator, Tarjan 1983). 2 Goal Support the same operations as previous search trees.
Data Structure Introduction.
Searching Given distinct keys k 1, k 2, …, k n and a collection of n records of the form »(k 1,I 1 ), (k 2,I 2 ), …, (k n, I n ) Search Problem - For key.
Chapter 18: Searching and Sorting Algorithms. Objectives In this chapter, you will: Learn the various search algorithms Implement sequential and binary.
1 Lower Bound on Comparison-based Search We have now covered lots of searching methods –Contiguous Data (Arrays) Sequential search Binary Search –Dynamic.
Implicit Dictionaries with O(1) Modifications per Update and Fast Search Gianni Franceschini and Ian Munro  Elements kept in 1 st n positions of an array.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 7.
Four different data structures, each one best in a different setting. Simple Heap Balanced Heap Fibonacci Heap Incremental Heap Our results.
Block Ciphers and the Advanced Encryption Standard
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 1. Complexity Bounds.
1 Chapter 5-1 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Data Structures Haim Kaplan & Uri Zwick December 2013 Sorting 1.
Chapter 9 Sorting 1. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step.
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.
Splay Trees and the Interleave Bound Brendan Lucier March 15, 2005 Summary of “Dynamic Optimality -- Almost” by Demaine et. Al., 2004.
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
Searching Topics Sequential Search Binary Search.
Great Theoretical Ideas in Computer Science for Some.
Chapter 7: Sorting Algorithms Insertion Sort Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Binary search trees Definition
Self-Adjusting Search trees
Introduction to Algorithms
Chapter 3: The Efficiency of Algorithms
Splay trees (Sleator, Tarjan 1983)
Data Structures Sorting Haim Kaplan & Uri Zwick December 2014.
Recurrences (Method 4) Alexandra Stefan.
Computer Organization & Architecture 3416
Elementary Sorting Algorithms
Presentation transcript:

On the Competitiveness of Self Organizing Linear Search J. Ian Munro (University of Waterloo) Competitiveness: How well does an on line algorithm do in comparison to one that is given the sequence of operations in advance? Self Organizing Search: Based on requests received, continually reorganize the data structure to make frequently accessed elements cheaper to get. Model of Computation: What operations can we do? What do we count? Amortized cost in our case.

Self Organizing Linear Search Elements in a linear list (array or linked) On access can reorder the elements inspected, count number records inspected Likely approaches: lMove to Front S E L F O R G A N I Z I N G L I N E A R.. I S E L F O R G A N Z I N G L I N E A R.. lSimple exchange S E L F O R G A N I Z I N G L I N E A R.. S E L F O R G A I N Z I N G L I N E A R..

Known Bounds Expected case (long sequence, elements have fixed independent probabilities of access): Cost(SE)  Cost(MtF)  2 Opt = 2  i p i (McCabe; Rivest) Replace p i by f i /m, then on an amortized basis Cost(MtF)  2  i f i /m (Bentley and McGeough) Move to Front is 2-competitive (Sleator and Tarjan): i.e. within a factor of 2 of the cost of the off line optimal…which can move elements about as if it knows what will be accessed but model is crucial.

That Model Scan to the element requested, and no further (charge 1 per element inspected) Put requested element anywhere among scanned values (free) Swap as many pairs of consecutive elements as you like (1 per exchange) so swapping front and back halves of list costs  (n 2 ) n/2 (n/2+1)..n  (n/2+1).. n n/2

A Realistic Change in the Model Scan as far as you like. Charge one per element inspected KEY POINT Can rearrange portion inspected arbitrarily at no charge (in fact we will perform very simple rearrangements) so so swapping front and back halves of list costs  (n) n/2 (n/2+1).. n  (n/2+1).. n n/2

Order by Next Request lScan for element i, continue to the 2  lg i  lReorder the element requested by NEXT REQUEST CostNew Ordering

Cost of a “Cycle” for Order by Next Request Cost (under our model) is n lg n, amortized lg n Lower bound Theorem: Under our model, n ln n inspections are required to individually scan for each of n elements. Proof idea: “Crossing sequence argument” Access to elements in position i or later must occur at least n/i times … for a total cost of at least  n/i  n ln n

More General Bound on Amortized Cost of OBNR Main Theorem: Let r denote the number of distinct elements requested since the last for a given value, then the amortized cost for a search can be charged as at most  lg r  Idea of Proof: “Soak the Middle Class” For any request, entire cost is borne by penultimate block of size 2  lg i  - 2, so costs 4 for each of them. Lemma: An element can be in the penultimate block at most once between its accesses.

Tweaking the Constant Blocks of size 2 k are not optimal. Make them of size powers of And the preceding bound becomes  lg r 

Corollaries Bounds look much like Splay Tree bounds Request Gap View: Total cost of sequence in which element i occurs r i times is at most n   lg (r i + 1) . or Entropy View: Let f i denote the frequency of accesses to i in a sequence of length m, then the total cost is at most n  f i  lg (m/f i ) , or writing f i /m= p i, the amortized cost is O(1 + p i lg 1/p i )

Linear Search Versus Binary Trees.. Off Line Bounds in terms of frequencies are same order. Splay trees can take advantage of key order (e.g. accessing values sequentially). Order by Next Request on trees.. a bad case: Order by Next Request takes amortized time lg n and makes no changes in the tree!