PUSH - PowerPoint PPT Presentation

About This Presentation
Title:

PUSH

Description:

APPENDED TO POSTFIX AS SOON AS. THAT OPERAND IS ENCOUNTERED IN. INFIX. INFIX POSTFIX ... y' IS APPENDED TO POSTFIX. WHAT. HAPPENS WHEN -' IS ACCESSED? INFIX ... – PowerPoint PPT presentation

Number of Views:79
Avg rating:3.0/5.0
Slides: 136
Provided by: WILLIAM944
Category:
Tags: push | appended

less

Transcript and Presenter's Notes

Title: PUSH


1
(No Transcript)
2
(No Transcript)
3
(No Transcript)
4
PUSH MATT
5
MATT
FRONT
BACK
6
PUSH ANDREW
7
MATT
ANDREW
FRONT
BACK
8
PUSH SAMIRA
9
SAM IRA
MATT
ANDREW
FRONT
BACK
10
POP
11
SAM IRA
ANDREW
FRONT
BACK
12
(No Transcript)
13
(No Transcript)
14
(No Transcript)
15
(No Transcript)
16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
19
DETERMINE THE OUTPUT FROM THE FOLLOWING queuelt
intgt my_queue for (int i 0 i lt 10 i)
my_queue.push (i i) while (!my_queue.empty())
cout ltlt my_queue.front() ltlt endl
my_queue.pop() // while
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
(No Transcript)
26
A SYSTEM IS A COLLECTION OF INTERACTING PARTS.
27
A MODEL IS A SIMPLIFICATION OF A SYSTEM.
THE PURPOSE OF BUILDING A MODEL IS TO STUDY THE
UNDERLYING SYSTEM.
28
(No Transcript)
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
32
(No Transcript)
33
(No Transcript)
34
(No Transcript)
35
(No Transcript)
36
(No Transcript)
37
(No Transcript)
38
(No Transcript)
39
(No Transcript)
40
(No Transcript)
41
(No Transcript)
42
(No Transcript)
43
(No Transcript)
44
(No Transcript)
45
(No Transcript)
46
(No Transcript)
47
(No Transcript)
48
(No Transcript)
49
(No Transcript)
50
(No Transcript)
51
(No Transcript)
52
(No Transcript)
53
(No Transcript)
54
(No Transcript)
55
(No Transcript)
56
(No Transcript)
57
(No Transcript)
58
(No Transcript)
59
(No Transcript)
60
(No Transcript)
61
(No Transcript)
62
(No Transcript)
63
(No Transcript)
64
(No Transcript)
65
(No Transcript)
66
(No Transcript)
67
(No Transcript)
68
(No Transcript)
69
(No Transcript)
70
STACKS
71
(No Transcript)
72
(No Transcript)
73
(No Transcript)
74
(No Transcript)
75
(No Transcript)
76
(No Transcript)
77
(No Transcript)
78
(No Transcript)
79
(No Transcript)
80
(No Transcript)
81
(No Transcript)
82
(No Transcript)
83
(No Transcript)
84
(No Transcript)
85
(No Transcript)
86
DETERMINE THE OUTPUT FROM THE FOLLOWING stacklt
intgt my_stack for (int i 0 i lt 10 i)
my_stack.push (i i) while (!my_stack.empty())
cout ltlt my_stack.top() ltlt endl
my_stack.pop() // while
87
(No Transcript)
88
(No Transcript)
89
(No Transcript)
90
STACK APPLICATION 1 HOW COMPILERS IMPLEMENT
RECURSION
91
(No Transcript)
92
EACH ACTIVATION RECORD CONTAINS 1. A VARIABLE
THAT CONTAINS THE RETURN ADDRESS IN THE CALLING
METHOD 2. FOR EACH VALUE FORMAL PARAMETER, A
VARIABLE THAT CONTAINS A COPY OF THE
ARGUMENT 3. FOR EACH REFERENCE FORMAL
PARAMETER, A VARIABLE THAT CONTAINS THE
ADDRESS OF THE ARGUMENT 4. FOR EACH
VARIABLE DEFINED IN THE METHODS BLOCK, A
VARIABLE THAT CONTAINS A COPY OF THAT DEFINED
VARIABLE.             
                 
                 
                 
 
93
       
