Welcome to CISC220 Data Structures in C++ sakai.udel.edu Office Hours: Mon / Wed 2:30PM - 4PM TAs: Miao Tang, Zequn (Richard) Huang
Who am I?
Who are you?
What will we learn? Pointers Lists Analysis/ Big O notation Stacks Queues Recursion Trees Sorting Heaps Graphs NP-completeness Hashing
How will we learn? Class exercises + Lab participation (5%) Homework problems/programming (10*3- 5% = 35%) Two programming projects (20%) Three tests (two midterm * 10%, final 20%)
What is a Data Structure?
Objectives for Today Manipulate pointers –read/write –create –dereference –assign value Reading - K+W P.1-P.6
Review of pointers & memory cf. K&W, Chapter P A C++ Primer section P.5
Smith Hall Newark, DE USA
How could we move the Department of Computer and Information Sciences?
Memory Address vs. Value Stored Consider memory to be a single huge array: –Each cell of the array has an address associated with it. –Each cell also stores some value. Don’t confuse the address referring to a memory location with the value stored in that location
Pointers An address refers to a particular memory location. In other words, it points to a memory location. Pointer: A variable that contains the address of a variable. z x y Location (address) name 104
Pointers How to initialize a pointer: – can initialize to NULL (i.e. not currently pointing to anything) – & operator: get address of a variable int *x; x?y? int y = 3; x?y3 x = &y; xy3
Pointers How to get the value that is pointed to? – * “ dereference operator”: get value pointed to * x returns 3 How to change the variable pointed to? – Use dereference * operator to left of = xy5 *x = 5 ; xy3