data structures overview practice fixedlengthqueue
play

Data Structures Overview/Practice FixedLengthQueue Introduction to - PowerPoint PPT Presentation

Data Structures Overview/Practice FixedLengthQueue Introduction to Markov Chaining Check Checkout out DataStruc DataStructures ures project from SVN project from SVN It's nothing new Curt did it last term. Most Minesweeper work


  1. Data Structures Overview/Practice FixedLengthQueue Introduction to Markov Chaining Check Checkout out DataStruc DataStructures ures project from SVN project from SVN

  2. � It's nothing new – Curt did it last term. Most Minesweeper work will be out of class. Most Markov work in-class

  3. � Markov has usually been a pair assignment (and that's probably ideal). � But I don't want you to have to flit between two teams, so I am having you do Markov with your same team. � This is potentially dangerous: ◦ Be sure that you and the rest of your team understand everything that is going on. More details on Markov later today.

  4. � Array List � Linked List � Stack � Queue � Set � Map Implementations for all of these are provided by the Java Collections Framework in the java.util package.

  5. Operations Operations Array List Array List Linked List Linked List Provided Provided Efficiency Efficiency Efficiency Efficiency Random access O(1) O(n) Add/remove item O(n) O(1) Next Week we will discuss implementations. Q1

  6. � A last-in, first-out (LIFO) data structure � Real-world stacks ◦ Plate dispensers in the cafeteria ◦ Pez dispenser � Some uses: ◦ Tracking paths through a maze ◦ Providing “unlimited undo” in an application Implemented by Operations Operations Efficiency Efficiency Stack , Provided Provided LinkedList , and Push item O(1) ArrayDeque in Pop item O(1) Java Q1

  7. � A first-in, first-out (FIFO) data structure � Real-world queues Can implement as a ◦ Waiting line at the BMV (growable) "circular" array ◦ Waiting for customer http://maven.smith.edu/~str service at Dell.com einu/Teaching/Courses/112/ Applets/Queue/myApplet.ht � Some uses: ml ◦ Scheduling access to shared resource (e.g., printer) Operations Operations Efficiency Efficiency Implemented by Provided Provided LinkedList and ArrayDeque in Java Enqueue item O(1) Dequeue item O(1) Q1

  8. � Unordered Unordered collections without duplicates without duplicates � Real-world sets But the Java TreeSet ◦ Students implementation of the Set ◦ Collectibles interface does keep its items � Some uses: ordered. ◦ Quickly checking if an item is in a collection Operations Operations HashSet ashSet TreeSet TreeSet Add/remove item O(1) O(log n) Contains? O(1) O(log n) Q1 Can hog space Sorts items!

  9. � Associate keys keys with values values � Real-world “maps” ◦ Dictionary ◦ Phone book � Some uses: ◦ Associating student ID with transcript ◦ Associating name with high scores Operations Operations Hash ashMap ap TreeMap TreeMap Insert key-value pair O(1) O(lg n) Look up value for key O(1) O(lg n) Q1 Can hog space Sorts items by key!

  10. � In the DataS DataStructures ructures Project � Do the ToDo items � Talk with someone else � Get help from instructor/TA � If you don't finish now, finish for HW.

  11. Demonstration

  12. � Input: a text file the skunk jumped over the stump the stump jumped over the skunk the skunk said the stump stunk and the stump said the skunk stunk � Output: a randomly generated list of words that is “like” the original input in a well-defined way

  13. � Gather statistics on word patterns by building an appropriate data structure � Use the data structure to generate random text that follows the discovered patterns

  14. Prefix Prefix Suffixes Suffixes � Input: a text file NONWORD the the skunk jumped over the the skunk jumped over the stum stump the skunk (4), the stump jumped over the the stump jumped over the skunk skunk stump (4) the skunk said the stump stunk the skunk said the stump stunk jumped, said, skunk and the stump said the skunk stunk and the stump said the skunk stunk stunk, the jumped over (2) over the (2) stump jumped, said, stunk, the said the (2) and, stunk NONWORD and the

  15. � Input: a text file Prefix Prefix Suffixes Suffixes the skunk jumped over the the skunk jumped over the stum stump NW NW the the stump jumped over the the stump jumped over the skunk skunk NW the skunk the skunk said the stump stunk the skunk said the stump stunk jumped, the skunk and the stump said the skunk stunk and the stump said the skunk stunk said, the, stunk skunk jumped over jumped over the stump, over the skunk the, jumped, the stump stunk, said …

  16. � n=2: � n=1: the skunk said the the skunk the skunk stump stunk and the jumped over the stump jumped over skunk stunk the skunk jumped over the skunk stunk � Note: it’s also possible to hit the the skunk stunk max before you hit the last nonword.

  17. � For the prefixes? Prefix Prefix Suffixes Suffixes NW NW the � For the set of suffixes? NW the skunk jumped, the skunk said, the, � To relate them? stunk skunk jumped over jumped over the stump, over the skunk the, jumped, the stump stunk, said …

  18. � The Markov and FixedLengthQueue projects are in your team repository: � Check them out.

  19. � FixedLengthQueue: a specialized data structure, useful for Markov problem � Work with your team to implement it in the next 25 minutes or so. � Then Then read (twice) and begin digesting the Markov assignment � It's in several inter-linked documents � Discuss it with your team

  20. Review HW description, Teams work on FixedLengthQueue/Markov for rest of class

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend