Chapter 5 – 9 CSC212 KL Nov 8, CS Dept, CCNY

Slides:



Advertisements
Similar presentations
Copyright © 2002 Pearson Education, Inc. Slide 1.
Advertisements

Chapter 19 Standard Template Library. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Iterators Constant and mutable.
Hold data and provide access to it. Random-access containers: -Allow accessing any element by index -arrays, vectors Sequential containers: -Allow accessing.
Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.
C++ Templates. What is a template? Templates are type-generic versions of functions and/or classes Template functions and template classes can be used.
Copyright © 2012 Pearson Education, Inc. Chapter 16: Exceptions, Templates, and the Standard Template Library (STL)
Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.
Exam Review 2 Chapter 5 – 9 CSC212 RS March 31, 2011, CS Dept, CCNY.
Exam Review 2 Chapter 5 – 9 CS211 November 05,2007, CS Dept, MHC.
C++ Programming: Program Design Including Data Structures, Second Edition Chapter 22: Standard Template Library (STL)
CMSC 202 Lesson 24 Iterators and STL Containers. Warmup Write the class definition for the templated Bag class – A bag has: Random insertion Random removal.
Review for Midterm Chapter 1-9 CSc 212 Data Structures.
Dr. Yingwu Zhu STL Vector and Iterators. STL (Standard Template Library) 6:14:43 AM 2 A library of class and function templates Components: 1. Containers:
Data Structures Using C++ 2E
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Standard Template Library (STL)
Data Structures Using C++ 2E Chapter 8 Queues. Data Structures Using C++ 2E2 Objectives Learn about queues Examine various queue operations Learn how.
Friends & Standard Template Library CSCI3110 Advanced Data Structures Lecturer: Dr. Carroll and Nan Chen.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
CS342 Data Structures End-of-semester Review S2002.
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.
CSC 212 Sequences & Iterators. Announcements Midterm in one week  Will cover through chapter 5 of book  Midterm will be open book, open note (but, closed.
Exam Review 2 Chapter 5 – 9 CSC212 FG CS Dept, CCNY.
CSCI-383 Object-Oriented Programming & Design Lecture 25.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Function Templates 16.2.
Object-Oriented Programming (OOP) Lecture No. 41
Data Structures Using C++ 2E
Regarding homework 9 Many low grades
Lecture 04: Sequences structures
CS 215 Final Review Ismail abumuhfouz Fall 2014.
Midterm Review.
Exceptions, Templates, and the Standard Template Library (STL)
Templates, Iterators and STL
Standard Template Library (STL)
ENERGY 211 / CME 211 Lecture 12 October 17, 2008.
Week 15 – Monday CS221.
Chapter 1-4 CSc 212 Data Structures, Sec AB CCNY, Spring 2012
The Bag and Sequence Classes with Linked Lists
Template Functions Chapter 6 introduces templates, which are a C++ feature that easily permits the reuse of existing code for new purposes. This presentation.
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
Exam 2 Review CS 3358 Data Structures.
Function and class templates
Chapter 5 – 9 CSC212 AB April 03, CS Dept, CCNY
ADT Implementations: Templates and Standard Containers
Review for Exam 1 Topics covered: For each of these data structures
Introduction to the Standard Template Library
Exam 1 Review CS 3358.
Stacks, Queues, and Deques
Queue and Priority Queue Implementations
Template Functions Chapter 6 introduces templates, which are a C++ feature that easily permits the reuse of existing code for new purposes. This presentation.
Exam 1 Review CS 3358.
CSC 143 Queues [Chapter 7].
Multiset Class and its Iterator
Chapter 5 – 9 CSC212 RS April 08, CS Dept, CCNY
Exam 2 Review CS 3358 Data Structures.
Templates. Templates Example: Swap Template Mechanism.
Containers and the Standard Template Library (STL)
Template Functions Chapter 6 introduces templates, which are a C++ feature that easily permits the reuse of existing code for new purposes. This presentation.
Standard Version of Starting Out with C++, 4th Edition
Iterators and STL Containers
Exceptions, Templates, and the Standard Template Library (STL)
Tenth step for Learning C++ Programming
STL (Standard Template Library)
C++ Programming: chapter 10 – STL
For each of these data structures
Chapter 1-4 CSc 212 Data Structures, Sec FG CCNY, 2009
Presentation transcript:

Chapter 5 – 9 CSC212 KL Nov 8, CS Dept, CCNY Exam Review 2 Chapter 5 – 9 CSC212 KL Nov 8, CS Dept, CCNY

Chapter 5: Linked Lists Node Class (Ex 1-4, 6-9) Linked List Toolkit (Ex 10 -16) 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 6.1-6.2, Ex 1-3, 6-11 Iterators (Sec. 6.5- 6.7, Ex 17-28) step through all items of a container in a standard manner Standard Template Library (Section 6.3, Ex. 12-16) 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 <class Item1, class Item2, ...> 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. 6.5- 6.7, 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)