The Bucharest University of Economic Studies. Data Structures. ADTs-Abstract Data Types Stacks and Queues
|
|
- Abel Sparks
- 6 years ago
- Views:
Transcription
1 The Bucharest University of Economic Studies Data Structures ADTs-Abstract Data Types Stacks and Queues
2 Agenda Definition Graphical representation Internal interpretation Characteristics Operations Implementations
3 Stack It is a linear structure in which the two basic operations, insertion and deletion are made on a LIFO based rule. These operations are made in a single part of the structure called the head of the stack, or the top. push STACK pop
4 Stack A logical structure implemented with different type of data structures: linked lists or arrays; A homogenous structure with elements of the same type; Basic operations: Adding an element, called the push operation Removing an element, called the pop operation Looking at the top element, called the peek operation struct Stack{ int Stack * }; info; next;
5 Stack as an ADT The implementation rule is LIFO Last In First Out The pop operation from a NULL stack is considered an error The push operation into a stack is considered a limitation The element from the top of a stack is the only accessible element top
6 Stack graphical representation push pop K C A T S Stack mechanism
7 Stacks with Linked Lists top of the stack new node 2 NULL NULL
8 Stacks with Linked Lists top of the stack NULL
9 Stacks with Linked Lists top of the stack temporary node NULL
10 Function call simulation 0x00f11464h int suma(int x, int y) { int z = 0, r = 2; z = x + y; return z; } void main(){ int a = suma(3,8); }
11 Function call simulation initialization. SP:0x0018FA18h BP:0x0018FA1Ch
12 Function call simulation push b b: 8. SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
13 Function call simulation push a a: 3 b: 8. SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
14 Function call simulation push IP IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
15 Function call simulation push BP BP: 0x0018FA1Ch IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA08h SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
16 Function call simulation mov BP, SP BP:0x0018FA08h BP: 0x0018FA1Ch IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA08h SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
17 Function call simulation sub r: 2 esp,8 SP:0x0018FA00h BP:0x0018FA08h z: 0 BP: 0x0018FA1Ch IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA08h SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
18 Function call simulation mov r: 2 SP, BP SP:0x0018FA00h BP:0x0018FA08h z: 0 BP: 0x0018FA1Ch IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA08h SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
19 Function call simulation pop r: 2 BP SP:0x0018FA00h BP:0x0018FA08h pop BP z: 0 BP: 0x0018FA1Ch IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA08h SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
20 Function call simulation return BP:0x0018FA08h pop BP return r: 2 z: 0 BP: 0x0018FA1Ch IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA00h SP:0x0018FA08h SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
21 Function call simulation BP:0x0018FA08h pop BP return r: 2 z: 0 BP: 0x0018FA1Ch IP: 0x00f11464h a: 3 b: 8. SP:0x0018FA00h SP:0x0018FA08h SP:0x0018FA0Ch SP:0x0018FA10h SP:0x0018FA14h SP:0x0018FA18h BP:0x0018FA1Ch
22 PUSH Pseudocode 1. memory allocation (newnode); 2. newnode initialization; 3. if (stack_full) stack overflow; else newnode >next = empty(head)? NULL: head; head = newnode;
23 POP Pseudocode 1. declaring a temporary node (tmpnode); 2. if (stack_empty) stack underflow; else value = head->info; tmpnode = head; head = head >next; free(tmpnode); return value;
24 QUEUES It is a linear structure in which the two basic operations, insertion and deletion are made on a FIFO based model. The insertion is made on the tail section and the deletion is made on the front section of the queue. dequeue get Queue put enqueue
25 Queue A logical structure implemented with different type of data structures: linked lists or arrays; A homogenous structure with elements of the same type; Basic operations: Adding an element, called the enqueuer or put operation Removing an element, called the dequeuer or get operation struct Queue{ Node* head; Node* tail; }; struct Node{ int Node * }; info; next;
26 Queue Implementation model FIFO Fifo In First Out front back
27 Queue Implementation put E U E U Q get
28 PUT Pseudocode 1. memory allocation for a new node (newnode); 2. newnode initialization; 3. if (full queue) queue overflow; else if (empty queue) head = tail = newnode ; else tail >next = newnode;
29 GET Pseudocode 1. declaring a temporary node (tmpnode); 2. if (empty queue) queue underflow; else value = head >info; tmpnode = head; head = head >next; free(tmpnode); return value;
30 Queues with Linked Lists head of the queue NULL tail of the queue 34 NULL
31 Queues with Linked Lists head of the queue tail of the queue 2 NULL
32 Queues with Linked Lists temporary node head of the queue tail of the queue 2 NULL
33 Queue Circular array Initial state (back < front && empty == true): back front
34 Queue Circular array Enqueue (2): 2 front back
35 Queue Circular array Enqueue (4): 2 4 front back
36 Queue Circular array Enqueue (1): back front
37 Queue Circular array Enqueue (3): back front
38 Queue Circular array Dequeue => return 2: back front
39 Queue Circular array Dequeue => return 4: front back
40 Queue Circular array Dequeue => return 1: back front
41 Queue Circular array Dequeue => return 3: back front
42 Palindrome Able was I ere I saw Elba
43 Ring buffer
44 Infix Postfix Prefix notations Evaluating mathematical expressions by using the stack data structure: reordering the elements so that the expression can be evaluated easily by one single crossing over the entire expression; The Polish notation invented by Jan Lukasiewicz also called the prefix expression; The Reverse Polish notation is called postfix notation.
45 Infix Postfix Prefix notations Evaluating mathematical expressions: Prefix or Polish notation: the operators are written before the operands Postfix or revers Polish notation: the operators are placed after the operands
46 Infix Postfix Prefix notations The postfix or the reverse Polish notation is much easily interpreted than the infix, normal mathematical expressions: the order of operations is straight forward; the parentheses are not necessary; the evaluation are automatically made by the use of a stack data structure;
47 Infix Postfix Prefix notations The algorithm for casting an infix expression to a postfix notation is called Dijkstra Shunting-Yard algorithm: using a stack for storing the operators in order to be transferred into the postfix notation; each operator has an adequate hierarchy level as depicted in the next table;
48 Infix Postfix Prefix notations Operators hierarchy level ( [ { ) ] } + - * /
49 Infix Postfix Prefix notations Mathematical expression (the infix notation) Polish notation (prefix expression) Reverse Polish notation (postfix expression) * * * + 4 * * * * (2 + 3) * *
50 Dijkstra Shunting-Yard algorithm Scan the entire infix expression from left to right for tokens (operators, operands and parentheses) For each token, test whether: If token is an operator: All operators from the top of the stack that are higher or equal precedence than the incoming one are popped out from the stack and appended to the postfix expression; after this operation the new token is pushed on the stack;
51 Dijkstra Shunting-Yard algorithm If token is an operand, append it to the postfix expression; If token is a left parenthesis, push it on the stack; If token is a right parenthesis: Pop all the operators from the stack and append them to the postfix expression, till the matching left parenthesis is found, which is popped out without being added to the result; When all tokens of the infix expression have been scanned, pop all the elements from the stack and append them to the postfix expression;
52 Infix to Postfix 2*(4+3)+9/3 Stack: Output:2
53 Infix to Postfix 2*(4+3)+9/3 Stack:* Output:2
54 Infix to Postfix 2*(4+3)+9/3 Stack:*( Output:2
55 Infix to Postfix 2*(4+3)+9/3 Stack:*( Output:24
56 Infix to Postfix 2*(4+3)+9/3 Stack:*(+ Output:24
57 Infix to Postfix 2*(4+3)+9/3 Stack:*(+ Output:243
58 Infix to Postfix 2*(4+3)+9/3 Stack:* Output:243+
59 Infix to Postfix 2*(4+3)+9/3 Stack:+ Output:243+*
60 Infix to Postfix 2*(4+3)+9/3 Stack:+ Output:243+*9
61 Infix to Postfix 2*(4+3)+9/3 Stack:+/ Output:243+*9
62 Infix to Postfix 2*(4+3)+9/3 Stack:+/ Output:243+*93
63 Infix to Postfix 2*(4+3)+9/3 Stack: Output:243+*93/+
64 Postfix evaluation algorithm Scan the entire postfix expression from left to right for tokens (operands and operators): For each token, test whether: If token is an operand is pushed on the stack; If token is an operator: The left element is popped from the stack into a x variable; The right element is popped from the stack into a y variable; The operation between x operator y is computed; The result is pushed on the stack; The last value standing on the stack is the result of the expression.
65 Infix->Postifix->Evaluation E = 2+5*3-(3*2+1)
66 Bibliografie Ion IVAN, Marius POPA, Paul POCATILU, coordonatori Structuri de date, Editura ASE, Bucuresti, 2008, ISBN Ion SMEUREANU Programarea in limbajul C/C++, Editura CISON, 2001 Michael MAIN Data Structures & Other Objects Using Java, Editura Pearson, 2012, ISBN:
The Bucharest University of Economic Studies. Data Structures. Heap Priority Queues Maps and Sets
The Bucharest University of Economic Studies Data Structures Heap Priority Queues Maps and Sets Heap A heap is a specialized tree-based data structure that satisfies the property: if A is parent for B
More informationPostfix (and prefix) notation
Postfix (and prefix) notation Also called reverse Polish reversed form of notation devised by mathematician named Jan Łukasiewicz (so really lü-kä-sha-vech notation) Infix notation is: operand operator
More informationPA3 Design Specification
PA3 Teaching Data Structure 1. System Description The Data Structure Web application is written in JavaScript and HTML5. It has been divided into 9 pages: Singly linked page, Stack page, Postfix expression
More informationLecture Data Structure Stack
Lecture Data Structure Stack 1.A stack :-is an abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example a deck of cards
More informationStack Abstract Data Type
Stacks Chapter 5 Chapter Objectives To learn about the stack data type and how to use its four methods: push, pop, peek, and empty To understand how Java implements a stack To learn how to implement a
More informationSTACKS AND QUEUES. Problem Solving with Computers-II
STACKS AND QUEUES Problem Solving with Computers-II 2 Stacks container class available in the C++ STL Container class that uses the Last In First Out (LIFO) principle Methods i. push() ii. iii. iv. pop()
More informationThe Bucharest University of Economic Studies. Data Structures. Associate Professor Mihai DOINEA
The Bucharest University of Economic Studies Data Structures Associate Professor Mihai DOINEA mihai.doinea@ie.ase.ro Assessment Final exam: 60% Short quiz: 10% Practical test: 50% Laboratory grading: 40%
More informationData Structures Unit 02
Data Structures Unit 02 Bucharest University of Economic Studies Memory classes, Bit structures and operators, User data types Memory classes Define specific types of variables in order to differentiate
More informationStacks. stacks of dishes or trays in a cafeteria. Last In First Out discipline (LIFO)
Outline stacks stack ADT method signatures array stack implementation linked stack implementation stack applications infix, prefix, and postfix expressions 1 Stacks stacks of dishes or trays in a cafeteria
More informationSolution: The examples of stack application are reverse a string, post fix evaluation, infix to postfix conversion.
1. What is the full form of LIFO? The full form of LIFO is Last In First Out. 2. Give some examples for stack application. The examples of stack application are reverse a string, post fix evaluation, infix
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 03 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? finish RadixSort implementation some applications of stack Priority Queues Michael
More informationStacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved
Stacks Chapter 5 Contents Specifications of the ADT Stack Using a Stack to Process Algebraic Expressions A Problem Solved: Checking for Balanced Delimiters in an Infix Algebraic Expression A Problem Solved:
More informationThe Stack and Queue Types
The Stack and Queue Types Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/ hkaiser/fall_2012/csc1254.html 2 Programming Principle of the Day Do the simplest thing that could possibly work A good
More informationEC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3
UNIT 3 LINEAR DATA STRUCTURES 1. Define Data Structures Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between
More informationStack and Its Implementation
Stack and Its Implementation Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale tessema.mengistu@siu.edu Room - 3131 1 Definition of Stack Usage of Stack Outline
More informationSome Applications of Stack. Spring Semester 2007 Programming and Data Structure 1
Some Applications of Stack Spring Semester 2007 Programming and Data Structure 1 Arithmetic Expressions Polish Notation Spring Semester 2007 Programming and Data Structure 2 What is Polish Notation? Conventionally,
More informationData Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1
Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Infix to Postfix Example 1: Infix to Postfix Example 2: Postfix Evaluation
More information09 STACK APPLICATION DATA STRUCTURES AND ALGORITHMS REVERSE POLISH NOTATION
DATA STRUCTURES AND ALGORITHMS 09 STACK APPLICATION REVERSE POLISH NOTATION IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD WWW.IMRANIHSAN.COM LECTURES ADAPTED FROM: DANIEL KANE, NEIL RHODES
More informationADVANCED DATA STRUCTURES USING C++ ( MT-CSE-110 )
ADVANCED DATA STRUCTURES USING C++ ( MT-CSE-110 ) Unit - 2 By: Gurpreet Singh Dean Academics & H.O.D. (C.S.E. / I.T.) Yamuna Institute of Engineering & Technology, Gadholi What is a Stack? A stack is a
More informationStacks and Queues. Chris Kiekintveld CS 2401 (Fall 2010) Elementary Data Structures and Algorithms
Stacks and Queues Chris Kiekintveld CS 2401 (Fall 2010) Elementary Data Structures and Algorithms Two New ADTs Define two new abstract data types Both are restricted lists Can be implemented using arrays
More informationStacks, Queues and Hierarchical Collections. 2501ICT Logan
Stacks, Queues and Hierarchical Collections 2501ICT Logan Contents Linked Data Structures Revisited Stacks Queues Trees Binary Trees Generic Trees Implementations 2 Queues and Stacks Queues and Stacks
More informationStacks Fall 2018 Margaret Reid-Miller
Stacks 15-121 Fall 2018 Margaret Reid-Miller Today Exam 2 is next Tuesday, October 30 Today: Quiz 5 solutions Recursive add from last week (see SinglyLinkedListR.java) Stacks ADT (Queues on Thursday) ArrayStack
More informationStacks, Queues and Hierarchical Collections
Programming III Stacks, Queues and Hierarchical Collections 2501ICT Nathan Contents Linked Data Structures Revisited Stacks Queues Trees Binary Trees Generic Trees Implementations 2 Copyright 2002- by
More informationIntroduction. Problem Solving on Computer. Data Structures (collection of data and relationships) Algorithms
Introduction Problem Solving on Computer Data Structures (collection of data and relationships) Algorithms 1 Objective of Data Structures Two Goals: 1) Identify and develop useful high-level data types
More informationSTACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:
STACKS A stack is a linear data structure for collection of items, with the restriction that items can be added one at a time and can only be removed in the reverse order in which they were added. The
More informationLinked List. April 2, 2007 Programming and Data Structure 1
Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element
More informationCSE 230 Intermediate Programming in C and C++
CSE 230 Intermediate Programming in C and C++ Structures and List Processing Fall 2017 Stony Brook University Instructor: Shebuti Rayana http://www3.cs.stonybrook.edu/~cse230/ Self-referential Structure
More informationStack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017
Stack Applications Lecture 27 Sections 18.7-18.8 Robb T. Koether Hampden-Sydney College Wed, Mar 29, 2017 Robb T. Koether Hampden-Sydney College) Stack Applications Wed, Mar 29, 2017 1 / 27 1 Function
More informationData Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1
Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Stack Operations on a stack Representing stacks Converting an expression
More informationDEEPIKA KAMBOJ UNIT 2. What is Stack?
What is Stack? UNIT 2 Stack is an important data structure which stores its elements in an ordered manner. You must have seen a pile of plates where one plate is placed on top of another. Now, when you
More informationStacks. Revised based on textbook author s notes.
Stacks Revised based on textbook author s notes. Stacks A restricted access container that stores a linear collection. Very common for solving problems in computer science. Provides a last-in first-out
More informationMotivation for Queues
CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 178] Motivation for Queues Some examples of first-in, first-out (FIFO) behavior: æ waiting in line to check out at a store æ cars on
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 07 / 26 / 2016 Instructor: Michael Eckmann Today s Topics Comments/Questions? Stacks and Queues Applications of both Priority Queues Michael Eckmann - Skidmore
More informationMarch 13/2003 Jayakanth Srinivasan,
Statement Effort MergeSort(A, lower_bound, upper_bound) begin T(n) if (lower_bound < upper_bound) Θ(1) mid = (lower_bound + upper_bound)/ 2 Θ(1) MergeSort(A, lower_bound, mid) T(n/2) MergeSort(A, mid+1,
More information15. Stacks and Queues
COMP1917 15s2 15. Stacks and Queues 1 COMP1917: Computing 1 15. Stacks and Queues Reading: Moffat, Section 10.1-10.2 Overview Stacks Queues Adding to the Tail of a List Efficiency Issues Queue Structure
More informationChapter 2. Stack & Queues. M hiwa ahmad aziz
. Chapter 2 Stack & Queues www.raparinweb.com M hiwa ahmad aziz 1 Stack A stack structure with a series of data elements that Allows access to only the last item inserted. An item is inserted or removed
More informationLinear Data Structure
Linear Data Structure Definition A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array Linked List Stacks Queues Operations on linear Data Structures Traversal
More informationStack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5
What is Stack? Stack 1. Stack is LIFO Structure [ Last in First Out ] 2. Stack is Ordered List of Elements of Same Type. 3. Stack is Linear List 4. In Stack all Operations such as Insertion and Deletion
More information12 Abstract Data Types
12 Abstract Data Types 12.1 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). Define
More informationDATA STRUCTURE UNIT I
DATA STRUCTURE UNIT I 1. What is Data Structure? A data structure is a mathematical or logical way of organizing data in the memory that consider not only the items stored but also the relationship to
More informationLecture 12 ADTs and Stacks
Lecture 12 ADTs and Stacks Modularity Divide the program into smaller parts Advantages Keeps the complexity managable Isolates errors (parts can be tested independently) Can replace parts easily Eliminates
More information1 P age DS & OOPS / UNIT II
UNIT II Stacks: Definition operations - applications of stack. Queues: Definition - operations Priority queues - De que Applications of queue. Linked List: Singly Linked List, Doubly Linked List, Circular
More informationStacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved
Stacks Chapter 5 Copyright 2012 by Pearson Education, Inc. All rights reserved Contents Specifications of the ADT Stack Using a Stack to Process Algebraic Expressions A Problem Solved: Checking for Balanced
More information-The Hacker's Dictionary. Friedrich L. Bauer German computer scientist who proposed "stack method of expression evaluation" in 1955.
Topic 15 Implementing and Using "stack n. The set of things a person has to do in the future. "I haven't done it yet because every time I pop my stack something new gets pushed." If you are interrupted
More informationFirst Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...
First Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms.... Q1) What are some of the applications for the tree data structure? Q2) There are 8, 15, 13, and
More informationRevision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,
[1] Big-O Analysis AVERAGE(n) 1. sum 0 2. i 0. while i < n 4. number input_number(). sum sum + number 6. i i + 1 7. mean sum / n 8. return mean Revision Statement no. of times executed 1 1 2 1 n+1 4 n
More informationFormal Languages and Automata Theory, SS Project (due Week 14)
Formal Languages and Automata Theory, SS 2018. Project (due Week 14) 1 Preliminaries The objective is to implement an algorithm for the evaluation of an arithmetic expression. As input, we have a string
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationCS W3134: Data Structures in Java
CS W3134: Data Structures in Java Lecture #10: Stacks, queues, linked lists 10/7/04 Janak J Parekh HW#2 questions? Administrivia Finish queues Stack/queue example Agenda 1 Circular queue: miscellany Having
More informationQueues Fall 2018 Margaret Reid-Miller
Queues 15-121 Fall 2018 Margaret Reid-Miller Today Exam 2 is next Tuesday, October 30 Writing methods various classes that implement Lists. Methods using Lists and Big-O w/ ArrayList or LinkedLists Prove
More information#06 More Structures LIFO FIFO. Contents. Queue vs. Stack 3. Stack Operations. Pop. Push. Stack Queue Hash table
Contents #06 More Structures -07 FUNDAMENTAL PROGRAMMING I Stack Queue Hash table DEPARTMENT OF COMPUTER ENGINEERING, PSU v. Queue vs. Stack Stack Operations IN IN OUT Push: add an item to the top Pop:
More informationStacks and Queues. CSE Data Structures April 12, 2002
Stacks and Queues CSE 373 - Data Structures April 12, 2002 Readings and References Reading Section 3.3 and 3.4, Data Structures and Algorithm Analysis in C, Weiss Other References 12-Apr-02 CSE 373 - Data
More informationCMSC Introduction to Algorithms Spring 2012 Lecture 7
CMSC 351 - Introduction to Algorithms Spring 2012 Lecture 7 Instructor: MohammadTaghi Hajiaghayi Scribe: Rajesh Chitnis 1 Introduction In this lecture we give an introduction to Data Structures like arrays,
More informationData Structure - Stack and Queue-
Data Structure - Stack and Queue- Hanyang University Jong-Il Park STACK Stack ADT List that insertions and deletions can be performed at the end of the list Operations Push(X, S): insert X in the list
More informationDATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
DATA STRUCUTRES A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. An algorithm, which is a finite sequence of instructions, each of which
More information.:: UNIT 4 ::. STACK AND QUEUE
.:: UNIT 4 ::. STACK AND QUEUE 4.1 A stack is a data structure that supports: Push(x) Insert x to the top element in stack Pop Remove the top item from stack A stack is collection of data item arrange
More informationInfix to Postfix Conversion
Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Conceptual Idea
More informationCSE 326 Team. Today s Outline. Course Information. Instructor: Steve Seitz. Winter Lecture 1. Introductions. Web page:
CSE 326 Team CSE 326: Data Structures Instructor: Steve Seitz TAs: Winter 2009 Steve Seitz Lecture 1 Eric McCambridge Brent Sandona Soyoung Shin Josh Barr 2 Today s Outline Introductions Administrative
More informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours
TED (10)-3071 Reg. No.. (REVISION-2010) (Maximum marks: 100) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours PART
More informationCS6202 - PROGRAMMING & DATA STRUCTURES I Unit IV Part - A 1. Define Stack. A stack is an ordered list in which all insertions and deletions are made at one end, called the top. It is an abstract data type
More informationLecture 4 Stack and Queue
Lecture 4 Stack and Queue Bo Tang @ SUSTech, Spring 2018 Our Roadmap Stack Queue Stack vs. Queue 2 Stack A stack is a sequence in which: Items can be added and removed only at one end (the top) You can
More informationCS200: Queues. Prichard Ch. 8. CS200 - Queues 1
CS200: Queues Prichard Ch. 8 CS200 - Queues 1 Queues First In First Out (FIFO) structure Imagine a checkout line So removing and adding are done from opposite ends of structure. 1 2 3 4 5 add to tail (back),
More informationWhere does the insert method place the new entry in the array? Assume array indexing starts from 0(zero).
Suppose we have a circular array implementation of the queue,with ten items in the queue stored at data[2] through data[11]. The current capacity of an array is 12. Where does the insert method place the
More informationStacks and their Applications
Stacks and their Applications Lecture 23 Sections 18.1-18.2 Robb T. Koether Hampden-Sydney College Fri, Mar 16, 2018 Robb T. Koether Hampden-Sydney College) Stacks and their Applications Fri, Mar 16, 2018
More informationData Structures. Chapter 06. 3/10/2016 Md. Golam Moazzam, Dept. of CSE, JU
Data Structures Chapter 06 1 Stacks A stack is a list of elements in which an element may be inserted or deleted only at one end, called the top of the stack. This means that elements are removed from
More informationArrays and Linked Lists
Arrays and Linked Lists Abstract Data Types Stacks Queues Priority Queues and Deques John Edgar 2 And Stacks Reverse Polish Notation (RPN) Also known as postfix notation A mathematical notation Where every
More informationStack ADT. ! push(x) puts the element x on top of the stack! pop removes the topmost element from the stack.
STACK Stack ADT 2 A stack is an abstract data type based on the list data model All operations are performed at one end of the list called the top of the stack (TOS) LIFO (for last-in first-out) list is
More informationTop of the Stack. Stack ADT
Module 3: Stack ADT Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Stack ADT Features (Logical View) A List that
More informationStack and Queue. Stack:
Stack and Queue Stack: Abstract Data Type A stack is a container of objects that are inserted and removed according to the last-in first-out (LIFO) principle. In the pushdown stacks only two operations
More informationCSE 332: Data Structures. Spring 2016 Richard Anderson Lecture 1
CSE 332: Data Structures Spring 2016 Richard Anderson Lecture 1 CSE 332 Team Instructors: Richard Anderson anderson at cs TAs: Hunter Zahn, Andrew Li hzahn93 at cs lia4 at cs 2 Today s Outline Introductions
More informationTop of the Stack. Stack ADT
Module 3: Stack ADT Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Stack ADT Features (Logical View) A List that
More informationData Abstraction and Specification of ADTs
CITS2200 Data Structures and Algorithms Topic 4 Data Abstraction and Specification of ADTs Example The Reversal Problem and a non-adt solution Data abstraction Specifying ADTs Interfaces javadoc documentation
More informationADT Stack. Inserting and deleting elements occurs at the top of Stack S. top. bottom. Stack S
Stacks Stacks & Queues A linear sequence, or list, is an ordered collection of elements: S = (s 1, s 2,..., s n ) Stacks and queues are finite linear sequences. A Stack is a LIFO (Last In First Out) list.
More informationData Structures & Algorithm Analysis. Lecturer: Souad Alonazi
Data Structures & Algorithm Analysis Lec(3) Stacks Lecturer: Souad Alonazi What is a stack? Stores a set of elements in a particular order Stack principle: LAST IN FIRST OUT = LIFO It means: the last element
More informationContent: Learning Objectives
1 BLOOM PUBLIC CHOOL Vasant Kunj, New Delhi Lesson Plan Class: XII ubject: Computer cience Month : July No of s: 21 Chapter:Data structure: Linked List TTT: 8 WT: 12 Content: Learning Objectives At the
More informationAbstract Data Types. Stack. January 26, 2018 Cinda Heeren / Geoffrey Tien 1
Abstract Data Types Stack January 26, 2018 Cinda Heeren / Geoffrey Tien 1 Abstract data types and data structures An Abstract Data Type (ADT) is: A collection of data Describes what data are stored but
More informationOutline. Stacks. 1 Chapter 5: Stacks and Queues. favicon. CSI33 Data Structures
Outline Chapter 5: and Queues 1 Chapter 5: and Queues Chapter 5: and Queues The Stack ADT A Container Class for Last-In-First-Out Access A stack is a last in, first out (LIFO) structure, i.e. a list-like
More informationSCHOOL OF COMPUTER AND COMMUNICATION ENGINEERING. EKT224: ALGORITHM AND DATA STRUCTURES (Stack, Queue, Linked list)
ASSIGNMENT 2 SCHOOL OF COMPUTER AND COMMUNICATION ENGINEERING EKT224: ALGORITHM AND DATA STRUCTURES (Stack, Queue, Linked list) Date: 30/9/2015 Due Date: 30/10/2015 Early Bird Date: 23/10/2015 QUESTION
More information10/26/2017 CHAPTER 3 & 4. Stacks & Queues. The Collection Framework
CHAPTER 3 & 4 Stacks & Queues The Collection Framework 1 Stack Abstract Data Type A stack is one of the most commonly used data structures in computer science A stack can be compared to a Pez dispenser
More informationCS24 Week 4 Lecture 2
CS24 Week 4 Lecture 2 Kyle Dewey Overview Linked Lists Stacks Queues Linked Lists Linked Lists Idea: have each chunk (called a node) keep track of both a list element and another chunk Need to keep track
More informationProgramming Abstractions
Programming Abstractions C S 1 0 6 B Cynthia Lee Today s Topics ADTs Stack Example: Reverse-Polish Notation calculator Queue Example: Mouse Events Stacks New ADT: Stack stack.h template
More informationAn Introduction to Trees
An Introduction to Trees Alice E. Fischer Spring 2017 Alice E. Fischer An Introduction to Trees... 1/34 Spring 2017 1 / 34 Outline 1 Trees the Abstraction Definitions 2 Expression Trees 3 Binary Search
More informationStacks and Queues
Stacks and Queues 2-25-2009 1 Opening Discussion Let's look at solutions to the interclass problem. Do you have any questions about the reading? Do you have any questions about the assignment? Minute Essays
More informationOutline. Introduction Stack Operations Stack Implementation Implementation of Push and Pop operations Applications. ADT for stacks
Stack Chapter 4 Outline Introduction Stack Operations Stack Implementation Implementation of Push and Pop operations Applications Recursive Programming Evaluation of Expressions ADT for stacks Introduction
More informationProgramming Abstractions
Programming Abstractions C S 1 0 6 B Cynthia Lee Today s Topics HW Tips QT Creator dos & don ts ADTs Stack Example: Reverse-Polish Notation calculator Queue Event queues QT Creator A F E W W A R N I N
More informationSimpleCalc. which can be entered into a TI calculator, like the one on the right, like this:
!! SimpleCalc Objective: To use stacks to emulate a simple arithmetic calculator. Background: Most people learn to write arithmetic expressions like this: which can be entered into a TI calculator, like
More informationStacks (Section 2) By: Pramod Parajuli, Department of Computer Science, St. Xavier s College, Nepal.
(Section 2) Linked list implementation of stack Typical Application of stacks Evaluation of expressions (infix, postfix, prefix) References and further details By: Pramod Parajuli, Department of Computer
More informationAlgorithms and Data Structures Exercise I
Algorithms and Data Structures Exercise I Banafsheh Azari http://www.uni-weimar.de/de/medien/professuren/grafischedatenverarbeitung/ Bauhaus-University Weimar - CogVis/MMC May 3, 2017 c 2017, Algorithms
More informationEEE2020 Data Structures and Algorithms Abstract Data Types: Stacks and Queues
EEE2020 Data Structures and Algorithms Abstract Data Types: Stacks and Queues W. Jinho Song School of Electrical & Electronic Engineering Yonsei University 1 Textbook Chapter and Objectives Textbook "Data
More informationStack Applications. Lecture 25 Sections Robb T. Koether. Hampden-Sydney College. Mon, Mar 30, 2015
Stack Applications Lecture 25 Sections 18.7-18.8 Robb T. Koether Hampden-Sydney College Mon, Mar 30, 2015 Robb T. Koether Hampden-Sydney College) Stack Applications Mon, Mar 30, 2015 1 / 34 1 The Triangle
More informationDHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES
DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES UNIT III LINEAR DATA STRUCTURES PART A 1. What is meant by data
More information3137 Data Structures and Algorithms in C++
3137 Data Structures and Algorithms in C++ Lecture 3 July 12 2006 Shlomo Hershkop 1 Announcements Homework 2 out tonight Please make sure you complete hw1 asap if you have issues, please contact me will
More informationList, Stack, and Queues
List, Stack, and Queues R. J. Renka Department of Computer Science & Engineering University of North Texas 02/24/2010 3.1 Abstract Data Type An Abstract Data Type (ADT) is a set of objects with a set of
More informationLecture No.04. Data Structures
Lecture No.04 Data Structures Josephus Problem #include "CList.cpp" void main(int argc, char *argv[]) { CList list; int i, N=10, M=3; for(i=1; i
More informationLab 7 1 Due Thu., 6 Apr. 2017
Lab 7 1 Due Thu., 6 Apr. 2017 CMPSC 112 Introduction to Computer Science II (Spring 2017) Prof. John Wenskovitch http://cs.allegheny.edu/~jwenskovitch/teaching/cmpsc112 Lab 7 - Using Stacks to Create a
More information4.3 Stacks and Queues
4.3 Stacks and Queues Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 03/30/12 04:33:08 PM Data Types and Data Structures Data types.
More informationStacks and Queues. Stack - Abstract Data Type. Stack Applications. Stack - Abstract Data Type - C Interface
Stacks and Queues Stack - Abstract Data Type. Stacks and queues ubiquitous -structure in computing. Part of many important algorithms. Good example of abstract types. Good example to practice programming
More informationIV. Stacks. A. Introduction 1. Consider the 4 problems on pp (1) Model the discard pile in a card game. (2) Model a railroad switching yard
IV. Stacks 1 A. Introduction 1. Consider the problems on pp. 170-1 (1) Model the discard pile in a card game (2) Model a railroad switching yard (3) Parentheses checker () Calculate and display base-two
More informationClass / Sem: I CSE / II Semester Subject Code: CS 6202 Subject: Programming and Data Structures I Prepared by T. Vithya Unit IV - LINEAR DATA STRUCTURES STACKS AND QUEUES Stack ADT Evaluating arithmetic
More information