1 / 10

Data Structures

Data Structures. Data Structures. How long an algorithm takes often depends on how the data is organized Different data structures will give different running times It’s important to use the appropriate data structure for your task. Linear Structures. Arrays A ccess any element in O(1) time

kent
Download Presentation

Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures

  2. Data Structures How long an algorithm takes often depends on how the data is organized Different data structures will give different running times It’s important to use the appropriate data structure for your task

  3. Linear Structures • Arrays • Access any element in O(1) time • Inserting and Deleting an element can cost O(n) time • The underlying structure for others, like Strings • Linked list • Singly or doubly linked • Node with pointer to next one • Access first in list in O(1) time • Access general element in O(n) time • Insert and Delete in O(1) time

  4. Linear Structures • Stack • FILO • Queue • FIFO • Priority Queue • Each element given priority, and elements are deleted in priority order These are all implemented using some other structure, like an array.

  5. Graphs Collection of nodes (or vertices) and edges May be directed or undirected May or may not have a loop May or may not be weighted Are usually connected We talk about paths in the graph and simple paths

  6. Trees A type of graph: A connected, acyclic graph Refer to its root and leaves Refer to parents, children, ancestors, descendants, and siblings Have height, have subtrees |E| = |V| -1

  7. Binary Tree Tree with at most 2 children for each node Usually draw root at the top Can be complete, or full

  8. Sets Unordered collection No duplicates allowed (elements are distinct) Should support membership, union, and intersection

  9. Dictionary Way to look up key, value pairs Must support adding and deleting elements Usually thought of as either “associative arrays” or a hash table (HashMap in Java) Carol 123 Junior 424 Hope 829 Bob 701

  10. What data structure? Receive calls and answer them in the order they were received Send backlog orders to customers based on the priority of the order Represent the layout of city streets, compute the route from point A to point B

More Related