Lecture9

Lecture9 - Algorithms in Systems Engineering IE170 Lecture...

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

View Full Document Right Arrow Icon
Algorithms in Systems Engineering IE170 Lecture 9 Dr. Ted Ralphs
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
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 specified 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 specified key. Insert an item. Remove a specified 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.
Background image of page 3

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

View Full DocumentRight Arrow Icon
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.
Background image of page 4
IE170 Lecture 9 4 Applications of Symbol Tables What are some applications of symbol tables?
Background image of page 5

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

View Full DocumentRight Arrow Icon
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);
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online