checkout datastructures from svn understanding the
play

Checkout DataStructures from SVN Understanding the engineering - PowerPoint PPT Presentation

Data-structure-palooza Checkout DataStructures from SVN Understanding the engineering trade-offs when storing data Boil down data types (e.g., lists) to their essential operations Choosing a data structure for a project then becomes:


  1. Data-structure-palooza Checkout DataStructures from SVN

  2. Understanding the engineering trade-offs when storing data

  3.  Boil down data types (e.g., lists) to their essential operations  Choosing a data structure for a project then becomes: ◦ Identify the operations needed ◦ Identify the abstract data type that most efficiently supports those operations  Goal: that you understand several basic abstract data types and when to use them

  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. Ope pera ratio ions Arra rray L Lis ist Linke ked L d List t Prov ovide ided Effici cien ency cy Effici cien ency cy Random access O(1) O(n) Add/remove item O(n) O(1)

  6.  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 Ope pera ratio ions Effici cien ency cy Implemented by Prov ovide ided Stack , LinkedList kedList , Stac and ArrayDeque ayDeque in Push item O(1) Java Pop item O(1) Q1

  7.  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 tion ons P Prov ovide ided Effici cien ency cy Implemented by LinkedList and Add (enqueue, offer) item O(1) ArrayDeque in Remove (dequeue, poll) item O(1) Java Q2

  8.  Use if you need the  Uses “hash code” items to be sorte orted  O(1) to lookup, add or remove  Log(n) height of tree sam am joe oe ty ty, … ali li Binary Tree Hash Table

  9.  Collections with ithou out duplicates ates  Real-world sets ◦ Students ◦ Collectibles  Some uses: ◦ Quickly checking if an item is in a collection  Sorted? Depends on implementation! Ope pera ratio ions Hash Ha shSet Tr TreeS eeSet et Add/remove item O(1) O(log n) Contains? O(1) O(log n) Can hog space Sorts items! Q3

  10.  Associate keys ys with values es  Real-world “maps” ◦ Dictionary ◦ Phone book  Some uses: ◦ Associating student ID with transcript ◦ Associating name with high scores Ope pera ratio ions HashMa hMap Tr TreeM 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! Q4

  11.  Use if you need the  Uses “hash code” items to be sorte orted  O(1) to lookup, add or remove  Log(n) height of tree sam am joe oe ty ty, … ali li Binary Tree Hash Table

  12. Your chance to improve instruction, courses, and curricula.

  13. Q5 - 6

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