1 / 8

Data Organization

Data Organization. Example 1: A simple text editor Store the text buffer as a list of lines. How would we implement the UNDO operation? Example 2: Parsing How does the compiler check the syntax? Example 3: Bracket matching Example 4: Runtime storage organization. Stack ADT. Data

hgraber
Download Presentation

Data Organization

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 Organization • Example 1: A simple text editor • Store the text buffer as a list of lines. • How would we implement the UNDO operation? • Example 2: Parsing • How does the compiler check the syntax? • Example 3: Bracket matching • Example 4: Runtime storage organization

  2. Stack ADT • Data • A collection of homogeneous elements arranged in a sequence. • LIFO structure • Operations • Push • Pop • Top • isEmpty

  3. Stack ADT • Implementation • Contiguous memory • Which end of the array is the top of the stack? • Linked memory • Which end of the "list" is the top of the stack?

  4. Data Organization • Example 1: Discrete Event Simulation • Bank waiting line • Each new customer joins the end of the line • The next customer to walk up to a teller is the one at the front of the line • Run a sim to process arrival and departure events and collect information about waiting times. • Example 2: Process scheduling • Round-robin

  5. Queue ADT • Data • A collection of homogeneous elements arranged in a sequence. • FIFO structure • Operations • Enqueue • Dequeue • Front • isEmpty

  6. Queue ADT • Implementation • Contiguous memory • Which end of the array is the front/end? • Linked memory • Which end of the "list" is the front?

  7. A different kind of queue • Queues are used to model waiting lines. • In some situations (e.g. aircraft boarding), certain elements in a line (e.g. first class passengers) have a higher priority: the FIFO model is not strictly applicable. • We need a data structure similar to a queue, where elements are ordered, not based on arrival, but based on some priority.

  8. Priority queue I • Data • A collection of elements, where each element is assigned a priority • Efficient extraction of the highest-priority element should be supported. • Operations • Enqueue • Dequeue • GetMax • Implementation • How would you modify your regular queue implementation?

More Related