good coders code, great reuse |
| MIT’s Introduction to Algorithms, Lecture 11: Augmenting Data Structures Posted: 29 Sep 2008 03:55 PM CDT
There are some programming situations that can be perfectly solved with standard data structures such as a linked lists, hash tables, or binary search trees. Many others require a dash of creativity. Only in rare situations will you need to create an entirely new type of data structure, though. More often, it will suffice to augment (to modify) an existing data structure by storing additional information in it. You can then program new operations for the data structure to support the desired application. Augmenting a data structure is not always straightforward, however, since the added information must be updated and maintained by the ordinary operations on the data structure. This lecture discusses two data structures that are constructed by augmenting red-black trees (see the previous post on red-black trees). The first part of the lecture describes a data structure that supports general order-statistic operations on a dynamic set. It’s called dynamic order statistics. The notion of order statistics was introduced in lecture six. In lecture six it was shown that any order statistic could be retrieved in O(n) time from an unordered set. In this lecture it is shown how red-black trees can be modified so that any order statistic can be determined in O(lg(n)) time. It presents two algorithms OS-Select(i), which returns i-th smallest item in a dynamic set, and OS-Rank(x), which returns rank (position) of element x in sorted order. The lecture continues with general methodology of how to augment a data structure. Augmenting a data structure can be broken into four steps:
The second part of the lecture applies this methodology to construct a data structure called interval trees. This data structure maintains a dynamic set of elements, with each element x containing an interval. Interval is simply pair of numbers (low, high). For example, a time interval from 3 o’clock to 7 o’clock is a pair (3, 7). Lecture gives an algorithm called Interval-Search(x), which given a query interval x, quickly finds an interval in the set that overlaps it. Time complexity of this algorithm is O(lg(n)). The lecture ends with the correctness proof of Interval-Search(x) algorithm. You’re welcome to watch lecture eleven: Topics covered in lecture eleven:
Lecture eleven notes: Have fun augmenting data structures! The next post will be about a simple and efficient search structure called skip list! PS. This course is taught from the CLRS book (also called “Introduction to Algorithms”): |
| You are subscribed to email updates from good coders code, great reuse To stop receiving these emails, you may unsubscribe now. | Email Delivery powered by FeedBurner |
| Inbox too full? | |
| If you prefer to unsubscribe via postal mail, write to: good coders code, great reuse, c/o FeedBurner, 20 W Kinzie, 9th Floor, Chicago IL USA 60610 | |
No comments:
Post a Comment
Keep a civil tongue.