Abstract Data Types. Definitions, Implementations, and Uses

Size: px
Start display at page:

Download "Abstract Data Types. Definitions, Implementations, and Uses"

Transcription

1 Abstract Data Types Definitions, Implementations, and Uses

2 ADT An abstract data representation without reference to a specific implementation TABLE QUEUE STACK The primitive operations on the ADT elements store, retrieve, lookup Generically called getters and setters tostring provides a generic way to display the contents of a complex data element

3 Order TABLE ADT Unique key Data needed Store (insert) Search (lookup) Name & Address Telephone Number Retrieve (get_by_key)

4 TABLE Primitive Operations Insert (for ordered tables) Delete Find (search by key) Retrieve (data by key) = get(find()) Operations ordinarily dominated by retrieval Requires a find (by key) and a get (return of value) Does not modify the table data Traverse (all of the above require an ability to walk the links

5 TABLE Composite Operations Edit (general) Retrieve (to get location) Delete old data Insert new data Depending on how the table is implemented this could take up to three taversrals

6 QUEUE ADT Head First-In-First-Out Tail Retrieve (dequeue) Store (enqueue)

7 QUEUE Primitive Operations isempty returns true if there is nothing in the queue isfull returns true if this is a fixed size and is full of elements Enqueue adds an element to the tail of the queue Dequeue removes an element from the head Peek looks at the head element without removing it

8 STACK ADT Last-In-First-Out Store (push) Top_of_stack Retrieve (pop)

9 STACK Primitive Operations isempty returns true if there are no elements in the stack isfull returns true if the stack is of fixed size and it is full of elements Push puts a new element at the top of the stack Pop removes an element from the top of the stack Peek looks at the element at the top of the stack without removing it

10 Array Implementations Table multiple arrays or multi-dimensional Key element and value element must be kept in order Sorting two arrays difficult and time inefficient Searching can be implemented as a binary search much faster Queue Single dimensioned array of data type Problem with moving data toward index 0 Circular queue is very efficient Fixed size Stack Single dimensioned array of data type Fixed size

11 Linked List Implementation Linked lists are extensible (can grow as needed) Search operations take time proportional to the size of the list, n Good performance for queues and stacks but not so good for tables

12 Linked List Details Could be in program heap or function stack frame head count first last headptr variable In program heap stack (function stack frame) To Add data to unordered list just make the last element point to the new data node. first node node last data data NULL data typedef struct nodestr { Data data; nodestr ; } NodeStr; data heap variables data data typedef struct headstr { int count; NodePtr first; NodePtr last; } HeadStr; typedef HeadStr * HeadPtr; typedef NodeStr * NodePtr;

13 Linked List Insert newnode datab > dataa Go to next node node datab node datac > datab Insert before dataa datac temp_p Insert datab behind dataa and before datac to establish order. Doubly linked list prior_p dataa prior_p datab

14 BST New Node David left right root pointer Stack Bill Dennis Heap Less than left right 1 root node left right 0 Donald Granford George More than left right 2 Greg Jim Arron left right left right left right left right left right 5 6 left right 8 Kelly

15 class Node { string ; float salary; double y_t_d; Node * ; } Hash Table/Map Implementation of Fast Table hash Wayvern function % class Head { int count; node first; } class HashMap { int size; head hashmap[size]; modulo the array size = Table Array node salary y_t_d node salary y_t_d Wayne Wayvern } int hash(string); void insert(node entry); node find(string ); float getsalary(string ); double getyeartodate(string ); etc. size

Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.

Data 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 information

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Cpt S 122 Data Structures. Course Review Midterm Exam # 1 Cpt S 122 Data Structures Course Review Midterm Exam # 1 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 1 When: Friday (09/28) 12:10-1pm Where:

More information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0)

CS11001/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 information

Stack and Queue. Stack:

Stack 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 information

Linked List. April 2, 2007 Programming and Data Structure 1

Linked 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 information

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

MULTIMEDIA 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 information

All the above operations should be preferably implemented in O(1) time. End of the Queue. Front of the Queue. End Enqueue

