Lecture9

Lecture9 - Algorithms in Systems Engineering IE170 Lecture...

This preview shows pages 1–7. Sign up to view the full content.

Algorithms in Systems Engineering IE170 Lecture 9 Dr. Ted Ralphs

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
IE170 Lecture 9 1 References for Today’s Lecture Required reading CLRS Chapter 12 References D.E. Knuth, The Art of Computer Programming, Volume 3: Sorting and Searching (Third Edition), 1998. R. Sedgewick, Algorithms in C++ (Third Edition), 1998.
IE170 Lecture 9 2 Symbol Tables and Dictionaries In the last few lectures, we discussed various methods for sorting a list of items by a speciﬁed key. We now consider further operations on such lists. A symbol table is a data structure for storing a list of items, each with a key and satellite data , supporting the following basic operations. Construct a symbol table. Search for an item (or items) having a speciﬁed key. Insert an item. Remove a speciﬁed item. Count the number of items. Print the list of items. Symbol tables are also called dictionaries because of the obvious comparison with looking up entries in a dictionary. Note that the keys may not have an ordering.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
IE170 Lecture 9 3 Additional Operations on Symbol Tables If the items can be ordered, e.g., by operator< and operator == , we may support the following additional operations. Sort the items (print them in sorted order). Return the maximum or minimum item. Select the k th item. Return the successor or predecessor of a given item. We may also want to be able to join two symbol tables into one. These operations may or may not be supported in various implementations.
IE170 Lecture 9 4 Applications of Symbol Tables What are some applications of symbol tables?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
IE170 Lecture 9 5 Symbol Tables with Integer Keys Consider a list of items whose keys are small positive integers. Assuming no duplicate keys, we can implement such a symbol table using an array. class sybmolTable { private: symbolTable(); \\ Disable the default constructor Item** st_; \\ An array of pointers to the items const int maxKey_; \\ The maximum allowed value of a key public: symbolTable (const int M); \\ Constructor ~symbolTable (); \\ Destructor int getNumItems() const; Item* search (const int k) const; Item* select (int k) const; void insert (Item* it); void remove (Item* it); void sort (ostream& os);
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 18

Lecture9 - Algorithms in Systems Engineering IE170 Lecture...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online