Math Review - Proof By Induction - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Math Review - Proof By Induction

Description:

CS 340. Chapter 3: Lists, Stacks, and Queues. 1. ADT #2: The Stack ... CS 340. Chapter 3: Lists, Stacks, and Queues. 2. Example Stack Application: Arithmetic ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 8
Provided by: william746
Category:
Tags: com | cs | induction | math | proof | review

less

Transcript and Presenter's Notes

Title: Math Review - Proof By Induction


1
ADT 2 The Stack
A stack is a list in which insertions and
removals can only transpire at one end of the
list, i.e., the top of the stack.
2
Example Stack Application Arithmetic Expressions
Stacks can be used to convert infix expressions
into postfix expressions
Following these rules, then, the infix expression
7 6 - 3 ( 5 8 / 2 ) is converted into the
postfix expression 7 6 3 5 8 2 / -
3
Arithmetic Expression Evaluation (continued)
Then a separate stack can be used to evaluate the
postfix expression
Following these rules with the postfix expression
7 6 3 5 8 2 / - yields
7
13
-14
4
Stack Implementation Alternatives
  • An Array Implementation
  • Positives
  • Avoids pointers
  • Trivial implementation
  • Negatives
  • Size must be declared in advance
  • A Linked List Implementation
  • Positives
  • Dynamically allocates exactly the right amount of
    memory
  • Straightforward (if not quite trivial)
    implementation
  • Negatives
  • Those wonderful pointers

5
ADT 3 The Queue
A queue is a list in which insertions can only
occur at one end of the list (the front of the
queue) and removals can only occur at the
opposite end of the list (the back of the queue).
6
Example Queue Application Server Access
The first-come, first-served nature of the
queue ADT can be adapted to providing orderly
access to file servers, print servers, Web
servers, etc.
7
Queue Implementation Alternatives
  • An Array Implementation
  • Positives
  • Avoids pointers
  • Negatives
  • Size must be declared in advance
  • Wraparound is needed to avoid false overflows
  • A Linked List Implementation
  • Positives
  • Dynamically allocates exactly the right amount of
    memory
  • Wraparound problem is circumvented
  • Negatives
  • Our friendly neighborhood pointers
Write a Comment
User Comments (0)
About PowerShow.com