All the above operations should be preferably implemented in O(1) time. End of the Queue. Front of the Queue. End Enqueue Module 4: Queue ADT Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Queue ADT Features (Logical View) A List that

More information

CS24 Week 4 Lecture 2

CS24 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 information

Queues. October 20, 2017 Hassan Khosravi / Geoffrey Tien 1

Queues. 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 information

Linked Lists and Abstract Data Structures A brief comparison

Linked Lists and Abstract Data Structures A brief comparison Linked Lists and Abstract Data A brief comparison 24 March 2011 Outline 1 2 3 4 Data Data structures are a key idea in programming It s just as important how you store the data as it is what you do to

More information

Cpt S 122 Data Structures. Data Structures

Cpt S 122 Data Structures. Data Structures Cpt S 122 Data Structures Data Structures Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Self Referential Structures Dynamic Memory Allocation

More information

1 P age DS & OOPS / UNIT II

1 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 information

COP 3502 (Computer Science I) Test #3: Data Structures Date: 11/1/2013 VERSION A

COP 3502 (Computer Science I) Test #3: Data Structures Date: 11/1/2013 VERSION A COP 3502 (Computer Science I) Test #3: Data Structures Date: 11/1/2013 VERSION A Directions: This is a multiple choice test. Each question is worth 5 points. Please choose the most accurate answer listed.

More information

.:: UNIT 4 ::. STACK AND QUEUE

.:: 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 information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Topics: Priority Queue Linked List implementation Sorted Unsorted Heap structure implementation TODAY S TOPICS NOT ON THE MIDTERM 2 Some priority queue

More information

CS6202 - 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 information

Summer Final Exam Review Session August 5, 2009

Summer Final Exam Review Session August 5, 2009 15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding

More information

DATA 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. 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

CP2 Revision. theme: dynamic datatypes & data structures

CP2 Revision. theme: dynamic datatypes & data structures CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;

More information

ITI Introduction to Computing II

ITI 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 information

C Data Structures Stacks. Stack. push Adds a new node to the top of the stack

C Data Structures Stacks. Stack. push Adds a new node to the top of the stack 1 12 C Data Structures 12.5 Stacks 2 Stack New nodes can be added and removed only at the top Similar to a pile of dishes Last-in, first-out (LIFO) Bottom of stack indicated by a link member to NULL Constrained

More information

Data Structures. Alice E. Fischer. Lecture 4, Fall Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall / 19

Data Structures. Alice E. Fischer. Lecture 4, Fall Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall / 19 Data Structures Alice E. Fischer Lecture 4, Fall 2018 Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall 2018 1 / 19 Outline 1 Ordered Lists 2 Sorted Lists Tail Pointers 3 Doubly Linked Lists

More information

CS300 Final Review Questions 1

CS300 Final Review Questions 1 CS300 Final Review Questions 1 This is not a complete list of questions and topics, but a good sampling of questions that will help you study for the final. I strongly advise you to work through every

More information

Solution for Data Structure

Solution 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 information

CSC 1052 Algorithms & Data Structures II: Linked Queues

CSC 1052 Algorithms & Data Structures II: Linked Queues CSC 1052 Algorithms & Data Structures II: Linked Queues Professor Henry Carter Spring 2018 Recap A queue simulates a waiting line, where objects are removed in the same order they are added The primary

More information

Data Structure Advanced

Data Structure Advanced Data Structure Advanced 1. Is it possible to find a loop in a Linked list? a. Possilbe at O(n) b. Not possible c. Possible at O(n^2) only d. Depends on the position of loop Solution: a. Possible at O(n)

More information

3. Fundamental Data Structures

3. Fundamental Data Structures 3. Fundamental Data Structures CH08-320201: Algorithms and Data Structures 233 Data Structures Definition (recall): A data structure is a way to store and organize data in order to facilitate access and

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 18 EXAMINATION Subject Name: Data Structure Model wer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in

More information

CMSC Introduction to Algorithms Spring 2012 Lecture 7

CMSC 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 information

Search Trees. Data and File Structures Laboratory. DFS Lab (ISI) Search Trees 1 / 17

