We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byClyde Gilbert
Modified about 1 year ago
Copyright © 2009 Curt Hill Self Organizing Lists Another form of searchable list
Normal Searched Lists Unlike an array, a list cannot be searched by a binary search A list is sorted only so that search can quit early It is thus it is largely an O(N) activity Since there are plenty of better searches that are O(log N) or better a list is seldom a good choice Copyright © 2009 Curt Hill
Self organizing lists Instead of sorting by key, sort by frequency Drive frequently used items to the front of the list and seldom accessed items to the back of the list A self organizing list modifies itself based on accesses Do this without prior information as to how frequently an item will be accessed –These lists may be kept in either vectors or lists Only uses a sequential search technique Copyright © 2009 Curt Hill
How? Several techniques Keep a count of accesses Move each item accessed to the front Move each item closer to the front Copyright © 2009 Curt Hill
Counts Keep a count of accesses in each record Keep the list sorted by this number of accesses At the beginning the list has no accesses so all counts are zero and hence any order is acceptable Each search then increments the count of just one item Copyright © 2009 Curt Hill
Counts Again Incrementing the count does not provoke a full sort of the list Rather you just move that item forward until its count is larger than the next and smaller than the prior The disadvantage of this approach –Extra storage in the list for the count Once a large number of accesses have occurred things do not move very far Copyright © 2009 Curt Hill
More on counts A number of accesses to an item in a short time normally moves the item –If that number of accesses is small compared to the total number it will not move item very far At the end of the run the list has the optimal static order Possible to save this or a variant of this for next time –Either save the exact counts or the counts divided by some constant Copyright © 2009 Curt Hill
Move to front Each accessed item becomes the first item in the list –At least until the next access Push all subsequent items down a slot Compare this to caching This works much better for lists than vectors since insertion in a list is painless while insertion in a list is painful Copyright © 2009 Curt Hill
Move to Front There is a pathlogically bad case where we always reference the last item –This case is extremely unlikely We typically use self-organizing lists where we have very few items that are very frequently used Copyright © 2009 Curt Hill
Transposition Every time a record is accessed swap it with the item before it Frequently used items will migrate toward the front and seldom used ones will move toward the back One item never changes the list much Modification: If this is an array you may want to swap the item with something closer to the front, such as halfway to the front rather than move it just one slot Copyright © 2009 Curt Hill
Example –1 is 30% –1 is 25% –1 is 20% –1 is 5% –1 is 4% –1 is 3% –2 are 2% –1 is 1.5% –1 is 1% –5 are.5% –2 are.3 % –4 are.2% –23 are.1% –6 arr.05% Copyright © 2009 Curt Hill A list of 50 items with widely differing frequencies.
Do the math Assume that the self-organizing list achieves optimal static order –The first three items account for 75% of the searches The average searches is the sum of the frequency times the position divided by total searches In this case the average search length is An log 2 N search would give a length of Copyright © 2009 Curt Hill
Frequency Distribution Copyright © 2009 Curt Hill
Summary Self-organizing lists need a radical frequency distribution to be effective against O(log 2 N) searches –Such as a binary or tree search A failure has to search entire list, so these should be infrequent as well Like perfect hashes these need to be looked for Very good search when conditions are right Copyright © 2009 Curt Hill
Quicksort Introduction to Algorithms Quicksort CSE 680 Prof. Roger Crawfis.
1 Indexing. 2 Overview An index is a table containing a list of keys associated with a reference field pointing to the record where the information referenced.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Dolch Words the of and to a in that is was.
Chapter 17: Recovery System Failure Classification Storage Structure Recovery and Atomicity Log-Based Recovery Shadow Paging Recovery With Concurrent Transactions.
IOS103 OPERATING SYSTEM VIRTUAL MEMORY. Objectives At the end of the course, the student should be able to: Define virtual memory; Discuss the demand.
Zabin Visram Room CS115 CS126 Searching Binary Search.
Data Structures and Algorithms Courses slides: Sorting Algorithms
Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered.
The. of and a to in is you that it he for.
Surds Surds are a special type of number that you need to understand and do calculations with. The are examples of exact values and are often appear in.
22-Jan-14 Dynamic Programming. 2 Counting coins To find the minimum number of US coins to make any amount, the greedy method always works At each step,
1 Chapter 11. Hash Tables. 2 Many applications require a dynamic set that supports only the dictionary operations, INSERT, SEARCH, and DELETE. Example:
1 Chapter 9 continued: Quicksort Similar to mergesort: divide and conquer, recursive algorithm Average running time is O(nlogn) O(n 2 ) worst case performance,
©G. Millbery 2003File and Database ConceptsSlide 1 Methods of Access Serial Sequential Indexed Sequential Random Access Need to show advantages,
G.Vadivu & P.Subha, Assistant Professor, SRM University, Kattankulathur 8/22/2011School of Computing, Department of IT.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 12: Query Processing.
Linked Lists. Please Read These slides are provided for the use of students enrolled in James Durbanos Data Structures class (CISC 220). They are the.
David Luebke 1 6/1/2014 CS 332: Algorithms Medians and Order Statistics Structures for Dynamic Sets.
© Richard Jones, 1999BCS Advanced Programming SG: Garbage Collection 14 October Garbage Collection Richard Jones Computing Laboratory University.
Chapter 14 Query Optimization. ©Silberschatz, Korth and Sudarshan14.2Database System Concepts 3 rd Edition Chapter 14: Query Optimization Introduction.
1 How to Factor Quadratics of the Form ax 2 + bx + c.
A. as is a couldn’t does could has wouldn’t.
Outline lecture Revise arrays Entering into an array Totalling values in an array Sequential search.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 10: Storage and.
An introduction to pointers in c Pointers are Great!!! Pointers: are extremely powerful make some things much easier improve your program's efficiency.
Divide-and-Conquer CIS 606 Spring Analyzing Divide-and-Conquer Algorithms Use a recurrence to characterize the running time of a divide-and-conquer.
Search Engines Information Retrieval in Practice All slides ©Addison Wesley, 2008.
Caged Across – I IV and V Main chords. Working across rather than up the neck Will start in the key of G major. The 3 principle chords in any key are.
CS0007: Introduction to Computer Programming Arrays: Higher Dimensional Arrays.
© 2016 SlidePlayer.com Inc. All rights reserved.