2004 A.M. Turing Award Winners Vinton G. Cerf Robert E. Kahn Citation For pioneering work on internetworking, including the design and implementation of.

Slides:



Advertisements
Similar presentations
Chapter 18 Vectors and Arrays
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 4: Linked Lists Data Abstraction & Problem Solving with.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 16 – Shopping List Application: Introducing.
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.
Introduction to Programming Lecture 39. Copy Constructor.
CS-1030 Dr. Mark L. Hornick 1 Constructors Copy Constructors.
What is a copy constructor? A copy constructor is a special constructor for a class/struct that is used to make a copy of an existing instance during initialization.
Linked List - I. Abstract Data Type (ADT) ADT is a data type whose properties (domain and operations) are specified independently of any particular implementation.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 13: Pass-by-Value?!?
Copy Constructors Shallow Copy: –The data members of one object are copied into the data members of another object without taking any dynamic memory pointed.
Chapter 4 Linked Lists. © 2005 Pearson Addison-Wesley. All rights reserved4-2 Preliminaries Options for implementing an ADT List –Array has a fixed size.
Winners of Turing Award 2004 Presenter: Yung-Hsing Peng Date:
1 Chapter 6 Lists Plus. ADT Sorted List Operations Transformers n MakeEmpty n InsertItem n DeleteItem Observers n IsFull n LengthIs n RetrieveItem Iterators.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
Variations of Linked Lists CS 308 – Data Structures.
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.
Chapter 4 Linked Lists. © 2005 Pearson Addison-Wesley. All rights reserved4-2 Preliminaries Options for implementing an ADT List –Array has a fixed size.
Data Structures Using C++ 2E
1 Nell Dale Chapter 6 Lists Plus Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus C++ Plus Data Structures.
Copy Control Joe Meehean. More Class Responsibilities When making a new type (i.e., class) we must specify what happens when it is: Copied Assigned Destroyed.
2 Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during insertions and deletions Linked list is able to.
Linked List. List Definitions Linear relationship Each element except the first has a unique predecessor, and each element except the last has a unique.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 4: Linked Lists Data Abstraction & Problem Solving with.
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CARRANO CHAPT. 9.
CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor-II.
Copy Constructors Fall 2008 Dr. David A. Gaitros
The Big Three Based on Weiss “Data Structures and algorithm Analysis CS240 Computer Science II.
1 Recall Definition of Stack l Logical (or ADT) level: A stack is an ordered group of homogeneous items (elements), in which the removal and addition of.
Chapter 9 Classes: A Deeper Look, Part I Part II.
A Doubly Linked List prevnextdata There’s the need to access a list in reverse order header dnode.
What happens... l When a function is called that uses pass by value for a class object like our dynamically linked stack? StackType MakeEmpty Pop Push.
Chapter 6 Lists Plus. What is a Class Template? A class template allows the compiler to generate multiple versions of a class type by using type parameters.
THE INTER-NET Rocky K. C. Chang13 Sept Some history may help 2.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 1.
Data Abstraction and Problem Solving with C++ Walls and Mirrors, Third Edition, Frank M. Carrano and Janet J. Prichard ©2002 Addison Wesley CHAPTER 4 Linked.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
1 CS 132 Spring 2008 Chapter 5 Linked Lists p
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
CC 215 DATA STRUCTURES LINKED LISTS Dr. Manal Helal - Fall 2014 Lecture 3 AASTMT Engineering and Technology College 1.
On dynamic memory and classes ● We previously had only discussed dynamic memory in regards to structs and dynamic arrays. ● However, they can be used (to.
Chapter 16: Linked Lists.
C++ Programming:. Program Design Including
Data Structure and Algorithms
Copy Constructor / Destructors Stacks and Queues
Astobj2 Joshua Colp, Senior Software Developer 1 1.
Linked Lists Chapter 6 Section 6.4 – 6.6
C++ Plus Data Structures
Chapter 4 Linked Lists.
C++ Object-Oriented Programming
A Doubly Linked List There’s the need to access a list in reverse order prev next data dnode header 1.
Chapter 4 Linked Lists
Memberwise Assignment / Initialization
This pointer, Dynamic memory allocation, Constructors and Destructor
The Bag and Sequence Classes with Linked Lists
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Pointers and Linked Lists
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Chapter 4 Linked Lists.
Foundational Data Structures
Indirection.
Chapter 4 Linked Lists.
Essential Class Operations
NAME 436.
Classes: A Deeper Look, Part 1
STL List.
Class: Special Topics 2 For classes using memory allocation
The Constructors Lecture 7 Fri, Feb 2, 2007.
Essential Class Operations
STL List.
Presentation transcript:

2004 A.M. Turing Award Winners Vinton G. Cerf Robert E. Kahn Citation For pioneering work on internetworking, including the design and implementation of the Internet's basic communications protocols, TCP/IP, and for inspired leadership in networking. Press Release New York Times Article Biographical Information: Vinton G. CerfVinton G. Cerf, MCI Robert E. KahnRobert E. Kahn, CNRI

Linked List - II

Default Memberwise Assignment Assignment operator (=) –Can assign one object to another of same type –Default: memberwise assignment Each right member assigned individually to left member Passing, returning objects –Default: pass-by-value Copy of object passed, returned Compiler-generated copy constructor –You must provide your own copy constructor when there are member pointer variables And destructor too

Deep Copy (1 of 3) front ABC 0 itemlinkitemlinkitemlinksize 3 slist1 slist2 front XY 0 itemlinkitemlinksize 2 Consider the following two ShoppingList objects What would the result of slist2 = slist1; be if the default copy behavior took place?

Deep Copy (2 of 3) front ABC 0 itemlinkitemlinkitemlinksize 3 slist1 slist2 front XY 0 itemlinkitemlinksize 3 slist2 becomes a “shallow copy” of slist1 slist2 doesn’t get a copy of slist1 data All references to slist2 data are lost!

Deep Copy (3 of 3) front ABC 0 itemlinkitemlinkitemlinksize 3 slist1 slist2 frontsize 3 Here is what slist2 would look like as a “deep copy” of slist1 Note that slist2 has its own set of data ABC 0 itemlinkitemlinkitemlink

Clone Example (1 of 8) ShoppingList::ShoppingList(const ShoppingList &slist) { Node *cur1, *cur2; front ABC 0 itemlinkitemlinkitemlinksize 3 slist *this front XY 0 itemlinkitemlinksize 2 cur1 ? cur2 ?

Clone Example (2 of 8) this->deleteAll(); this->size = slist.size; front ABC 0 itemlinkitemlinkitemlinksize 3 front 0 size 3 cur1 ? cur2 ? slist *this

Clone Example (3 of 8) this->front = new Node(*(slist.front).item); front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1 ? cur2 ? A itemlink 0 slist *this

Clone Example (4 of 8) cur1 = this->front; cur2 = slist.front; front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1cur2 A itemlink 0 slist *this

Clone Example (5 of 8) while (cur2->link) { cur2 = cur2->link; cur1->link = new Node(*cur2); cur1 = cur1->link; } front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1cur2 A itemlink slist *this B itemlink 0 First iteration

Clone Example (6 of 8) while (cur2->link) { cur2 = cur2->link; cur1->link = new Node(*cur2); cur1 = cur1->link; } front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1cur2 A itemlink slist *this B itemlink Second iteration C 0 itemlink

Clone Example (7 of 8) cur1 = cur2 = 0; front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1 0 cur2 0 A itemlink slist *this B itemlink C 0 itemlink

Clone Example (8 of 8) } front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 A itemlink slist *this B itemlink C 0 itemlink

Doubly Linked List Each node has 2 pointers, one to the node before and one to the node after No longer limited to left-to-right pointer movement Typically, a rear pointer is employed to simplify reverse traversals front A datarlinkllink B datarlinkllink C datarlinkllink rear

Circular Linked List “Last” node’s link points at the “front” node Concept of “front” optional cur A datalink B datalink C datalink E datalink D datalink