Search Trees. Data and File Structures Laboratory.  DFS Lab (ISI) Search Trees 1 / 17 Search Trees Data and File Structures Laboratory http://www.isical.ac.in/~dfslab/2017/index.html DFS Lab (ISI) Search Trees 1 / 17 Binary search trees. Definition. Binary tree in which following property

More information

Chapter 17: Linked Lists

Chapter 17: Linked Lists Chapter 17: Linked Lists 17.1 Introduction to the Linked List ADT Introduction to the Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures list head

More information

! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge

! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge Trees & Heaps Week 12 Gaddis: 20 Weiss: 21.1-3 CS 5301 Fall 2018 Jill Seaman!1 Tree: non-recursive definition! Tree: set of nodes and directed edges - root: one node is distinguished as the root - Every

More information

COMP 250 Midterm #2 March 11 th 2013

COMP 250 Midterm #2 March 11 th 2013 NAME: STUDENT ID: COMP 250 Midterm #2 March 11 th 2013 - This exam has 6 pages - This is an open book and open notes exam. No electronic equipment is allowed. 1) Questions with short answers (28 points;

More information

8. Fundamental Data Structures

8. 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 information

CS 225. April 6 Disjoint Sets Implementation. Data Structures. Wade Fagen-Ulmschneider

CS 225. April 6 Disjoint Sets Implementation. Data Structures. Wade Fagen-Ulmschneider CS 225 Data Structures April 6 Disjoint Sets Implementation Wade Fagen-Ulmschneider Disjoint Sets 2 5 9 7 0 1 4 8 3 6 5 7 4 3 9 2 0 8 6 1 0 4 1 2 3 4 5 6 7 8 5-1 -1-1 3-1 8 9 4 5 Disjoint Sets Find 1 2

More information

Chapter 17: Linked Lists

Chapter 17: Linked Lists Chapter 17: Linked Lists Copyright 2009 Pearson Education, Inc. Copyright Publishing as Pearson 2009 Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 17.1 Introduction to the

More information

l 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)

l 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 information

Queues. A queue is a special type of structure that can be used to maintain data in an organized way.

Queues. 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 information

Final Exam Data Structure course. No. of Branches (5)

Final Exam Data Structure course. No. of Branches (5) Page ١of 5 College Of Science and Technology Khan younis - Palestine Computer Science & Inf. Tech. Information Technology Data Structure (Theoretical Part) Time: 2 Hours Name: ID: Mark: Teacher 50 Mahmoud

More information

Lists, Stacks and Queues in C. CHAN Hou Pong, Ken CSCI2100A Data Structures Tutorial 4

Lists, Stacks and Queues in C. CHAN Hou Pong, Ken CSCI2100A Data Structures Tutorial 4 Lists, Stacks and Queues in C CHAN Hou Pong, Ken CSCI2100A Data Structures Tutorial 4 Outline Structure Linked List Overview Implementation Stack Overview Implementation Queue Overview Implementation 2

More information

Abstract 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 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 information

table1 = [ [1, 2, 3, 4], [4, 5, 6, 7], [8, 9,10,11] ] we get: >>> sumcol(table1,0) 13 >>> sumcol(table1,1) 16

