12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

152 Chap. 4 Lists, Stacks, <strong>and</strong> Queues‘a’ ‘b’ ‘c’ 3 ‘h’ ‘e’ ‘l’ ‘l’ ‘o’ 5<strong>to</strong>p = 100 1 2 3 4 5 6 7 8 9 10Figure 4.32 An array-based stack s<strong>to</strong>ring variable-length strings. Each positions<strong>to</strong>res either one character or the length of the string immediately <strong>to</strong> the left of itin the stack.4.8 Define an ADT for a bag (see Section 2.1) <strong>and</strong> create an array-based implementationfor bags. Be sure that your bag ADT does not rely in any wayon knowing or controlling the position of an element. Then, implement thedictionary ADT of Figure 4.27 using your bag implementation.4.9 Implement the dictionary ADT of Figure 4.27 using an unsorted linked list asdefined by class LList in Figure 4.8. Make the implementation as efficientas you can, given the restriction that your implementation must use the unsortedlinked list <strong>and</strong> its access operations <strong>to</strong> implement the dictionary. Statethe asymp<strong>to</strong>tic time requirements for each function member of the dictionaryADT under your implementation.4.10 Implement the dictionary ADT of Figure 4.27 based on stacks. Your implementationshould declare <strong>and</strong> use two stacks.4.11 Implement the dictionary ADT of Figure 4.27 based on queues. Your implementationshould declare <strong>and</strong> use two queues.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!