Chapter 9 STACK, QUEUE
|
|
- Jared Ross
- 6 years ago
- Views:
Transcription
1 Chapter 9 STACK, QUEUE 1
2 LIFO: Last In, First Out. Stacks Restricted form of list: Insert and remove only at front of list. Notation: Insert: PUSH Remove: POP The accessible element is called TOP.
3 Stack ADT // Initialize the stack void init(stack); // Reinitialize the stack void clear(stack); // Push an element onto the top of the stack. bool push(stack, Elem) = 0; // Remove the element at the top of the stack. bool pop(stack, Elem*) = 0; // Get a copy of the top element in the stack bool topvalue(stack, Elem*); // Return the number of elements in the stack. int length(stack);
4 Array-Based Stack // Array-based stack implementation int size; // Maximum size of stack int top; // Index for top element Elem *listarray; // Array holding elements Issues: Which end is the top? Where does top point to? What is the cost of the operations?
5 Linked Stack // Linked stack implementation Link<Elem>* top; // Pointer to first elem int currentsize; // Count number of elems What is the cost of the operations? How do space requirements compare to the array-based stack implementation?
6 #define TRUE 1 #define FALSE 0 typedef int BOOL ; Array-Based Stack Class (1) typedef int Elem; typedef struct STACK{ int size ; // Maximum size of stack int top ; // Index for top element Elem *listarray ; // Array holding elements }*Stack;
7 Array-Based Stack Class (2) void init_size(stack stack, int mysize) { stack->size = mysize; stack->top = 0; stack->listarray = (Elem*)malloc((mysize)*sizeof(Elem)); } void init(stack stack) { init_size(stack, 200);} void clear(stack stack) { stack->size = 0; stack->top = 0; if( stack->listarray!= NULL ) { free(stack->listarray); stack->listarray = NULL; }}
8 Array-Based Stack Class (3) BOOL push(stack stack, Elem e) { if ( stack->top < stack->size ){ stack->listarray[ stack->top++ ] = e; return TRUE; } return FALSE;} BOOL pop(stack stack, Elem* e) { if ( stack->top > 0 ){ *e = stack->listarray[ stack->top - 1 ]; stack->top --; return TRUE; } return FALSE;}
9 Array-Based Stack Class (4) // Get a copy of the top element in the stack BOOL topvalue(stack stack, Elem* e) { if ( stack->top > 0 ){ *e = stack->listarray[ stack->top - 1 ]; return TRUE; } return FALSE;} // Return the number of elements in the stack. int length(stack stack) { return stack->top; }
10 FIFO: First in, First Out Queues Restricted form of list: Insert at one end, remove from the other. Notation: Insert: Enqueue Delete: Dequeue First element: Front Last element: Rear
11 Queue Implementation (1)
12 Queue ADT // Initialize the queue void init(queue, int); // Reinitialize the queue void clear(queue); // enqueue an element into the queue. bool enqueue(queue, Elem) = 0; // dequeue an element from the queue. bool dequeue(queue, Elem*) = 0; // Get a copy of the front element in the stack bool frontvalue(queue, Elem*); // Return the number of elements in the queue. int length(queue);
13 Queue Implementation (2)
14 The Maze Runner How to find a way out of maze?
15 Problem description Given you a maze map, a start point(s) and an exit (E), calculate the minimum distance from the start to the exit. 15
16 Problem description A map consists of 4 kinds of characters: S means the start point; E means the exit point;. means the opened-block that you can pass; # means the closed-block that you cannot pass; A sample Map 16
17 Requirements: Problem description It is ONLY allowed to move by one step vertically or horizontally( up, down, left or right) to the next block; You MUST NOT get out of the map; Return -1 if given arguments can not satisfy the above requirements or you cannot find a way from S to E. 17
18 Depth first search DFS and Stack Go go go, until you meet a wall! Backward Use a stack to trace the path Whenever meet a wall, pop the last point Need to try all possible path to decide the shortest way
19 Stack based Algorithm Algorithm Mark the Begin Node as tried. Push the Node. While(Stack is not Empty){ Pop a node=n if(n is the goal){ break;} Try 4 directions of N. if(a direction has a neighbor of N = M && M is not tried yet. ){ Push M into Stack. Set N as the prenode of M } } If(N is the Goal){ Output N. while(n has a pre-node = M){ Output M; N=M; } } Else{ there is not any path. } 19
20 Hint (X,Y) UP Down Left Right (X,Y+1 ) (X,Y-1) (X-1,Y) (X+1,Y) Dist[x][y] denotes the shortest distance from S point to position (x,y). Initially, Dist[x][y] = MAX; (for (x,y)!= S) Dist[x][y] = 0; (for (x,y) == S) 20
21 Queue and BFS Breadth First Search Search each level Done with every point, and do not come back Use a queue to store further points Points to check Then you can update the distance for new position If ( dist[new_x][new_y] < dist[x][y] + 1) dist[new_x][new_y] = dist[x][y] + 1; (X,Y+1) (X,Y-1) (X-1,Y) (X+1,Y)
22 UP (X,Y+1 ) Down UP Left (X,Y-1) Right a b c d (X,Y) (X-1,Y) Hint Down Left Right UP (X+1,Y) Down Left (X,Y+1 ) Right dequeue (X,Y-1) (X-1,Y) (X+1,Y) a b c d As long as the queue is not empty, you dequeue a position and enqueue its the next 4 positions. Update the distance matrix. 22
23 Algorithm Enqueue the root node, i.e the position of S Dequeue a node enqueue the direct child nodes (at most 4) Update the child nodes distance If the queue is empty, every node on the graph has been examined quit the search. If the queue is not empty, repeat from Step 2. 23
Stacks 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 informationcsci 210: Data Structures Stacks and Queues
csci 210: Data Structures Stacks and Queues 1 Summary Topics Stacks and Queues as abstract data types ( ADT) Implementations arrays linked lists Analysis and comparison Applications: searching with stacks
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 informationQueues. A queue is a special type of structure that can be used to maintain data in an organized way.
A queue is a special type of structure that can be used to maintain data in an organized way. This data structure is commonly implemented in one of two ways: as an array or as a linked list. In either
More informationCMPT 125: Practice Midterm Answer Key
CMPT 125, Spring 2017, Surrey Practice Midterm Answer Key Page 1 of 6 CMPT 125: Practice Midterm Answer Key Linked Lists Suppose you have a singly-linked list whose nodes are defined like this: struct
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 informationCS 2412 Data Structures. Chapter 9 Graphs
CS 2412 Data Structures Chapter 9 Graphs Some concepts A graph consists of a set of vertices and a set of lines (edges, arcs). A directed graph, or digraph, is a graph in which each line has a direction.
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 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 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 informationSeparate Compilation and Namespaces Week Fall. Computer Programming for Engineers
Separate Compilation and Namespaces Week 07 Fall Computer Programming for Engineers Problem Multiplied palindrome number Multiplied palindrome number A number is called as a palindrome when you can read
More informationCS 1114: Implementing Search. Last time. ! Graph traversal. ! Two types of todo lists: ! Prof. Graeme Bailey.
CS 1114: Implementing Search! Prof. Graeme Bailey http://cs1114.cs.cornell.edu (notes modified from Noah Snavely, Spring 2009) Last time! Graph traversal 1 1 2 10 9 2 3 6 3 5 6 8 5 4 7 9 4 7 8 10! Two
More informationData Structures. Jia-Liang Lu. Slides based on the course notes of C.A. Shaffer
Data Structures Jia-Liang Lu Slides based on the course notes of C.A. Shaffer Part II: Fundamental Data Structure Chapter 4: Lists, Stacks, and Queues Lists A list is a finite, ordered sequence of data
More informationCOSC160: Data Structures: Lists and Queues. Jeremy Bolton, PhD Assistant Teaching Professor
COSC160: Data Structures: Lists and Queues Jeremy Bolton, PhD Assistant Teaching Professor Outline I. Queues I. FIFO Queues I. Usage II. Implementations II. LIFO Queues (Stacks) I. Usage II. Implementations
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 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 informationLinear Structures. Linear Structure. Implementations. Array details. List details. Operations 4/18/2013
Linear Structure Linear Structures Chapter 4 CPTR 318 Every non-empty linear structure has A unique element called first A unique element called last Every element except last has a unique successor Every
More informationYou must print this PDF and write your answers neatly by hand. You should hand in the assignment before recitation begins.
15-122 Homework 4 Page 1 of 13 15-122 : Principles of Imperative Computation, Summer 1 2014 Written Homework 4 Due: Thursday, June 12 before recitation Name: Andrew ID: Recitation: In this assignment,
More informationLinear Structures. Linear Structure. Implementations. Array details. List details. Operations 2/10/2013
Linear Structure Linear Structures Chapter 4 CPTR 318 Every non-empty linear structure has A unique element called first A unique element called last Every element except last has a unique successor Every
More informationQueues. October 20, 2017 Hassan Khosravi / Geoffrey Tien 1
Queues October 20, 2017 Hassan Khosravi / Geoffrey Tien 1 Queue ADT Queue ADT should support at least the first two operations: enqueue insert an item to the back of the queue dequeue remove an item from
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 informationName CPTR246 Spring '17 (100 total points) Exam 3
Name CPTR246 Spring '17 (100 total points) Exam 3 1. Linked Lists Consider the following linked list of integers (sorted from lowest to highest) and the changes described. Make the necessary changes in
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech
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 informationCS S-04 Stacks and Queues 1. An Abstract Data Type is a definition of a type based on the operations that can be performed on it.
CS245-2017S-04 Stacks and Queues 1 04-0: Abstract Data Types An Abstract Data Type is a definition of a type based on the operations that can be performed on it. An ADT is an interface Data in an ADT cannot
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 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 informationData Structures and Algorithms
Data Structures and Algorithms CS245-2017S-04 Stacks and Queues David Galles Department of Computer Science University of San Francisco 04-0: Abstract Data Types An Abstract Data Type is a definition of
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 informationData Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.
Data Structures Outline Introduction Linked Lists Stacks Queues Trees Introduction dynamic data structures - grow and shrink during execution Linked lists - insertions and removals made anywhere Stacks
More informationCSE 100: GRAPH ALGORITHMS
CSE 100: GRAPH ALGORITHMS 2 Graphs: Example A directed graph V5 V = { V = E = { E Path: 3 Graphs: Definitions A directed graph V5 V6 A graph G = (V,E) consists of a set of vertices V and a set of edges
More informationDepartment of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #13
Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Topic: Stack and Queue Practice Sheet #13 Date: 04-04-2017 1. Consider the following sequence of push and pop operations
More informationCS24 Week 8 Lecture 1
CS24 Week 8 Lecture 1 Kyle Dewey Overview Tree terminology Tree traversals Implementation (if time) Terminology Node The most basic component of a tree - the squares Edge The connections between nodes
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 3 Data Structures Graphs Traversals Strongly connected components Sofya Raskhodnikova L3.1 Measuring Running Time Focus on scalability: parameterize the running time
More informationMidterm I Exam Principles of Imperative Computation Frank Pfenning. February 17, 2011
Midterm I Exam 15-122 Principles of Imperative Computation Frank Pfenning February 17, 2011 Name: Sample Solution Andrew ID: fp Section: Instructions This exam is closed-book with one sheet of notes permitted.
More informationOverview of today s lecture. Quick recap of previous C lectures. Introduction to C programming, lecture 2. Abstract data type - Stack example
Overview of today s lecture Introduction to C programming, lecture 2 -Dynamic data structures in C Quick recap of previous C lectures Abstract data type - Stack example Make Refresher: pointers Pointers
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 informationWentworth Institute of Technology COMP201 Computer Science II Spring 2015 Derbinsky. Stacks and Queues. Lecture 11.
Lecture 11 1 More Data Structures In this lecture we will use a linked list to implement two abstract data types (ADT) An ADT provides the interface, or what a data structure does We can then use code
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Queues ArrayQueue Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 10, 2014 Abstract These lecture notes are meant to be looked
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 informationList, Stack and Queue Implementation
Roy Chan CSC2100B Data Structures Tutorial 2 (Version 2) January 21, 2009 1 / 39 1 CSC2100B Online Judge Score 2 Structure 3 Linked List Overview Implementation 4 Stack Overview Implementation 5 Queue
More informationLecture Notes on Queues
Lecture Notes on Queues 15-122: Principles of Imperative Computation Frank Pfenning and Jamie Morgenstern Lecture 9 February 14, 2012 1 Introduction In this lecture we introduce queues as a data structure
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 informationCOMP 182 Algorithmic Thinking. Breadth-first Search. Luay Nakhleh Computer Science Rice University
COMP 182 Algorithmic Thinking Breadth-first Search Luay Nakhleh Computer Science Rice University Graph Exploration Elucidating graph properties provides a powerful tool for understanding networks and their
More information! A data type for which: ! An ADT may be implemented using various. ! Examples:
Stacks and Queues Unit 6 Chapter 19.1-2,4-5 CS 2308 Fall 2018 Jill Seaman 1 Abstract Data Type A data type for which: - only the properties of the data and the operations to be performed on the data are
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 informationCPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues
CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues Alan J. Hu (Slides borrowed from Steve Wolfman) Be sure to check course webpage! http://www.ugrad.cs.ubc.ca/~cs221 1 Lab 1 is available.
More informationLecture 10 Notes Linked Lists
Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to
More informationAshish Gupta, Data JUET, Guna
Introduction In general, Queue is line of person waiting for their turn at some service counter like ticket window at cinema hall, at bus stand or at railway station etc. The person who come first, he/she
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 informationA linear-list Data Structure where - addition of elements to and - removal of elements from are restricted to the first element of the list.
A linear-list Data Structure where - addition of elements to and - removal of elements from are restricted to the first element of the list. the first element of the list a new element to (the Top of)
More informationSolution for Data Structure
Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT
More informationLecture 24 Notes Search in Graphs
Lecture 24 Notes Search in Graphs 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson 1 Introduction In this lecture, we will discuss the
More informationGraphs: Graph Data Structure:
Graphs: A graph is a pictorial representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by points termed as vertices, and the links
More informationData Structures and Algorithms (DSA) Course 6 Lists (Recapitulation) Iulian Năstac
Data Structures and Algorithms (DSA) Course 6 Lists (Recapitulation) Iulian Năstac Recapitulation Operations related to a linked list: a) creation of a linked list; b) access to any node of the list; c)
More informationData Structure. Recitation VII
Data Structure Recitation VII Recursion: Stack trace Queue Topic animation Trace Recursive factorial Executes factorial(4) Step 9: return 24 Step 8: return 6 factorial(4) Step 0: executes factorial(4)
More informationStack. Data structure with Last-In First-Out (LIFO) behavior. Out
Stack and Queue 1 Stack Data structure with Last-In First-Out (LIFO) behavior In Out C B A B C 2 Typical Operations Pop on Stack Push isempty: determines if the stack has no elements isfull: determines
More informationMLR Institute of Technology
MLR Institute of Technology Laxma Reddy Avenue, Dundigal, Quthbullapur (M), Hyderabad 500 043 Phone Nos: 08418 204066 / 204088, Fax : 08418 204088 TUTORIAL QUESTION BANK Course Name : DATA STRUCTURES Course
More informationCPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues
CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues Alan J. Hu (Slides borrowed from Steve Wolfman) Be sure to check course webpage! http://www.ugrad.cs.ubc.ca/~cs221 1 Lab 1 available very
More informationLecture 10 Notes Linked Lists
Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Summer 1 2015) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to
More informationFile: /media/young/d1 (180713)/Work tive_tree_search/search_defs.h Page 1 of 1
File: /media/young/d1 (180713)/Work tive_tree_search/search_defs.h Page 1 of 1 #define N 7 #define R N the number of a tree the number of expanding choices = 2*R+1 ---------------------------------------------------------
More informationHow to Win Coding Competitions: Secrets of Champions. Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue.
How to Win Coding Competitions: Secrets of Champions Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue. Deque Pavel Krotkov Saint Petersburg 2016 General overview Stack,
More informationIntroduction to the Stack. Stacks and Queues. Stack Operations. Stack illustrated. elements of the same type. Week 9. Gaddis: Chapter 18
Stacks and Queues Week 9 Gaddis: Chapter 18 CS 5301 Fall 2015 Jill Seaman Introduction to the Stack Stack: a data structure that holds a collection of elements of the same type. - The elements are accessed
More informationUNIT-2 Stack & Queue
UNIT-2 Stack & Queue 59 13. Stack 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 information(6-1) Basics of a Queue. Instructor - Andrew S. O Fallon CptS 122 (September 26, 2018) Washington State University
(6-1) Basics of a Queue Instructor - Andrew S. O Fallon CptS 122 (September 26, 2018) Washington State University What is a Queue? 2 A linear data structure with a finite sequence of nodes, where nodes
More informationPractice test for Midterm 1; solutions
Practice test for Midterm 1; solutions November 1, 2 1 1 C++ review & UML diagrams Write a function which takes a vector of int and returns true if all the elements of the vector are positive ( 0) and
More informationSome major graph problems
CS : Graphs and Blobs! Prof. Graeme Bailey http://cs.cs.cornell.edu (notes modified from Noah Snavely, Spring 009) Some major graph problems! Graph colouring Ensuring that radio stations don t clash! Graph
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 informationME/CS 132: Advanced Robotics: Navigation and Vision
ME/CS 132: Advanced Robotics: Navigation and Vision Lecture #5: Search Algorithm 1 Yoshiaki Kuwata 4/12/2011 Lecture Overview Introduction Label Correcting Algorithm Core idea Depth-first search Breadth-first
More informationFundamental Algorithms
Fundamental Algorithms Chapter 8: Graphs Jan Křetínský Winter 2017/18 Chapter 8: Graphs, Winter 2017/18 1 Graphs Definition (Graph) A graph G = (V, E) consists of a set V of vertices (nodes) and a set
More informationChapter 5. ADTs Stack and Queue
Chapter 5 ADTs Stack and Queue Stacks of Coins and Bills Stacks of Boxes and Books TOP OF THE STACK TOP OF THE STACK Logical (or ADT) level: A stack is an ordered group of homogeneous items (elements),
More informationCh. 18: ADTs: Stacks and Queues. Abstract Data Type
Ch. 18: ADTs: Stacks and Queues CS 2308 Fall 2011 Jill Seaman Lecture 18 1 Abstract Data Type A data type for which: - only the properties of the data and the operations to be performed on the data are
More informationArchivo: /home/young/work/cordic/binary_tree_search/search_defs.h Página 1 de 1
Archivo: /home/young/work/cordic/binary_tree_search/search_defs.h Página 1 de 1 #define N 8 the number of a tree #define R 1 the number of expanding choices = 2*R ---------------------------------------------------------
More informationChapter 4. Uninformed Search Strategies
Chapter 4. Uninformed Search Strategies An uninformed (a.k.a. blind, brute-force) search algorithm generates the search tree without using any domain specific knowledge. The two basic approaches differ
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0)
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) An interesting definition for stack element The stack element could be of any data type struct stackelement int etype; union int ival;
More informationEnd-Term Examination Second Semester [MCA] MAY-JUNE 2006
(Please write your Roll No. immediately) Roll No. Paper Code: MCA-102 End-Term Examination Second Semester [MCA] MAY-JUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1.
More informationYou must include this cover sheet. Either type up the assignment using theory5.tex, or print out this PDF.
15-122 Assignment 5 Page 1 of 11 15-122 : Principles of Imperative Computation Fall 2012 Assignment 5 (Theory Part) Due: Tuesday, October 30, 2012 at the beginning of lecture Name: Andrew ID: Recitation:
More information: Principles of Imperative Computation, Spring Homework 3 Theory [Update 1]
15-122 Homework 3 Page 1 of 15 15-122 : Principles of Imperative Computation, Spring 2013 Homework 3 Theory [Update 1] Due: Thursday, February 21, 2013, at the beginning of lecture Name: Andrew ID: Recitation:
More informationChapter 22 Elementary Graph Algorithms
Chapter 22 Elementary Graph Algorithms Graph Representations Graph G = (V,E) Directed Undirected Adjacency Lists Adjacency Matrix Graph Representations Adjacency List: Undirected Memory: Adjacency: Graph
More informationLecture 24 Search in Graphs
Lecture 24 Search in Graphs 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson, Iliano Cervesato In this lecture, we will discuss the question
More informationAlgorithms and Theory of Computation. Lecture 3: Graph Algorithms
Algorithms and Theory of Computation Lecture 3: Graph Algorithms Xiaohui Bei MAS 714 August 20, 2018 Nanyang Technological University MAS 714 August 20, 2018 1 / 18 Connectivity In a undirected graph G
More informationChapter 18: Stacks And Queues
Chapter 18: Stacks And Queues 18.1 Introduction to the Stack ADT Introduction to the Stack ADT Stack: a LIFO (last in, first out) data structure Examples: plates in a cafeteria return addresses for function
More informationLecture 7: Data Structures. EE3490E: Programming S1 2017/2018 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology
Lecture 7: Data Structures 1 Introduction: dynamic array Conventional array in C has fix number of elements Dynamic array is array with variable number of elements: actually a pointer and a variable indicating
More informationMatriculation number:
Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse 14 8050 Zurich Phone: +41 44 635 4333 Email: boehlen@ifi.uzh.ch AlgoDat Repetition Exam Spring 2018 18.05.2018 Name: Matriculation number:
More informationW4231: Analysis of Algorithms
W4231: Analysis of Algorithms 10/21/1999 Definitions for graphs Breadth First Search and Depth First Search Topological Sort. Graphs AgraphG is given by a set of vertices V and a set of edges E. Normally
More informationIntroduction to the Stack. Stacks and Queues. Stack Operations. Stack illustrated. Week 9. elements of the same type.
Stacks and Queues Week 9 Gaddis: Chapter 18 (8th ed.) Gaddis: Chapter 19 (9th ed.) CS 5301 Fall 2018 Jill Seaman Introduction to the Stack Stack: a data structure that holds a collection of elements of
More informationStack & Queue on Self-Referencing Structures
C Programming 1 Stack & Queue on Self-Referencing Structures C Programming 2 Representation of Stack struct stack { int data ; struct stack *next ; ; typedef struct stacknode node, *stack ; C Programming
More informationCSE 100: GRAPH SEARCH
CSE 100: GRAPH SEARCH Announcements PA3 released Checkpoint due Tuesday, May 5 @10:00pm Final submission due Thursday, May 14 @10:00PM Start early! Start early! Start early! Start early! Start early! I
More informationl Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationWinter 2016 COMP-250: Introduction to Computer Science. Lecture 8, February 4, 2016
Winter 2016 COMP-250: Introduction to Computer Science Lecture 8, February 4, 2016 Stacks in the Java Virtual Machine Each process running in a Java program has its own Java Method Stack. Each time a method
More informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE
TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)
More informationatomicadd(int* address, int val); float atomicadd(float* address, float val); atomicsub(int* address, int val); atomicexch(int* address, int val);
int atomicadd(int* address, int val); float atomicadd(float* address, float val); int int atomicsub(int* address, int val); atomicexch(int* address, int val); float atomicexch(float* address, float val);
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 17 EXAMINATION Subject Name: Data Structure Using C Model Answer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as
More informationChapter 18: Stacks And Queues. Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 18: Stacks And Queues Copyright 2009 Pearson Education, Inc. Copyright Publishing as Pearson 2009 Addison-Wesley Pearson Education, Inc. Publishing as Pearson Addison-Wesley 18.1 Introduction to
More information! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises CS 2308 Spring 2014 Jill Seaman Chapters 1-7 + 11 Write C++ code to: Determine if a number is odd or even Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationAbstract Data Types. Stack ADT
Abstract Data Types Data abstraction consepts have been introduced in previous courses, for example, in Chapter 7 of [Deitel]. The Abstract Data Type makes data abstraction more formal. In essence, an
More informationWinter 2016 COMP-250: Introduction to Computer Science. Lecture 8, February 4, 2016
Winter 2016 COMP-250: Introduction to Computer Science Lecture 8, February 4, 2016 Stacks in the Java Virtual Machine Each process running in a Java program has its own Java Method Stack. Each time a method
More information8. Fundamental Data Structures
172 8. Fundamental Data Structures Abstract data types stack, queue, implementation variants for linked lists, [Ottman/Widmayer, Kap. 1.5.1-1.5.2, Cormen et al, Kap. 10.1.-10.2] Abstract Data Types 173
More informationMIDTERM EXAMINATION Spring 2010 CS301- Data Structures
MIDTERM EXAMINATION Spring 2010 CS301- Data Structures Question No: 1 Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the
More informationCome to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.
It is most beneficial to you to write this mock midterm UNDER EXAM CONDITIONS. This means: Complete the mock final in 170 minutes. Work on your own. Keep your notes and textbook closed. Attempt every question.
More information