THERE IS A RUN-TIME STACK TO HANDLE THESE
ACTIVATION RECORDS. PUSH WHEN FUNCTION IS
CALLED POP WHEN EXECUTION OF FUNCTION
IS COMPLETED             
94
AN ACTIVATION RECORD IS SIMILAR TO AN EXECUTION
FRAME, EXCEPT THAT AN ACTIVATION RECORD HAS
VARIABLES ONLY, NO CODE. YOU CAN REPLACE
RECURSION WITH ITERATION BY CREATING YOUR OWN
STACK.
95
(No Transcript)
96
(No Transcript)
97
(No Transcript)
98
STACK APPLICATION 2
CONVERTING FROM INFIX
TO POSTFIX
99
IN INFIX NOTATION, AN OPERATOR IS PLACED BETWEEN
ITS OPERANDS. a b c d (e f g h) /
i
100
OLD COMPILERS INFIX MACHINE
LANGUAGE THIS GETS MESSY BECAUSE OF
PARENTHESES. NEWER COMPILERS INFIX
POSTFIX MACHINE LANGUAGE
101
IN POSTFIX NOTATION, AN OPERATOR IS PLACED
IMMEDIATELY AFTER ITS OPERANDS. INFIX POSTFIX
a b ab a b c abc a b
c abc (a b) c abc
102
PARENTHESES ARE NOT NEEDED, AND NOT USED, IN
POSTFIX.
103
LETS CONVERT AN INFIX STRING TO A POSTFIX
STRING.      x y z      
104
POSTFIX PRESERVES THE ORDER OF OPERANDS, SO AN
OPERAND CAN BE APPENDED TO POSTFIX AS SOON
AS THAT OPERAND IS ENCOUNTERED IN INFIX.
105
INFIX POSTFIX x y z x
106
INFIX POSTFIX x y z x THE
OPERANDS FOR - ARE NOT YET IN POSTFIX, SO -
MUST BE TEMPORARILY SAVED SOMEWHERE.
107
INFIX POSTFIX x y z xy
108
INFIX POSTFIX x y z xy THE
OPERANDS FOR ARE NOT YET IN POSTFIX, SO
MUST BE TEMPORARILY SAVED SOMEWHERE, AND RESTORED
BEFORE -.
109
INFIX POSTFIX x y z xyz
110
INFIX POSTFIX x y z xyz
111
SUPPOSE, INSTEAD, WE STARTED WITH xy-z. AFTER
MOVING x TO POSTFIX, IS TEMPORARILY SAVED,
AND THEN y IS APPENDED TO POSTFIX. WHAT HAPPENS
WHEN - IS ACCESSED?
INFIX POSTFIX x y z xy
112
(No Transcript)
113
THE TEMPORARY STORAGE FACILITY IS A STACK. HERE
IS THE STRATEGY FOR MAINTAINING THE STACK
114
(No Transcript)
115
INFIX GREATER, PUSH
116
CONVERT FROM INFIX TO POSTFIX INFIX POSTFIX
a b c / d - e
117
INFIX POSTFIX a b c / d e
abcd/e
-
/


OPERATOR STACK
118
(No Transcript)
119
CONVERT TO POSTFIX x (y z)
120
(No Transcript)
121
(No Transcript)
122
(No Transcript)
123
(No Transcript)
124
(No Transcript)
125
TOKENS
126
(No Transcript)
127
(No Transcript)
128
(No Transcript)
129
(No Transcript)
130
(No Transcript)
131
(No Transcript)
132
(No Transcript)
133
(No Transcript)
134
(No Transcript)
135
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com