Linear Data Structures 1.7

Linear Data Structures 1.7 - Last Updated: 12-01-17 9:52 AM...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 31 - Applications of Stacks • Page-visited history in a Web browser • Undo sequence in a text editor • Chain of method calls in the Java Virtual Machine • Parsing math Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 32 - Method Stack in the JVM • The Java Virtual Machine (JVM) keeps track of the chain of active methods with a stack • When a method is called, the JVM pushes on the stack a frame containing – Local variables and return value – Program counter, keeping track of the statement being executed • When a method ends, its frame is popped from the stack and control is passed to the method on top of the stack • Allows for recursion main () { int i = 5; foo(i); } foo (int j) { int k; k = j+1; bar(k); } bar (int m) { … } bar PC = 1 m = 6 foo PC = 3 j = 5 k = 6 main PC = 2 i = 5 Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 33 - Array-based Stack • The Stack ADT can be implemented with...
View Full Document

This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

Page1 / 5

Linear Data Structures 1.7 - Last Updated: 12-01-17 9:52 AM...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online