# TAMU CSCE 221 - Arrays, Vectors, Pointers (40 pages)

Previewing pages 1, 2, 3, 19, 20, 38, 39, 40 of 40 page document
View Full Document

# Arrays, Vectors, Pointers

Previewing pages 1, 2, 3, 19, 20, 38, 39, 40 of actual document.

View Full Document
View Full Document

## Arrays, Vectors, Pointers

6 views

Pages:
40
School:
Texas A&M University
Course:
Csce 221 - Data Struc & Algorithm

Unformatted text preview:

Sequences Outline Storing Objects in Computer Memory Pointers and One Dimensional Arrays STL Class Vector Two Dimensional Arrays STL Class Matrix Linked Lists STL Class List Sequences Teresa Leyk CSCE 221 Data Structures Algorithms Sequences Fall 2013 1 40 Storing Objects in Computer Memory A computer s memory is a sequence of numbered bytes from 0 to the last one A byte number is an address of an object in the computer memory int main int val 0 char ch A string name All val 0 0 1 Teresa Leyk CSCE 221 ch name A All 231 2 Data Structures Algorithms Sequences 231 1 Fall 2013 2 40 Pointers A pointer is a memory address of an object of a specified type or it is a variable which keeps such an address P pointer 12316 12316 address Typed object Pointer properties A pointer value is the address of the first byte of the pointed object in the memory A pointer does not know about how many bytes it points to Teresa Leyk CSCE 221 Data Structures Algorithms Sequences Fall 2013 3 40 Pointers cont Pointers are used to create more complex data types such as lists queues stacks trees or graphs process arrays keep track of allocated memory returned by the operator new initialize to nothing no address denoted by NULL 0 or nullptr in C 11 deallocate a block of memory by the operator delete or delete Teresa Leyk CSCE 221 Data Structures Algorithms Sequences Fall 2013 4 40 Arrays An array of the fix size represents a contiguous sequence of objects of the same type allocated on the stack computer memory It is a very simple data structure often used in sorting and searching operations The position of an element in the array is called the index In C arrays always begin with the index 0 0 1 2 3 4 5 12 3 24 65 92 11 indices array values To declare a static one dimensional array with fixed size at compile time in the stack part of computer memory constexpr max size 6 int array max size 12 3 24 65 92 11 where max size is a constant expression a compile time constant known during compilation

View Full Document

## Access the best Study Guides, Lecture Notes and Practice Exams

Unlocking...

Join to view Arrays, Vectors, Pointers and access 3M+ class-specific study document.

or