table1 = [ [1, 2, 3, 4], [4, 5, 6, 7], [8, 9,10,11] ] we get: >>> sumcol(table1,0) 13 >>> sumcol(table1,1) 16 Algorithms and Data Structures : Week 1 Representations of data structures Multi-Dimensional Array Tasks Sum Columns of Table Write a function to sum the columns of a 2 dimensional array (i.e. a list of

More information

Introduction to Data Structures and Algorithms

Introduction to Data Structures and Algorithms Introduction to Data Structures and Algorithms Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective way. Data Structures

More information

Data Structures and Algorithms. Roberto Sebastiani

Data Structures and Algorithms. Roberto Sebastiani Data Structures and Algorithms Roberto Sebastiani roberto.sebastiani@disi.unitn.it http://www.disi.unitn.it/~rseba - Week 05 - B.S. In Applied Computer Science Free University of Bozen/Bolzano academic

More information

Revision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,

Revision 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 information

CSE 373 SEPTEMBER 29 STACKS AND QUEUES

CSE 373 SEPTEMBER 29 STACKS AND QUEUES CSE 373 SEPTEMBER 29 STACKS AND QUEUES DESIGN DECISIONS Shopping list? DESIGN DECISIONS Shopping list? What sorts of behavior do shoppers exhibit? What constraints are there on a shopper? What improvements

More information

CS/CE 2336 Computer Science II

CS/CE 2336 Computer Science II CS/CE 2336 Computer Science II UT D Session 11 OO Data Structures Lists, Stacks, Queues Adapted from D. Liang s Introduction to Java Programming, 8 th Ed. 2 What is a Data Structure? A collection of data

More information

CSE 100: GRAPH ALGORITHMS

CSE 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 information

Name CPTR246 Spring '17 (100 total points) Exam 3

Name 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 information

CSE 12 Week Eight, Lecture One

CSE 12 Week Eight, Lecture One CSE 12 Week Eight, Lecture One Heap: (The data structure, not the memory area) - A binary tree with properties: - 1. Parent s are greater than s. o the heap order - 2. Nodes are inserted so that tree is

More information

Data Structure - Stack and Queue-

Data 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 information

CS 216 Exam 1 Fall SOLUTION

CS 216 Exam 1 Fall SOLUTION CS 216 Exam 1 Fall 2004 - SOLUTION Name: Lab Section: Email Address: Student ID # This exam is closed note, closed book. You will have an hour and fifty minutes total to complete the exam. You may NOT

More information

CMSC 132: Object-Oriented Programming II. Stack and Queue

CMSC 132: Object-Oriented Programming II. Stack and Queue CMSC 132: Object-Oriented Programming II Stack and Queue 1 Stack Allows access to only the last item inserted. An item is inserted or removed from the stack from one end called the top of the stack. This

More information

Lecture Notes CPSC 122 (Fall 2014) Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S.

Lecture Notes CPSC 122 (Fall 2014) Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S. Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S. Bowers 1 of 11 Doubly Linked Lists Each node has both a next and a prev pointer head \ v1 v2 v3 \ tail struct

More information

UNIT-2 Stack & Queue

UNIT-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

CS 225. Nov. 13 Introduction to Graphs. Data Structures. Wade Fagen-Ulmschneider

CS 225. Nov. 13 Introduction to Graphs. Data Structures. Wade Fagen-Ulmschneider CS 225 Data Structures Nov. 13 Introduction to Graphs Wade Fagen-Ulmschneider UpTree 10 9 11 1 7 2 8 3 4 5 6 Disjoint Sets Find 1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 int DisjointSets::find(int

More information

Introduction to Data Structures. Introduction to Data Structures. Introduction to Data Structures. Data Structures

Introduction to Data Structures. Introduction to Data Structures. Introduction to Data Structures. Data Structures Philip Bille Data Structures Data structure. Method for organizing data for efficient access, searching, manipulation, etc. Goal. Fast. Compact Terminology. Abstract vs. concrete data structure. Dynamic

More information

ADVANCED DATA STRUCTURES USING C++ ( MT-CSE-110 )

ADVANCED 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 information

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance Course goals exposure to another language C++ Object-oriented principles knowledge of specific data structures lists, stacks & queues, priority queues, dynamic dictionaries, graphs impact of DS design

More information

Definition of Stack. 5 Linked Structures. Stack ADT Operations. ADT Stack Operations. A stack is a LIFO last in, first out structure.

Definition of Stack. 5 Linked Structures. Stack ADT Operations. ADT Stack Operations. A stack is a LIFO last in, first out structure. 5 Linked Structures Definition of Stack Logical (or ADT) level: A stack is an ordered group of homogeneous items (elements), in which the removal and addition of stack items can take place only at the

More information

CSC 1052 Algorithms & Data Structures II: Queues

CSC 1052 Algorithms & Data Structures II: Queues CSC 1052 Algorithms & Data Structures II: Queues Professor Henry Carter Spring 2018 Recap Recursion solves problems by solving smaller version of the same problem Three components Applicable in a range

More information

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis p. 5 Statement Constructs p. 5 Pseudocode Example p.

More information

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures Data Structures in C C Programming and Software Tools N.C. State Department of Computer Science Data Structures in C The combination of pointers, structs, and dynamic memory allocation allow for creation

More information

182 review 1. Course Goals

182 review 1. Course Goals Course Goals 182 review 1 More experience solving problems w/ algorithms and programs minimize static methods use: main( ) use and overload constructors multiple class designs and programming solutions

More information

10 MCQ of Data Structure Paper-2(CS/IT) For NIC SSC Scientific Assistant IBPS IT Officer Exam 2017

10 MCQ of Data Structure Paper-2(CS/IT) For NIC SSC Scientific Assistant IBPS IT Officer Exam 2017 10 MCQ of Data Structure Paper-2(CS/IT) For NIC SSC Scientific Assistant IBPS IT Officer Exam 2017 1)The time complexity for evaluating a postfix expression is a)o(n^2) b)o(logn) c)o(n) d)o(nlogn) 2)We

