MAT 21B Lecture 15: Lecture 15

26 views2 pages
School
Department
Course
Professor
Lecture 15
See code line on powerpoint
Pointer and iteration
- Use of a pointer variable for iterating through an array
o Access current element through dereferencing
o Increment pointer to move to next element
- Incrementing a pointer adds the seize of the pointed data
Array Size
- Sizeof ( ) returns the overall size of an array
- Dividing the array size by the size of an element, gives the numer of element
Passing arrays of arguments
- Arrays always decay into simple pointers when passed as arguments
- GCC warns when using sizeof( ) on a decayed array
- Functions always modify original array … not copies
- Cannot return a local array from a function
o All local variables disappear when a function returns
Searching
- Determine the location of a particular value in an array
Sorting
- Inefficient version of election sort
- Vary basic sorting algorithm
o Find smallest number of each position in the array successively
o Compare with all remaining number successively
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in
beigecamel74 and 41 others unlocked
MAT 21B Full Course Notes
83
MAT 21B Full Course Notes
Verified Note
83 documents

Document Summary

Use of a pointer variable for iterating through an array: access current element through dereferencing, increment pointer to move to next element. Incrementing a pointer adds the seize of the pointed data. Sizeof ( ) returns the overall size of an array. Dividing the array size by the size of an element, gives the numer of element. Arrays always decay into simple pointers when passed as arguments. Gcc warns when using sizeof( ) on a decayed array. Functions always modify original array not copies. Cannot return a local array from a function: all local variables disappear when a function returns. Determine the location of a particular value in an array. Vary basic sorting algorithm: find smallest number of each position in the array successively, compare with all remaining number successively. Arrays with two or more dimension: tables, matrices, charts etc.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents