O(log n) bits or atomic elements

Slides:



Advertisements
Similar presentations
Gerth Stølting Brodal University of Aarhus Monday June 9, 2008, IT University of Copenhagen, Denmark International PhD School in Algorithms for Advanced.
Advertisements

Priority Queues  MakeQueuecreate new empty queue  Insert(Q,k,p)insert key k with priority p  Delete(Q,k)delete key k (given a pointer)  DeleteMin(Q)delete.
Msb(x) in O(1) steps using 5 multiplications Word size n = g∙g, g a power of 2 [M.L. Fredman, D.E. Willard, Surpassing the information-theoretic bound.
Time O(log d) Exponential-search(13) Finger Search Searching in a sorted array time O(log n) Binary-search(13)
Chapter 6: Transform and Conquer
Merge Sort1 Part-G1 Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
Merge Sort1 7 2  9 4   2  2 79  4   72  29  94  4.
1 Self-Adjusting Data Structures. 2 Lists [D.D. Sleator, R.E. Tarjan, Amortized Efficiency of List Update Rules, Proc. 16 th Annual ACM Symposium on Theory.
Hierarchy-conscious Data Structures for String Analysis Carlo Fantozzi PhD Student (XVI ciclo) Bioinformatics Course - June 25, 2002.
Review. What to know You are responsible for all material covered in lecture, the readings, or the programming assignments There will also be some questions.
Computer Science Day 2008 Algorithms and Data Structures for Faulty Memory Gerth Stølting Brodal Department of Computer Science, University of Aarhus,
Update 1 Persistent Data Structures (Version Control) v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 Ephemeral query v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 Partial persistence.
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.
1 Balanced Search Trees  several varieties  AVL trees  trees  Red-Black trees  B-Trees (used for searching secondary memory)  nodes are added.
Lec 6 Feb 17, 2011  Section 2.5 of text (review of heap)  Chapter 3.
Fully Persistent B-Trees 23 rd Annual ACM-SIAM Symposium on Discrete Algorithms, Kyoto, Japan, January 18, 2012 Gerth Stølting Brodal Konstantinos Tsakalidis.
© 2006 Pearson Addison-Wesley. All rights reserved12 A-1 Chapter 12 Heaps.
Cache Oblivious Search Trees via Binary Trees of Small Height
Heaps and heapsort COMP171 Fall 2005 Part 2. Sorting III / Slide 2 Heap: array implementation Is it a good idea to store arbitrary.
B-Trees (continued) Analysis of worst-case and average number of disk accesses for an insert. Delete and analysis. Structure for B-tree node.
MergeSort Source: Gibbs & Tamassia. 2 MergeSort MergeSort is a divide and conquer method of sorting.
CSCE 3110 Data Structures & Algorithm Analysis Binary Search Trees Reading: Chap. 4 (4.3) Weiss.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Notice: Changed TA Office hour Thursday 11am-1pm  noon-2pm.
Binomial Queues Text Read Weiss, §6.8 Binomial Queue Definition of binomial queue Definition of binary addition Building a Binomial Queue Sequence of inserts.
Time O(log d) Exponential-search(13) Finger Search Searching in a sorted array time O(log n) Binary-search(13)
Data Structures and Algorithms Lecture (BinaryTrees) Instructor: Quratulain.
Computer Sciences Department1. Sorting algorithm 3 Chapter 6 3Computer Sciences Department Sorting algorithm 1  insertion sort Sorting algorithm 2.
B + -Trees Same structure as B-trees. Dictionary pairs are in leaves only. Leaves form a doubly-linked list. Remaining nodes have following structure:
CSCE 3110 Data Structures & Algorithm Analysis AVL Trees Reading: Chap. 4, Weiss.
Sorting Lower Bounds Amihood Amir Bar-Ilan University 2014.
Outline Priority Queues Binary Heaps Randomized Mergeable Heaps.
Binary SearchTrees [CLRS] – Chap 12. What is a binary tree ? A binary tree is a linked data structure in which each node is an object that contains following.
An experimental study of priority queues By Claus Jensen University of Copenhagen.
CSED101 INTRODUCTION TO COMPUTING TREE 2 Hwanjo Yu.
Λίστα Εργασιών External Memory Data Structures Vitter, J. S. and Shriver, E. 1994a. Algorithms for parallel memory I: Two-level memories. Algorithmica.
CH 8. HEAPS AND PRIORITY QUEUES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
B-Tree – Delete Delete 3. Delete 8. Delete
Computer Science and Software Engineering University of Wisconsin - Platteville 8. Comparison of Algorithms Yan Shi CS/SE 2630 Lecture Notes Part of this.
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.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
HEAPS Amihood Amir Bar Ilan University Sorting Bubblesort: Until no exchanges: For i=1 to n-1 if A[i]>A[i+1] then exchange their values end Time.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
8 January Heap Sort CSE 2011 Winter Heap Sort Consider a priority queue with n items implemented by means of a heap  the space used is.
Lecture 15 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Equivalence Between Priority Queues and Sorting in External Memory
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
Priority Search Trees Keys are pairs (x,y). Basic (search, insert, delete) and rectangle operations. Two varieties.  Based on a balanced binary search.
Exam 3 Review Data structures covered: –Hashing and Extensible hashing –Priority queues and binary heaps –Skip lists –B-Tree –Disjoint sets For each of.
1Computer Sciences. 2 HEAP SORT TUTORIAL 4 Objective O(n lg n) worst case like merge sort. Sorts in place like insertion sort. A heap can be stored as.
Dynamic Dictionaries Primary Operations:  get(key) => search  put(key, element) => insert  remove(key) => delete Additional operations:  ascend()
1 Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
B-Trees Katherine Gurdziel 252a-ba. Outline What are b-trees? How does the algorithm work? –Insertion –Deletion Complexity What are b-trees used for?
Heap Sort Uses a heap, which is a tree-based data type Steps involved: Turn the array into a heap. Delete the root from the heap and insert into the array,
Internal Memory Pointer MachineRandom Access MachineStatic Setting Data resides in records (nodes) that can be accessed via pointers (links). The priority.
Memory Hierarchies [FLPR12] Matteo Frigo, Charles E. Leiserson, Harald Prokop, Sridhar Ramachandran. Cache- Oblivious Algorithms. ACM Transactions on Algorithms,
More Trees. Outline Tree B-Tree 2-3 Tree Tree Red-Black Tree.
(A Survey on) Priority Queues IanFest, University of Waterloo, Waterloo, Ontario, Canada, August 14-15, 2013 Gerth Stølting Brodal Aarhus Universty.
The Implicit ModelA Moveable DictionaryA Working Set Dictionary The implicit model is the RAM model but with some restrictions: you are only allowed to.
Self-Adjusting Data Structures
List Order Maintenance
Experimental evaluation of Navigation piles
Persistent Data Structures (Version Control)
Binary Search Tree Chapter 10.
COMP 103 HeapSort Thomas Kuehne 2013-T1 Lecture 27
MergeSort Source: Gibbs & Tamassia.
Sorting.
Dr.Surasak Mungsing CSE 221/ICT221 Analysis and Design of Algorithms Lecture 05-2: Analysis of time Complexity of Priority.
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

O(log n) bits or atomic elements Implicit model atomic elements CPU, O(1) registers O(log n) bits or atomic elements 1 x1 2 x2 3 x3 4 x4 5 x5 xn-1 n xn - XOR OR write shift-left + * ≤ shift-right Memory, n words read ... NOT AND only allowed operation on elements # reads Complexity = + # writes + # instructions performed Inaccessible

Sorting Search trees O(n∙log n) Yes O(n2) O(n) No O(log n) Comparisons Data moves/writes Implicit HeapSort O(n∙log n) Yes SelectionSort O(n2) O(n) SearchTree No [FG05] Implicit priority queue [G. Franceschini, V. Geffert, An in-place sorting with O(n log n) comparisons and O(n) moves, J.ACM, 52(4), 515-537, 2005] Search trees Search & updates Range searching Implicit Cache-oblivious Red-black, ... O(log n) O(log n + t) No Sorted array Yes [FG02] [FG03] - [BFJ02], ... (no updates) Open problems Worst-case range searching + cache oblivious Range searching+ implicit + cache oblivious am. [G. Franceschini, R. Grossi, Optimal Cache-Oblivious Implicit Dictionaries, Proc. 30th International Colloquium on Automata, Languages, and Programming, volume 2719 of Lecture Notes in Computer Science, 316-331, Springer-Verlag, 2003.] [G. Franceschini, R. Grossi, J.I. Munro, L. Pagli. Implicit B-trees: New results for the dictionary problem. IEEE Symposium on Foundations of Computer Science, 145-154, 2002] [G.S. Brodal, R. Fagerberg, R. Jacob, Cache-Oblivious Search Trees via Binary Trees of Small Height, 13th Annual ACM-SIAM Symposium on Discrete Algorithms, 39-48, 2002]

The foundamental implicit trick The relative two elements x < y, can encode a bit = 0 = 1 2log n elements can encode integer {0,...,n-1} x y y x

Search trees O(log2 n) O(log2 n + t) Yes Search & updates Range searching Implicit O(log2 n) O(log2 n + t) Yes Search trees [J. Ian Munro, An Implicit Data Structure Supporting Insertion, Deletion, and Search in O(log² n) Time, Journal of Computer and System Sciences, 33(1), 66-74, 1986] Each nodes stores ..2-1 elements encoding the below fields (=8∙log n+2) Red-black search tree x x x x x x field values encoded by #elements left (address) 0,1,..., n-1 2∙log n right (address) parent(address) color (red/black) 0,1 2 node size s 0,1,...,n-1 x x x x x x x x x x x x x x x x x ps mod s = 0 root ps qs ps-1 qs-1 ps-2 qs-2 ps-4 qs-4 ps-3 =qs-3 p2-1 =q2-1 s s-1 s-2 s-4 gap xxxxxx xxxxx xxxx xx root p2-1,q2-1,... ,p,q (2+1)∙log n s ∙ (1 + # size-s-nodes) Total gap: 2+(2-1)+∙ ∙ ∙+ = arbitrary elements

Implicit merging O(n + m) can be used in an implicit O(n∙log n) MergeSort 2 4 5 7 9 11 3 6 8 14 n m 2 3 4 5 6 7 8 9 11 14 (Honours project 2)