More information

DNHI Homework 3 Solutions List, Stacs and Queues

DNHI Homework 3 Solutions List, Stacs and Queues Solutions List, Stacs and Queues Problem 1 Given the IntegerQueue ADT below state the return value and show the content of the, initially empty, queue of Integer objects after each of the following operations.

More information

Data Structures Question Bank Multiple Choice

Data Structures Question Bank Multiple Choice Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution

More information

Postfix (and prefix) notation

Postfix (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 information

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

MIDTERM 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 information

Queues. Lesson 4. CS 32: Data Structures Dept. of Computer Science

Queues. Lesson 4. CS 32: Data Structures Dept. of Computer Science Queues Lesson 4 Outline What is a queue? Straight queue Circular Queue Sequential Implementation Linked Implementation Application: Topological sort Deques Final Notes Outline What is a queue? Straight

More information

Lecture Data Structure Stack

Lecture 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 information

CMPT 225. Lecture 6 linked list

CMPT 225. Lecture 6 linked list CMPT 225 Lecture 6 linked list 1 Last Lecture Class documentation Linked lists and its operations 2 Learning Outcomes At the end of this lecture, a student will be able to: define one of the concrete data

More information

CS 1114: Implementing Search. Last time. ! Graph traversal. ! Two types of todo lists: ! Prof. Graeme Bailey.

CS 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 information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today Introduction to Linked Lists Stacks and Queues using Linked Lists Next Time Iterative Algorithms on Linked Lists Reading:

More information

Data Structures and Algorithms

Data 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 information

CSCE 2014 Final Exam Spring Version A

CSCE 2014 Final Exam Spring Version A CSCE 2014 Final Exam Spring 2017 Version A Student Name: Student UAID: Instructions: This is a two-hour exam. Students are allowed one 8.5 by 11 page of study notes. Calculators, cell phones and computers

More information

Programming. Lists, Stacks, Queues

Programming. Lists, Stacks, Queues Programming Lists, Stacks, Queues Summary Linked lists Create and insert elements Iterate over all elements of the list Remove elements Doubly Linked Lists Circular Linked Lists Stacks Operations and implementation

More information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0)

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) The queue ADT A queue is like a "natural" queue of elements. It is an ordered list in which all insertions occur at one end called

More information

Queues Fall 2018 Margaret Reid-Miller

Queues 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

Lecture Notes. char myarray [ ] = {0, 0, 0, 0, 0 } ; The memory diagram associated with the array can be drawn like this

Lecture Notes. char myarray [ ] = {0, 0, 0, 0, 0 } ; The memory diagram associated with the array can be drawn like this Lecture Notes Array Review An array in C++ is a contiguous block of memory. Since a char is 1 byte, then an array of 5 chars is 5 bytes. For example, if you execute the following C++ code you will allocate

More information

Computer Science 1 Study Union Practice Problems. What are the arguments to malloc? calloc? realloc? What do they do?

Computer Science 1 Study Union Practice Problems. What are the arguments to malloc? calloc? realloc? What do they do? Study Union Review Jacob Cornett 1 Computer Science 1 Study Union Practice Problems!This may not be a comprehensive review of everything that will be on your exam and we may go over more during the session.

