Reviews for Exam 1 Chapter 1-4 CSc 212 Data Structures, Sec FG CCNY, Fall 2010.

Slides:



Advertisements
Similar presentations
Container Classes A container class is a data type that is capable of holding a collection of items. In C++, container classes can be implemented as.
Advertisements

Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
1 CSC211 Data Structures Lectures 4 & 5 Container Classes Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
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.
Xiaoyan Li, CSC211 Data Structures Lectures 6/7 Pointers and Dynamic Arrays Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke.
@ Zhigang Zhu, CSC212 Data Structure - Section RS Lectures 6/7 Pointers and Dynamic Arrays Instructor: Zhigang Zhu Department of Computer Science.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 8 Dynamic Classes and the Law of the Big Three Instructor: Zhigang Zhu Department.
1 CSC212 Data Structure - Section FG Lectures 4 & 5 Container Classes Instructor: Zhigang Zhu Department of Computer Science City College of New York.
Chapter 14: Overloading and Templates C++ Programming: Program Design Including Data Structures, Fifth Edition.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
Reviews for Exam 1 Chapter 1-4 CS 211 Data Structures MHC, 2007.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 10 The Bag and Sequence Classes with Linked Lists Instructor: Zhigang Zhu Department.
Object Oriented Programming.  OOP Basic Principles  C++ Classes  September 2004  John Edgar 22.
Pointers1 Pointers & Dynamic Arrays Allocating memory at run-time.
Chapter 15: Operator Overloading
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
CSIS 123A Lecture 12 Templates. Introduction  C++ templates  Allow very ‘general’ definitions for functions and classes  Type names are ‘parameters’
Review for Midterm Chapter 1-9 CSc 212 Data Structures.
Pointer Data Type and Pointer Variables
Data Structures Using C++ 2E Chapter 3 Pointers and Array-Based Lists.
 200 Total Points ◦ 74 Points Writing Programs ◦ 60 Points Tracing Algorithms and determining results ◦ 36 Points Short Answer ◦ 30 Points Multiple Choice.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
Xiaoyan Li, CSC211 Data Structures Lecture 10 The Bag and Sequence Classes with Linked Lists Instructor: Prof. Xiaoyan Li Department of Computer.
SEN 909 OO Programming in C++ Final Exam Multiple choice, True/False and some minimal programming will be required.
Pointers Pointer a data type stores a memory address points to whatever the memory location contains A pointer is a variable that can store a memory address.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 26: Exam 2 Preview.
Edgardo Molina, CSC212 Data Structure - Section AB Lectures 6/7 Pointers and Dynamic Arrays Instructor: Edgardo Molina Department of Computer Science.
C++ Memory Overview 4 major memory segments Key differences from Java
Exam 1 Review CS Total Points – 60 Points Writing Programs – 20 Points Tracing Algorithms, determining results, and drawing pictures – 40 Points.
More C++ Features True object initialisation
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Stacks.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
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.
Edgardo Molina, CSC212 Data Structure - Section AB Lecture 8 Dynamic Classes and the Law of the Big Three Instructor: Edgardo Molina Department.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
 200 Total Points ◦ 75 Points Writing Programs ◦ 60 Points Tracing Algorithms and determining results ◦ 35 Points Short Answer ◦ 30 Points Multiple Choice.
Container Classes  A container class is a data type that is capable of holding a collection of items.  In C++, container classes can be implemented as.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
1 CSC212 Data Structure Lecture 4 Container Classes Instructor: George Wolberg Department of Computer Science City College of New York.
Classes, Arrays & Pointers. Compiler & Linker expectations file1.cppfile2.cppfilen.cpp …. file1.ofile2.ofilen.o …. Linker application (executable) Compiler.
Exam Review 2 Chapter 5 – 9 CSC212 FG CS Dept, CCNY.
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 15-1 Pointers, Dynamic Data, and Reference Types Dale/Weems.
Final Exam Review CS Total Points – 20 Points Writing Programs – 65 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Container Classes. How do we do better? Tough to delete correctly: startLocation.
@ George Wolberg, CSC212 Data Structure Lecture 6 Dynamic Classes and the Law of the Big Three Instructor: George Wolberg Department of Computer.
Final Exam Review CS 3358.
Chapter 1-4 CSc 212 Data Structures, Sec AB CCNY, Spring 2012
The Bag and Sequence Classes with Linked Lists
Lecture 9 Concepts of Programming Languages
Array Lists Chapter 6 Section 6.1 to 6.3
CS 2308 Final Exam Review.
Basic C++ What’s a declaration? What’s a definition?
Exam 1 Review CS 3358.
Introduction to Data Structures
Foundational Data Structures
Exam 1 Review CS 3358.
CSC212 Data Structure - Section FG
Indirection.
Data Structures and Algorithms for Information Processing
CSC212 Data Structure - Section RS
EE 312 Final Exam Review.
Dynamic allocation (continued)
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Chapter 1-4 CSc 212 Data Structures, Sec FG CCNY, 2009
Lecture 9 Concepts of Programming Languages
Lecture 4 – Data collection List ADT
Presentation transcript:

