Stacks. Stacks (and Queues) Stacks. q Stack: what is it? q ADT. q Applications. q Implementation(s) CSCU9A3 1


 Brent Arnold
 3 years ago
 Views:
Transcription
1 Stacks (and Queues) 1 Stacks Stack: what is it? ADT Applications Implementation(s) 2 CSCU9A3 1
2 Stacks and ueues A stack is a very important data structure in computing science. A stack is a seuence of elements to which new elements are added (pushed), and from which elements are removed (popped), at the same end. Stack sometimes referred to as a last in, first out structure (LIFO). In a ueue, elements are removed from the opposite end to which they are added. Queue sometimes referred to as a first in, first out structure (FIFO). 3 Stacks and ueues The difference is the remove operation. add remove add remove 4 CSCU9A3 2
3 Last In First Out A top B A top C B A top D C B A top E D C B A top D C B A 5 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: n Data stored n Operations on the data n Error conditions associated with operations Example: ADT modeling a simple stock trading system n The data stored are buy/sell orders n The operations supported are w order buy(stock, shares, price) w order sell(stock, shares, price) w void cancel(order) n Error conditions: w Buy/sell a nonexistent stock w Cancel a nonexistent order 6 CSCU9A3 3
4 The Stack ADT The Stack ADT stores arbitrary objects Insertions and deletions follow the lastin firstout scheme Think of a springloaded plate dispenser. (Pez?) 7 The Stack ADT Main stack operations: n push(object): inserts an element n Object pop(): removes and returns the last inserted element Auxiliary stack operations: n Object peek(): returns the last inserted element without removing it. (Sometimes appears as Object top()) n integer size(): returns the number of elements stored n boolean isempty(): indicates whether no elements are stored 8 CSCU9A3 4
5 Stack Operations Assume a simple stack for integers. Stack s = new Stack(); s.push(12); s.push(4); s.push( s.top() + 2 ); s.pop() s.push( s.top() ); //what are contents of stack? 9 Stack usage and limitations Write an algorithm to Reverse the contents of an array. How about using a stack? Write a method to print out contents of stack in reverse order. 10 CSCU9A3 5
6 Stack Interface in Java Java interface corresponding to our Stack ADT Reuires the definition of class EmptyStackException Different from the builtin Java class java.util.stack public interface Stack<E> { public int size(); public boolean isempty(); public Object top() throws EmptyStackException; public void push(e element); public Object pop() throws EmptyStackException; 11 Exceptions Attempting the execution of an operation of ADT may sometimes cause an error condition, called an exception Exceptions are said to be thrown by an operation that cannot be executed In the Stack ADT, operations pop and top cannot be performed if the stack is empty Attempting the execution of pop or top on an empty stack throws an EmptyStackException 12 CSCU9A3 6
7 Applications of Stacks Direct applications n Pagevisited history in a Web browser n Undo seuence in a text editor n Chain of method calls in the Java Virtual Machine Indirect applications n Auxiliary data structure for algorithms n Component of other data structures 13 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 n Local variables and return value n 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 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 14 CSCU9A3 7
8 Arraybased Stack Allocate an array of some size (predefined) n Maximum N elements in stack Bottom stack element stored at element 0 last index in the array is the top n What is index when stack is empty? Increment top when one element is pushed, decrement after pop 15 Arraybased Stack Algorithm size() return top + 1 Algorithm pop() if isempty() then throw EmptyStackException else top top  1 return S[top + 1] S t 16 CSCU9A3 8
9 Arraybased Stack (cont.) The array storing the stack elements may become full A push operation will then throw a FullStackException n Limitation of the arraybased implementation n Not intrinsic to the Stack ADT Algorithm push(o) if t = S.length  1 then throw FullStackException else t t + 1 S[t] o S t 17 Performance and Limitations Performance n Let n be the number of elements in the stack n The space used is O(n) n Each operation runs in time O(1) Limitations n The maximum size of the stack must be defined a priori and cannot be changed n Trying to push a new element into a full stack causes an implementationspecific exception 18 CSCU9A3 9
10 Common Stack Error Stack s = new Stack(); // put stuff in stack for(int i = 0; i < 7; i++) s.push( i ); // print out contents of stack // while emptying it for(int i = 0; i < s.size(); i++) System.out.println( s.pop() ); // Output? Why? 19 Corrected Version Stack s = new Stack(); // put stuff in stack for(int i = 0; i < 7; i++) s.push( i ); // print out contents of stack // while emptying it int limit = s.size(); for(int i = 0; i < limit; i++) System.out.println( s.pop() ); //or // while(!s.isempty() ) // System.out.println( s.pop() ); 20 CSCU9A3 10
11 Arraybased Stack in Java public class ArrayStack<E> implements Stack<E> { // holds the stack elements private E S[ ]; // index to top element private int top = 1; // constructor public ArrayStack(int capacity) { S = (E[]) new Object[capacity]); public E pop() throws EmptyStackException { if isempty() { throw new EmptyStackException ( Empty stack: cannot pop ); E temp = S[top]; // facilitate garbage collection: S[top] = null; top = top 1; return temp; (other methods of Stack interface) 21 Example use in Java public class Tester { // other methods public void intreverse(integer a[]) { Stack<Integer> s; s = new ArrayStack<Integer>(); public void floatreverse(float f[]) { Stack<Float> s; s = new ArrayStack<Float>(); (code to reverse array f) for(int i = 0; i < a.length; a++) s.push(a[i]); for(int i = 0; i < a.length; a++) a[i] = s.pop(); 22 CSCU9A3 11
12 Parentheses Matching Each (, {, or [ must be paired with a matching ),, or [ n correct: ( )(( )){([( )]) n correct: ((( )(( )){([( )]) n incorrect: )(( )){([( )]) n incorrect: ({[ ]) n incorrect: ( 23 Parentheses Matching Algorithm Algorithm ParenMatch(X,n): Input: An array X of n tokens, each of which is either a grouping symbol, a variable, an arithmetic operator, or a number Output: true if and only if all the grouping symbols in X match Let S be an empty stack for i=0 to n1 do if X[i] is an opening grouping symbol then S.push(X[i]) else if X[i] is a closing grouping symbol then if S.isEmpty() then return false {nothing to match with if S.pop() does not match the type of X[i] then return false {wrong type if S.isEmpty() then return true {every symbol matched else return false {some symbols were never matched 24 CSCU9A3 12
13 HTML Tag Matching For fullycorrect HTML, each <name> should pair with a matching </name> <body> <center> <h1> The Little Boat </h1> </center> <p> The storm tossed the little boat like a cheap sneaker in an old washing machine. The three drunken fishermen were used to such treatment, of course, but not the tree salesman, who even as a stowaway now felt that he had overpaid for the voyage. </p> <ol> <li> Will the salesman die? </li> <li> What color is the boat? </li> <li> And what about Naomi? </li> </ol> </body> The Little Boat The storm tossed the little boat like a cheap sneaker in an old washing machine. The three drunken fishermen were used to such treatment, of course, but not the tree salesman, who even as a stowaway now felt that he had overpaid for the voyage. 1. Will the salesman die? 2. What color is the boat? 3. And what about Naomi? 25 Infix notation Consider the aithmetic expression: * (52) Binary operators reuires two operands. To evaluate the expression, we use the following rules: * and / have higher precedence than + and , when operators have the same precedence, we apply them from left to right, brackets change the order of precedence. Hence the following example gives a different answer: * (31) Consider a system of arithmetic with different rules 26 CSCU9A3 13
14 Reverse Polish With reverse Polish (postfix) notation, no precedence rules or parentheses reuired! In postfix notation, we put the operator after its operands instead of between them. Hence, instead of 5 + 4, we have Postfix Notation The first expression above, would be rewritten as: * (52) * while the second would be written as: * (31) * The operands are written in the same order while the operators are now written in the order in which they are to be applied. 28 CSCU9A3 14
15 Evaluating Postfix Expressions (continued) 29 Examples Let us first apply it to our simple example: Next Token : Answer is 9! With the expression: * Next  * CSCU9A3 15
This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues 1. 2004 Goodrich, Tamassia
This lecture Abstract data types Stacks Queues ADTs, Stacks, Queues 1 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations
More informationStacks & Queues. Data structures and Algorithms
Stacks & Queues Data structures and Algorithms Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++ Goodrich, Tamassia and Mount (Wiley, 2004) Outline
More informationOutline. The Stack ADT Applications of Stacks Arraybased implementation Growable arraybased stack. Stacks 2
Stacks Outline The Stack ADT Applications of Stacks Arraybased implementation Growable arraybased stack Stacks 2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure
More informationOutline. Computer Science 331. Stack ADT. Definition of a Stack ADT. Stacks. Parenthesis Matching. Mike Jacobson
Outline Computer Science 1 Stacks Mike Jacobson Department of Computer Science University of Calgary Lecture #12 1 2 Applications ArrayBased Linked ListBased 4 Additional Information Mike Jacobson (University
More informationIntroduction to Stacks
Introduction to Stacks What is a Stack Stack implementation using array. Stack implementation using linked list. Applications of Stack. What is a Stack? Stack is a data structure in which data is added
More informationcsci 210: Data Structures Stacks and Queues
csci 210: Data Structures Stacks and Queues Summary Topics stacks and queues as abstract data types implementations arrays linked lists analysis and comparison application: searching with stacks and queues
More informationSTACKS,QUEUES, AND LINKED LISTS
STACKS,QUEUES, AND LINKED LISTS Stacks Queues Linked Lists DoubleEnded Queues Case Study: A Stock Analysis Applet 1 Stacks Astack is a container of objects that are inserted and removed according to the
More information7.1 Our Current Model
Chapter 7 The Stack In this chapter we examine what is arguably the most important abstract data type in computer science, the stack. We will see that the stack ADT and its implementation are very simple.
More informationData Structures and Algorithms V22.0102. Otávio Braga
Data Structures and Algorithms V22.0102 Otávio Braga We use a stack When an operand is read, output it When an operator is read Pop until the top of the stack has an element of lower precedence Then push
More informationComp 245 Data Structures. Stacks
Comp 245 Data Structures Stacks What is a Stack? A LIFO (last in, first out) structure Access (storage or retrieval) may only take place at the TOP NO random access to other elements within the stack An
More informationWhat is a Stack? Stacks and Queues. Stack Abstract Data Type. Java Interface for Stack ADT. Arraybased Implementation
Stacks and Queues What is a Stack? Stores a set of elements in a particular order Accessed in LastIn InFirstOut (LIFO) fashion Real life examples: Pile of books PEZ dispenser Cup trays in cafeteria
More informationUniversidad Carlos III de Madrid
Universidad Carlos III de Madrid Algorithms and Data Structures (ADS) Bachelor in Informatics Engineering Computer Science Department Lists, Stacks and Queues. Authors: Isabel Segura Bedmar April 2011
More informationAlgorithms and Data Structures
Basic Data Structures Page 1 BFHTI: Softwareschule Schweiz Basic Data Structures Dr. CAS SD01 Basic Data Structures Page 2 Outline Data Structures and Abstract Data Types Linear Data Structures Implementing
More informationLast not not Last Last Next! Next! Line Line Forms Forms Here Here Last In, First Out Last In, First Out not Last Next! Call stack: Worst line ever!
ECE 551 C++ Programming, Data structures, and Algorithms Abstract Data Type: Stack Last In First Out (LIFO) 1 2 2 1 4 3 1 3 4 Stacks in Programming Worst line ever! 5 3 1 5 Stacks are not useful for waiting
More informationCourse: Programming II  Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1
Definition Course: Programming II  Abstract Data Types The ADT Stack The ADT Stack is a linear sequence of an arbitrary number of items, together with access procedures. The access procedures permit insertions
More information1.00 Lecture 35. Data Structures: Introduction Stacks, Queues. Reading for next time: Big Java: 15.115.3. Data Structures
1.00 Lecture 35 Data Structures: Introduction Stacks, Queues Reading for next time: Big Java: 15.115.3 Data Structures Set of reusable classes used in algorithms, simulations, operating systems, applications
More informationAlgorithms and Data Structures
Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. RalfPeter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2
More informationChapter 3: Restricted Structures Page 1
Chapter 3: Restricted Structures Page 1 1 2 3 4 5 6 7 8 9 10 Restricted Structures Chapter 3 Overview Of Restricted Structures The two most commonly used restricted structures are Stack and Queue Both
More information12 Abstract Data Types
12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).
More informationDATA STRUCTURES USING C
DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give
More informationDATA STRUCTURE  STACK
DATA STRUCTURE  STACK http://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm Copyright tutorialspoint.com A stack is an abstract data type ADT, commonly used in most programming
More informationUNIVERSITI MALAYSIA SARAWAK KOTA SAMARAHAN SARAWAK PSD2023 ALGORITHM & DATA STRUCTURE
STUDENT IDENTIFICATION NO UNIVERSITI MALAYSIA SARAWAK 94300 KOTA SAMARAHAN SARAWAK FAKULTI SAINS KOMPUTER & TEKNOLOGI MAKLUMAT (Faculty of Computer Science & Information Technology) Diploma in Multimedia
More information4.3 Stacks and Queues. Pushdown Stacks. Data Structures and Data Types. Collections
Data Structures and Data Types 4.3 Stacks and Queues Data types Set values. Set operations on those values. Some are built in to Java: int, double, char,... Most are not: Complex, Picture, Charge, Stack,
More informationStacks. The stack ADT Stack Implementation. Stack Examples. using arrays using generic linked lists using List ADT. EECS 268 Programming II 1
Stacks The stack ADT Stack Implementation using arrays using generic linked lists using List ADT Stack Examples 1 Stacks and Queues Linear data structures each item has specific first, next, and previous
More informationCHAPTER 4 ESSENTIAL DATA STRUCTRURES
CHAPTER 4 ESSENTIAL DATA STRUCTURES 72 CHAPTER 4 ESSENTIAL DATA STRUCTRURES In every algorithm, there is a need to store data. Ranging from storing a single value in a single variable, to more complex
More informationQueues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic
Queues Outline and Required Reading: Queues ( 4. except 4..4) COSC, Fall 3, Section A Instructor: N. Vlajic Queue ADT Queue linear data structure organized according to firstin/firstout (FIFO) principle!
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an objectoriented language. This document describes some of the differences between objectoriented programming in Scheme (which we hope you
More informationAnalysis of a Search Algorithm
CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,
More informationSequential Data Structures
Sequential Data Structures In this lecture we introduce the basic data structures for storing sequences of objects. These data structures are based on arrays and linked lists, which you met in first year
More informationData Structures Using C++ 2E. Chapter 7 Stacks
Data Structures Using C++ 2E Chapter 7 Stacks Linked Implementation of Stacks Disadvantage of array (linear) stack representation Fixed number of elements can be pushed onto stack Solution Use pointer
More informationUIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything
More informationStacks. Data Structures and Data Types. Collections
Data Structures and Data Types Data types Set values. Set operations on those values. Some are built in to Java: int, double, char,... Most are not: Complex, Picture, Charge, Stack, Queue, Graph,... Data
More informationData Structures Using Java
Data Structures Using Java D. S. Malik P. S. Nair THOMSON COURSE TECHNOLOGY Australia Canada Mexico Singapore Spain United Kingdom United States TABLE OF Contents PREFACE XXV 1.Software Engineering Principles
More informationLinked Lists Linked Lists, Queues, and Stacks
Linked Lists Linked Lists, Queues, and Stacks CSE 10: Introduction to C Programming Fall 200 Dynamic data structure Size is not fixed at compile time Each element of a linked list: holds a value points
More informationModule 2 Stacks and Queues: Abstract Data Types
Module 2 Stacks and Queues: Abstract Data Types A stack is one of the most important and useful nonprimitive linear data structure in computer science. It is an ordered collection of items into which
More information14 Stacks, Queues, And Linked Lists
141 Java Au Naturel by William C. Jones 141 14 Stacks, Queues, And Linked Lists Overview This chapter requires that you have a solid understanding of arrays (Chapter Seven) and have studied Exceptions
More informationCSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Linda Shapiro Registration We have 180 students registered and others who want to get in. If you re thinking of dropping
More informationCpt S 223. School of EECS, WSU
Abstract Data Types 1 Topics Abstract Data Types (ADTs) Some basic ADTs: Lists Stacks Queues 2 Primitive Data Type vs. Abstract Data Types Primitive DT: ADT: programmer progra ammer Interface (API) e.g.,
More informationHabanero Extreme Scale Software Research Project
Habanero Extreme Scale Software Research Project Comp215: Java Method Dispatch Zoran Budimlić (Rice University) Always remember that you are absolutely unique. Just like everyone else.  Margaret Mead
More information! stack, queue, priority queue, dictionary, sequence, set e.g., a Stack is a list implements a LIFO policy on additions/deletions.
Abstract Data Types and Data Structures Often, these terms are used as synonyms. But it s better to think of them this way: ADTs and Data Structures An Abstract Data Type (ADT) represents a particular
More informationLinked Lists, Stacks, Queues, Deques. It s time for a chainge!
Linked Lists, Stacks, Queues, Deques It s time for a chainge! Learning Goals After this unit, you should be able to... Differentiate an abstraction from an implementation. Define and give examples of problems
More informationSORTING. Review of Sorting. Merge Sort. Sets. sorting
Review of Sorting Merge Sort Sets SORTING 1 Sorting Algorithms Selection Sort uses a priority queue P implemented with an unsorted sequence:  Phase 1: the insertion of an item into P takes O(1) time;
More informationAlgorithms and Data Structures Written Exam Proposed SOLUTION
Algorithms and Data Structures Written Exam Proposed SOLUTION 20050107 from 09:00 to 13:00 Allowed tools: A standard calculator. Grading criteria: You can get at most 30 points. For an E, 15 points are
More informationCSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Nicki Dell Spring 2014
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Nicki Dell Spring 2014 Registration We have 140 students registered and 140+ on the wait list! If you re thinking of
More informationClass Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction
Class Overview CSE 326: Data Structures Introduction Introduction to many of the basic data structures used in computer software Understand the data structures Analyze the algorithms that use them Know
More informationIntroduction to Data Structures
Introduction to Data Structures Albert Gural October 28, 2011 1 Introduction When trying to convert from an algorithm to the actual code, one important aspect to consider is how to store and manipulate
More informationBorland C++ Compiler: Operators
Introduction Borland C++ Compiler: Operators An operator is a symbol that specifies which operation to perform in a statement or expression. An operand is one of the inputs of an operator. For example,
More informationChapter 5 Instructor's Manual
The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 5 Instructor's Manual Chapter Objectives Chapter 5, A Closer Look at Instruction
More informationData Structures and Algorithms(3)
Ming Zhang Data Structures and Algorithms Data Structures and Algorithms(3) Instructor: Ming Zhang Textbook Authors: Ming Zhang, Tengjiao Wang and Haiyan Zhao Higher Education Press, 2008.6 (the "Eleventh
More informationCollections & Data Structures. CS 3: Computer Programming in Java
Collections & Data Structures CS 3: Computer Programming in Java Objectives The concept of a collection Separating the interface from the implementation Dynamic data structures Linked lists Queues and
More informationCommon Data Structures
Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees
More informationAPI for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.
Sequences and Urns 2.7 Lists and Iterators Sequence. Ordered collection of items. Key operations. Insert an item, iterate over the items. Design challenge. Support iteration by client, without revealing
More informationChapter 7: Queues and Deques
Chapter 7: Queues and Deques After the stack, the next simplest data abstraction is the queue. As with the stack, the queue can be visualized with many examples you are already familiar with from everyday
More informationQuiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s
Quiz 4 Solutions Q1: What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number
More informationCourse: Programming II  Abstract Data Types. The ADT Queue. (Bobby, Joe, Sue, Ellen) Add(Ellen) Delete( ) The ADT Queues Slide Number 1
Definition Course: Programming II  Abstract Data Types The ADT Queue The ADT Queue is a linear sequence of an arbitrary number of items, together with access procedures. The access procedures permit addition
More informationData Structures Using C++ 2E. Chapter 5 Linked Lists
Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given
More informationData Structures and Algorithms
Data Structures and Algorithms CS2452016S04 Stacks and Queues David Galles Department of Computer Science University of San Francisco 040: Abstract Data Types An Abstract Data Type is a definition of
More informationKrishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA213 : DATA STRUCTURES USING C
Tutorial#1 Q 1: Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2: What is a Data Type? Differentiate
More informationC Compiler Targeting the Java Virtual Machine
C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCSTR98334 May 30, 1998 Abstract One of the
More informationExplain the relationship between a class and an object. Which is general and which is specific?
A.1.1 What is the Java Virtual Machine? Is it hardware or software? How does its role differ from that of the Java compiler? The Java Virtual Machine (JVM) is software that simulates the execution of a
More informationChapter 7D The Java Virtual Machine
This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly
More informationCOMPUTER SCIENCE. Paper 1 (THEORY)
COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) 
More informationCollaboration policy. Where to get help Email (but no code in email) Office hours Lab TAs in Friend 008/009 Bounce ideas (but not code) off classmates
Collaboration policy Programs: Do not use someone else s code unless specifically authorized Exceptions Code from course materials OK [cite source] Coding with partner OK after first assignment [stay tuned]
More informationCSE 143, Winter 2013 Programming Assignment #2: HTML Validator Due Thursday, July 10, 2014, 11:30 PM
CSE 143, Winter 2013 Programming Assignment #2: HTML Validator Due Thursday, July 10, 2014, 11:30 PM This program focuses on using Stack and Queue collections. Turn in files named HtmlValidator.java, and
More informationStack: What problems does it solve? Data Structures revisited. Simple stack example. Implementation is very simple
Data Structures revisited Stack: What problems does it solve? Linked lists and arrays and ArrayLists and Linear structures, operations include insert, delete, traverse, Advantages and tradeoffs include
More informationData Structures and Algorithms Stacks and Queues
Data Structures and Algorithms Stacks and Queues Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/23 60: Stacks and
More informationChapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
More informationD06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch20 Data Structures I PowerPoint presentation, created by Angel A. Juan  ajuanp(@)gmail.com, for
More informationQueues and Stacks. Atul Prakash Downey: Chapter 15 and 16
Queues and Stacks Atul Prakash Downey: Chapter 15 and 16 Queues Queues occur in real life a lot. Queues at checkout Queues in banks In software systems: Queue of requests at a web servers Properties of
More informationBSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering
BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security & BSc. (Hons.) Software Engineering Cohort: BIS/05/FT BCNS/05/FT BSE/05/FT Examinations for 20052006 / Semester
More informationAtmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1
Data Structure By Ajay Raiyani Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1 Linked List 4 Singly Linked List...4 Doubly Linked List...7 Explain Doubly Linked list: ...7 Circular Singly Linked
More informationIntroduction to Programming
Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@dunisiegena.de Tel.: 0271/7403966, Office: HB 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction
More informationParallel Programming
Parallel Programming 0024 Recitation Week 7 Spring Semester 2010 R 7 :: 1 0024 Spring 2010 Today s program Assignment 6 Review of semaphores Semaphores Semaphoren and (Java) monitors Semaphore implementation
More informationData Structure [Question Bank]
Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:
More informationCompSci61B, Data Structures Final Exam
Your Name: CompSci61B, Data Structures Final Exam Your 8digit Student ID: Your CS61B Class Account Login: This is a final test for mastery of the material covered in our labs, lectures, and readings.
More informationApplication of Stacks: Postfix Expressions Calculator (cont d.)
Application of Stacks: Postfix Expressions Calculator (cont d.) Postfix expression: 6 3 + 2 * = FIGURE 715 Evaluating the postfix expression: 6 3 + 2 * = Data Structures Using C++ 2E 1 Application of
More information1.204 Lecture 6. Data structures: stacks, queues, trees, dictionaries. Data structures
1.204 Lecture 6 Data structures: stacks, queues, trees, dictionaries Data structures Correct and efficient representation of data and applicable rules Stack: last in, first out discipline Queue: first
More informationWhy? A central concept in Computer Science. Algorithms are ubiquitous.
Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online
More informationDebugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, PsuedoCode, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
More informationA TOOL FOR DATA STRUCTURE VISUALIZATION AND USERDEFINED ALGORITHM ANIMATION
A TOOL FOR DATA STRUCTURE VISUALIZATION AND USERDEFINED ALGORITHM ANIMATION Tao Chen 1, Tarek Sobh 2 Abstract  In this paper, a software application that features the visualization of commonly used
More informationChapter 4 Operators & Arithmetic
Chapter 4 Operators & Arithmetic 41 Arithmetic in C++ Arithmetic expressions can be made up of constants, variables, operators and parentheses. The arithmetic operators in C++ are as follows + (addition)
More information1 The Java Virtual Machine
1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This
More informationCS104: Data Structures and ObjectOriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team
CS104: Data Structures and ObjectOriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A
More informationAlgorithms and Data S tructures Structures Stack, Queues, and Applications Applications Ulf Leser
Algorithms and Data Structures Stack, Queues, and Applications Ulf Leser Content of this Lecture Stacks and Queues Tree Traversal Towers of Hanoi Ulf Leser: Alg&DS, Summer semester 2011 2 Stacks and Queues
More informationBinary Heap Algorithms
CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn G. Chappell
More informationGlossary of Object Oriented Terms
Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction
More informationMAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push) 
=============================================================================================================================== DATA STRUCTURE PSEUDOCODE EXAMPLES (c) Mubashir N. Mir  www.mubashirnabi.com
More informationIntroduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
More informationThe Java Virtual Machine (JVM) Pat Morin COMP 3002
The Java Virtual Machine (JVM) Pat Morin COMP 3002 Outline Topic 1 Topic 2 Subtopic 2.1 Subtopic 2.2 Topic 3 2 What is the JVM? The JVM is a specification of a computing machine Instruction set Primitive
More informationBinary Trees (1) Outline and Required Reading: Binary Trees ( 6.3) Data Structures for Representing Trees ( 6.4)
1 Binary Trees (1) Outline and Required Reading: Binary Trees ( 6.3) Data Structures for Representing Trees ( 6.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic Binary Tree 2 Binary Tree tree with
More informationCS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationCOMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing
More information1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++
Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The
More informationCmpSci 187: Programming with Data Structures Spring 2015
CmpSci 187: Programming with Data Structures Spring 2015 Lecture #12 John Ridgway March 10, 2015 1 Implementations of Queues 1.1 Linked Queues A Linked Queue Implementing a queue with a linked list is
More information2. Names, Scopes, and Bindings
2. Names, Scopes, and Bindings Binding, Lifetime, Static Scope, Encapsulation and Modules, Dynamic Scope Copyright 2010 by John S. Mallozzi Names Variables Bindings Binding time Language design issues
More informationHome Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit
Data Structures Page 1 of 24 A.1. Arrays (Vectors) nelement vector start address + ielementsize 0 +1 +2 +3 +4... +n1 start address continuous memory block static, if size is known at compile time dynamic,
More informationJava Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
More informationJavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.
1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,
More information1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.
1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated
More information