More information

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012 Data Abstractions National Chiao Tung University Chun-Jen Tsai 05/23/2012 Concept of Data Structures How do we store some conceptual structure in a linear memory? For example, an organization chart: 2/32

More information

Standard ADTs. Lecture 19 CS2110 Summer 2009

Standard ADTs. Lecture 19 CS2110 Summer 2009 Standard ADTs Lecture 19 CS2110 Summer 2009 Past Java Collections Framework How to use a few interfaces and implementations of abstract data types: Collection List Set Iterator Comparable Comparator 2

More information

Introduction to Data Structures

Introduction to Data Structures Introduction to Data Structures Data structures Stacks and Queues Linked Lists Dynamic Arrays Philip Bille Introduction to Data Structures Data structures Stacks and Queues Linked Lists Dynamic Arrays

More information

Stack. Data structure with Last-In First-Out (LIFO) behavior. Out

Stack. 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 information

CS301 - Data Structures Glossary By

CS301 - Data Structures Glossary By CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm

More information

Computer Science 302 Spring 2007 Practice Final Examination: Part I

Computer Science 302 Spring 2007 Practice Final Examination: Part I Computer Science 302 Spring 2007 Practice Final Examination: Part I Name: This practice examination is much longer than the real final examination will be. If you can work all the problems here, you will

More information

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues

CPSC 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 information

Object Oriented Programming COP3330 / CGS5409

Object Oriented Programming COP3330 / CGS5409 Object Oriented Programming COP3330 / CGS5409 Intro to Data Structures Vectors Linked Lists Queues Stacks C++ has some built-in methods of storing compound data in useful ways, like arrays and structs.

More information

Linked Lists. Linked list: a collection of items (nodes) containing two components: Data Address (link) of the next node in the list

Linked Lists. Linked list: a collection of items (nodes) containing two components: Data Address (link) of the next node in the list Linked Lists Introduction : Data can be organized and processed sequentially using an array, called a sequential list Problems with an array Array size is fixed Unsorted array: searching for an item is

More information

More Data Structures (Part 1) Stacks

More Data Structures (Part 1) Stacks More Data Structures (Part 1) Stacks 1 Stack examples of stacks 2 Top of Stack top of the stack 3 Stack Operations classically, stacks only support two operations 1. push 2. pop add to the top of the stack

More information

CS200: Queues. Prichard Ch. 8. CS200 - Queues 1

CS200: 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 information

Queue Linked List Implementation

Queue Linked List Implementation SCJ2013 Data Structure & Algorithms Queue Linked List Implementation Nor Bahiah Hj Ahmad Queue Implementation Link List Pointer Based Implementation Can be implemented using linear linked list or circular

More information

DS L9: Queues

DS L9: Queues Indian Institute of Science Bangalore, India भ रत य व ज ञ न स स थ न ब गल र, भ रत Department of Computational and Data Sciences DS286 2016-09-09 L9: Queues Yogesh Simmhan s i m m h a n @ c d s. i i s c.

More information

Linked Lists. Linked list: a collection of items (nodes) containing two components: Data Address (link) of the next node in the list

Linked Lists. Linked list: a collection of items (nodes) containing two components: Data Address (link) of the next node in the list Linked Lists Introduction : Data can be organized and processed sequentially using an array, called a sequential list Problems with an array Array size is fixed Unsorted array: searching for an item is

More information

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 4/18/2013

Linear 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 information

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC) SET - 1 II B. Tech I Semester Supplementary Examinations, May/June - 2016 PART A 1. a) Write a procedure for the Tower of Hanoi problem? b) What you mean by enqueue and dequeue operations in a queue? c)

More information

Agenda. Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList!

Agenda. Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList! Implementations I 1 Agenda Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList! Stack and queues Array-based implementations

More information

Ashish Gupta, Data JUET, Guna

Ashish 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 information

Applied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011

Applied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011 Applied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011 Autumn 2015 Lecture 5, C programming: Abstract Data Types A. Maki, C. Edlund Abstract Data

More information