Reviews for Exam 1 Chapter 1-4 CSc 212 Data Structures, Sec FG CCNY, Fall 2010

Chapter 1 (Lecture 1) Course Objectives – WHAT (Topics – ADTs, classes) – WHY (Importance – not only for credits) – WHERE (Goals – data structure experts) – HOW (Lectures, Self-Test Exercises, Assignments, Quizzes and Exams) The Phase of Software Development – Basic design strategy four steps- S, D, I, T – Pre-conditions and post-conditions assert – Running time analysis big-O notation Self-Test Exercises: 3-6, 11-15, 17-20

Chapter 2 A Review of C++ Classes (Lecture 2) OOP, ADTs and Classes Class Definition, Implementation and Use Constructors and Value Semantics More on Classes (Lecture 3) Namespace and Documentation –three ways to use namespace; pre- /post-conditions Classes and Parameters –value, reference, const reference Operator Overloading –nonmember, member and friend function Self-Test Exercises: 1, 4,513,15,17,21,23, 25,28,31

A container class is a class that can hold a collection of items. Container classes can be implemented with a C++ class. The class is implemented with –a header file (containing documentation and the class definition) bag1.h andbag1.h –an implementation file (containing the implementations of the member functions) bag1.cxx.bag1.cxx Other details are given in Section 3.1, which you should read, especially the real bag codebag code Chapter 3

Time Analysis of the Bag Class count – the number of occurrence erase_one – remove one from the bag erase – remove all += - append b1+b2 - union insert – add one item size – number of items in the bag

The Invariant of a Class Two rules for our bag implementation – The number of items in the bag is stored in the member variable used ; – For an empty bag, we don’t care what is stored in any of data ; for a non-empty bag, the items are stored in data [0] through data [ used -1], and we don’t care what are stored in the rest of data. The rules that dictate how the member variables of a (bag) class are used to represent a value (such as a bag of items) are called the invariant of the class

What’s the most important, then? Concept of Container Classes – the bag class is not particularly important Other kinds of container classes –Other types of bags using typedef – sequence – similar to a bag, both contain a bunch of items. But unlike a bag, the items in a sequence is arranged in order.(assignment 2) Self-Test Exercises: 1,3, 5,10,11,14,18-24

Chapter 4 Pointers –*(asterisk) and &(ampersand) operators Dynamic Variables and new Operator – Dynamic Arrays and Dynamic Objects – Stack (local) vs. heap (dynamic) memory Garbage Collection and delete Operator Parameters revisited –Pointers and Arrays as Parameters

Why Dynamic Classes Limitation of our bag class – bag::CAPACITY constant determines the capacity of every bag – wasteful and hard to reuse Solution: – provide control over size in running time, by – pointers and dynamic memory – => dynamic arrays –=> dynamic classes

Dynamic Classes (Ch 4.3–4) Pointers Member Variables Dynamic Memory Allocation –where and how Value Semantics (with dynamic memory) – assignment operator overloading – your own copy constructor Destructor the Law of the Big Three Self-Test Exercises:1-4, ,

Time Analysis of the Bag Class count – the number of occurrence erase_one – remove one from the bag erase – remove all += - append b1+b2 - union insert – add one item size – number of items in the bag

Exam 1 Wednesday, October, 06, 4:00 – 5:40 am Two parts (100 minutes, 30 questions) –Short Answers (10), e.g. What is an automatic default constructor, and what does it do? –Multiple Choices (20), e.g. Suppose that the foo class does not have an overloaded assignment operator. What happens when an assignment a=b; is given for two foo objects? A. The automatic assignment operator is used B. The copy constructor is used C. Compiler error D. Run-time error