Data Structures Practice Introduction to Markov Chaining Checkout - - PowerPoint PPT Presentation

data structures practice introduction to markov chaining
SMART_READER_LITE
LIVE PREVIEW

Data Structures Practice Introduction to Markov Chaining Checkout - - PowerPoint PPT Presentation

Data Structures Practice Introduction to Markov Chaining Checkout DataStructures project from SVN Array List Linked List Stack Queue Set Map Implementations for all of these are provided by the Java Collections Framework


slide-1
SLIDE 1

Data Structures Practice Introduction to Markov Chaining

Checkout DataStructures project from SVN

slide-2
SLIDE 2
slide-3
SLIDE 3

 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.

slide-4
SLIDE 4

Op Operati ations

  • ns

Prov

  • vide

ided Array List Efficie cienc ncy Linke nked d List Efficie cienc ncy Random access O(1) O(n) Add/remove item O(n) O(1) Q1,2

slide-5
SLIDE 5

 A last-in, first-out (LIFO) data structure  Real-world stacks

  • Plate dispensers in the cafeteria
  • Pancakes!

 Some uses:

  • Tracking paths through a maze
  • Providing “unlimited undo” in an application

Operati ations

  • ns

Prov

  • vid

ided Efficie cienc ncy Push item O(1) Pop item O(1)

Implemented by Stack, LinkedList, and ArrayDeque in Java

Q3

slide-6
SLIDE 6

 A first-in, first-out (FIFO) data structure  Real-world queues

  • Waiting line at the BMV
  • Character on Star Trek TNG

 Some uses:

  • Scheduling access to shared resource (e.g., printer)

Operati ations

  • ns

Prov

  • vid

ided Efficie cienc ncy Enqueue item O(1) Dequeue item O(1)

Implemented by LinkedList and ArrayDeque in Java

Q4

slide-7
SLIDE 7

 Unorder

rdered ed collections wi without t duplic icate ates

 Real-world sets

  • Students
  • Collectibles

 Some uses:

  • Quickly checking if an item is in a collection

Op Operati ations

  • ns

HashS hSet et Tr TreeSet Add/remove item O(1) O(lg n) Contains? O(1) O(lg n)

Can hog space Sorts items!

Q5

slide-8
SLIDE 8

 Associate keys with va

values es

 Real-world “maps”

  • Dictionary
  • Phone book

 Some uses:

  • Associating student ID with transcript
  • Associating name with high scores

Op Oper erati ations

  • ns

HashMap hMap Tr Tree eeMap ap Insert key-value pair O(1) O(lg n) Look up value for key O(1) O(lg n)

Can hog space Sorts items by key!

Q6

slide-9
SLIDE 9

The only blood these contracts are signed in is from me cutting my hand trying to open the d@^mned CD case.

slide-10
SLIDE 10

Demonstration

slide-11
SLIDE 11

 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

slide-12
SLIDE 12

 Gather statistics on word patterns by building

an appropriate data structure

 Use the data structure to generate random

text that follows the discovered patterns

slide-13
SLIDE 13

 Input: a text file

the e skunk nk jumped mped ove ver the stump the e stump p jumped mped ove ver the skunk nk the e skunk nk said the stump mp stunk k and d the stump mp said the skunk nk stunk nk Prefix Suffix ffixes NONWORD the the skunk (4), stump (4) skunk jumped, said, stunk, the jumped

  • ver (2)
  • ver

the (2) stump jumped, said, stunk, the said the (2) stunk and, NONWORD and the

slide-14
SLIDE 14

 Input: a text file

the e skunk nk jumped mped ove ver the stump the e stump p jumped mped ove ver the skunk nk the e skunk nk said the stump mp stunk k and d the stump mp said the skunk nk stunk nk Prefi fix Suffixe fixes NW NW the NW the skunk the skunk jumped, said, the, stunk skunk jumped

  • ver

jumped over the

  • ver the

stump, skunk the stump the, jumped, stunk, said …

slide-15
SLIDE 15

 n=1:

the skunk the skunk jumped over the skunk stunk the skunk stunk

 n=2:

the skunk said the stump stunk and the stump jumped over the skunk jumped

  • ver the skunk stunk

 Note: it’s also

possible to hit the max before you hit the last nonword.

slide-16
SLIDE 16

 For the prefixes?  For the set of suffixes?  To relate them?

Prefi fix Suffixe fixes NW NW the NW the skunk the skunk jumped, said, the, stunk skunk jumped

  • ver

jumped over the

  • ver the

stump, skunk the stump the, jumped, stunk, said …

slide-17
SLIDE 17

 The Markov assignment template is in a new

repository:

 where n is:  Make sure you can attach to the new

repository now, get help if stuck

http://svn.cs.rose-hulman.edu/repos/csse220-200910-team2n

n 1 Alice and Steve 2 Gardner and Cory 3 Joe and Sam

slide-18
SLIDE 18

 FixedLengthQueue: a specialized data

structure, useful for Markov problem

 Check out FixedLengthQueue  Work with your Markov partner to implement

it in the next 25 minutes or so

 Then read (twice) and begin digesting the

Markov assignment

 Discuss it with your partner

slide-19
SLIDE 19

Review HW description, Partners work on Markov for rest of class