Exam Review 2 Chapter 5 – 9 CSC212 FG CS Dept, CCNY.

Slides:



Advertisements
Similar presentations
1 Linked lists Sections 3.2, 3.3, 3.5 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors.
Advertisements

1111 Abstract Data Types Cpt S 223. School of EECS, WSU.
Chapter 6 Queues and Deques.
The unorganized person’s data structure
Review of Stacks and Queues Dr. Yingwu Zhu. Our Focus Only link-list based implementation of Stack class Won’t talk about different implementations of.
ADT Queue 1. What is a Queue? 2. STL Queue 3. Array Implementation of Queue 4. Linked List Implementation of Queue 5. Priority Queue.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18: Stacks And Queues.
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
Reviews for Exam 1 Chapter 1-4 CSc 212 Data Structures, Sec FG CCNY, Fall 2010.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 8 Dynamic Classes and the Law of the Big Three Instructor: Zhigang Zhu Department.
Exam Review 2 Chapter 5 – 9 CSC212 RS March 31, 2011, CS Dept, CCNY.
Reviews for Exam 1 Chapter 1-4 CS 211 Data Structures MHC, 2007.
COMP 171 Data Structures and Algorithms Tutorial 1 Template and STL.
Main Index Contents 11 Main Index Contents Model for a Queue Model for a Queue The Queue The Queue ADTQueue ADT (3 slides) Queue ADT Radix Sort Radix Sort.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 10 The Bag and Sequence Classes with Linked Lists Instructor: Zhigang Zhu Department.
1 Queues CPS212 Gordon College. 2 Introduction to Queues A queue is a waiting line – seen in daily life –Real world examples – toll booths, bank, food.
Exam Review 2 Chapter 5 – 9 CS211 November 05,2007, CS Dept, MHC.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
CSC212 Data Structure - Section FG Lecture 12 Stacks and Queues Instructor: Zhigang Zhu Department of Computer Science City College of New York.
Class 4: Queues. cis 335 Fall 2001 Barry Cohen What is a queue? n A stack is an ordered sequence of items. n As in lists and stacks, each node contains.
Data Structures Chapter 2 Stacks Andreas Savva. 2 Stacks A stack is a data structure in which all insertions and deletions of entries are made at one.
The Stack and Queue Types Lecture 10 Hartmut Kaiser
Object Oriented Data Structures
Review for Midterm Chapter 1-9 CSc 212 Data Structures.
1 Stacks Stack Examples Stack API More Examples/Uses Base Conversion Activation Records RPN Implementing a Stack Stacks.
Data Structures Using C++ 2E
Containers Overview and Class Vector
1 CSC 222: Computer Programming II Spring 2004 Pointers and linked lists  human chain analogy  linked lists: adding/deleting/traversing nodes  Node.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R1. Elementary Data Structures.
COP3530 Data Structures600 Stack Stack is one the most useful ADTs. Like list, it is a collection of data items. Supports “LIFO” (Last In First Out) discipline.
Xiaoyan Li, CSC211 Data Structures Lecture 10 The Bag and Sequence Classes with Linked Lists Instructor: Prof. Xiaoyan Li Department of Computer.
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
Data Structures Using C++ 2E Chapter 8 Queues. Data Structures Using C++ 2E2 Objectives Learn about queues Examine various queue operations Learn how.
C++ STL CSCI 3110.
Data Structures Using C++
Chapter 9: Part 2: Vectors + Maps and STL Overview JPC and JWD © 2002 McGraw-Hill, Inc. Modified by S. Sudarshan.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Slide 1 Linked Data Structures. Slide 2 Learning Objectives  Nodes and Linked Lists  Creating, searching  Linked List Applications  Stacks, queues.
Review of Stacks and Queues Dr. Yingwu Zhu. How does a Stack Work? Last-in-First-out (LIFO) data structure Adding an item Push operation Removing an item.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Copyright © 2002 Pearson Education, Inc. Slide 1.
CSC212 Data Structure - Section FG Lecture 11 Templates, Iterators and STL Instructor: Professor Zhigang Zhu Department of Computer Science City College.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 18: Stacks and Queues.
Data Structures and Algorithm Analysis Dr. Ken Cosh Stacks ‘n’ Queues.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
1 Queues Queue API Application: Radix Sort Implementation: Using Deque Using Deque Circular Array Circular Array Priority Queue Priority Queue API Implementation.
Fall 2006 METU EEEEE 441 S. Ece (GURAN) SCH MIDT EE 441 Data Structures Lecture 6 Stacks and Queues.
Xiaoyan Li, CSC211 Data Structures Lecture 8 Dynamic Classes and the Law of the Big Three Instructor: Prof. Xiaoyan Li Department of Computer Science.
1 Chapter 3 Lists, Stacks, and Queues Reading: Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
1 Data Structures CSCI 132, Spring 2016 Notes_ 5 Stacks.
18 Chapter Stacks and Queues
CS 215 Final Review Ismail abumuhfouz Fall 2014.
Templates, Iterators and STL
The Bag and Sequence Classes with Linked Lists
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
CMSC 341 Lecture 5 Stacks, Queues
Pointers and Linked Lists
Chapter 5 – 9 CSC212 AB April 03, CS Dept, CCNY
Chapter 5 – 9 CSC212 KL Nov 8, CS Dept, CCNY
Multiset Class and its Iterator
Chapter 5 – 9 CSC212 RS April 08, CS Dept, CCNY
Introduction to Programming
Containers: Queue and List
Jordi Cortadella and Jordi Petit Department of Computer Science
Visit for more Learning Resources
Using a Queue Chapter 8 introduces the queue data type.
Using a Queue Chapter 8 introduces the queue data type.
Chapter 3 Lists, Stacks, and Queues
Data Structures & Programming
Presentation transcript:

Exam Review 2 Chapter 5 – 9 CSC212 FG CS Dept, CCNY

Chapter 5: Linked Lists Node Class (Ex 1-4, 6-9) Linked List Toolkit (Ex ) The bag Class with a Linked List (Ex 19-21, 23,24,26) The sequence class with a Linked List (Ex 27-30: please refer to assignment 4) Comparison of dynamic arrays, linked lists and doubly linked lists (Ex 31-36)

Chapter 6: Templates, Iterators and STL Template Functions and Template Classes –for code that is meant be reused in a variety of settings in a single program –Sections , Ex 1-3, 6-11 Iterators (Sec , Ex 17-28) –step through all items of a container in a standard manner Standard Template Library (Section 6.3, Ex ) –the ANSI/ISO C++ Standard provides a variety of container classes in the STL

All you need to know about Templates Template Function (Ex. 1-3) –a template prefix before the function implementation –template Function Prototype –a template prefix before the function prototypes Template Class (Ex. 6-10) –a template prefix right before the class definition Instantiation (Ex 11) –template functions/classes are instantiated when used Better Understanding of classes and functions

Iterators (Sec , Ex 17-28) We discussed how to build an iterator for the linked list so that each of the containers can build its own iterator(s) easily A node iterator is an object of the node_iterator class, and can step through the nodes of the linked list

Linked List Version the bag Template Class with an Iterator Most of the implementation of this new bag is a straightforward translation of the bag in Chapter 5 that used an ordinary linked list Two new features –Template class with a underlying type Item –iterator and const_iterator – defined from node_iterator and const_node_iterator, but use the C++ standard [...) left inclusive pattern

Standard Template Library (STL) The ANSI/ISO C++ Standard provides a variety of container classes in the STL –set, multiset, stack, queue, string, vector Featured templates and iterators For example, the multiset template class is similar to our bag template class More classes summarized in Appendix H

Chapters 7/8 Stacks and Queues Stacks and LIFO( Read Chapter 7, esp. 7.1 and 7.3 ) –Self-Test: 1, 2, 7, 8, 9, 10, Queues and FIFO ( Read Chapter 8, esp. 8.1 and 8.3 ) –Self-Test: 1, 2, 6,10, 11,12 Priority Queues ( Read Section 8.4 ) –Self-Test: 16, 17 References Return Values ( Read Section 8.5 and p. 302 in Chapter 6 ) –Self-Test: class note of Lecture 12

Chapter 9 Recursive Thinking Recursive Functions (Section 9.1) –Recursive Calls and Stopping Cases –Activation Record and Run-Time Stack –Self-Test: Exercises 1-4 Reasoning about Recursion (Section 9.3) –Infinite Recursion and One Level Recursion –Ensure no Infinite and Correctness –Ex. 9, 10 on page 448 Applications of Recursion (Optional :Section 9.2)

A quiz on queue Implement –queue –push –pop –front Check pre- conditions if needed template class queue { public: // TYPEDEFS and MEMBER CONSTANTS typedef std::size_t size_type; typedef Item value_type; static const size_type CAPACITY = 30; // CONSTRUCTOR queue( ); // MODIFICATION MEMBER FUNCTIONS void push(const Item& entry); void pop( ); // CONSTANT MEMBER FUNCTIONS Item front( ) const; bool empty( ) const { return (count == 0); } size_type size( ) const { return count; } private: Item data[CAPACITY]; // Circular array size_type first; // Index of item at front of the queue size_type last; // Index of item at rear of the queue size_type count; // Total number of items in the queue // HELPER MEMBER FUNCTION size_type next_index(size_type i) const { return (i+1) % CAPACITY; } };

Exam 2 Nov 09, 2015, from 4:00 to 5:30 pm