This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 6.851: Advanced Data Structures Spring 2010 Lecture 8 March 2, 2010 Prof. Erik Demaine 1 Overview In the last lecture we studied sux trees and sux arrays. These two data structures are useful for answering a variety of queries on strings such as string matching, string frequency and longest repeating substring. They offer advantages over more generic data structures like binary search trees and hashes. We learned that a linear-time algorithm exists for converting between sux trees and sux arrays, and that there exists an algorithm for eciently constructing sux arrays, the DC3 algorithm. Finally, we studied a modification to sux arrays that allows one to perform document retrieval queries in O ( | P | + d ) time, where P is the pattern to search a set of documents for and d is the number of documents containing P . In todays lecture two problems are discussed: Level Ancestor Query (LAQ) and Least Common Ancestor (LCA). LAQ will be covered fully today, while LCA will be completed next lecture. Both problems have the same setting: given a rooted tree T and a node v , find an ancestor of v with some property. For LAQ, we will study various approaches with different preprocessing and query times, culminating in a data structure with O ( n ) preprocessing and O (1) query time. For LCA, we will study a different but related problem (Range Minimum Query or RMQ) which will help us to solve LCA. 2 Least Ancestor Queries (LAQ) First we introduce notation. Let h ( v ) be the height of a node v in a tree. Given a node v and level l , LAQ ( v,l ) is the ancestor a of v such that h ( a ) h ( v ) = l . Today we will study a variety of data structures with various preprocessing and query times which answer LAQ ( v,l ) queries. For a data structure which requires f ( n ) query time and g ( n ) preprocessing time, we will denote its running time as g ( n ) ,f ( n ) . The...
View Full Document
- Spring '10
- Data Structures