Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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 2 Stack ADT Data –A collection of homogeneous elements arranged in a sequence. –LIFO structure Operations –Push –Pop –Top –isEmpty

3 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 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 5 Queue ADT Data –A collection of homogeneous elements arranged in a sequence. –FIFO structure Operations –Enqueue –Dequeue –Front –isEmpty

6 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 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 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?


Download ppt "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."

Similar presentations


Ads by Google