COMP 250 Lecture Notes - Lecture 17: Web Browser, Text Editor, Program Counter
Document Summary
List that allows only operations at one end of the list (called the top) Can be implemented in an efficient matter. Many problems can be solved using stacks. Direct applications: page-visited history in a web browser, undo sequence in a text editor, chain of method calls in the java virtual machine (program running in the background of your computer, that executes your program) Indirect applications: auxiliary data structure for algorithms, component of other data structures. The 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 method ends, its frame is popped from the stack and control is passed to the method on top of the stack. An integer top keeps track of the top of the stop. Capacity fixes the size of the array, hence the stack.