ECS 30 Lecture Notes - Lecture 13: Array Data Structure, Data Structure

47 views2 pages
Lecture 13
Arrays
The case for arrays
Draw backs
- Approach is not scalable
- Doesn’t quiet capture the nature of grades
As algorithms become more complex
- Break down in smaller steps
- Functions can be refined even further
- Hierarchy of function
Source: https://www.tutorialspoint.com/cprogramming/c_arrays.htm
Data types also form a hierarchy
- Use simple data types to define more complex ones
- As many levels as necessary to represent what the program requires
- Combine independent data value into a single unified collection
- Reduce conceptual complexity
Algorithms +Data structure = Programs
Array definition
- An array groups distinct variable of the same type under a single name
o Definition of array grade
Four distinct elements
Each type int
o Access to each element through a subscript
Index is an integer value
First element at index 0
Last element at index one less than the number of element
- Visual representation
o In memory, array elements are:
Contiguously allocated
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

Document Summary

Doesn"t quiet capture the nature of grades. Use simple data types to define more complex ones. As many levels as necessary to represent what the program requires. Combine independent data value into a single unified collection. An array groups distinct variable of the same type under a single name: definition of array grade, four distinct elements, each type int, access to each element through a subscript. Index is an integer value: first element at index 0, last element at index one less than the number of element. Visual representation: in memory, array elements are, contiguously allocated. Compilation and execution: uninitialized global array. Initial values are set to 0: uninitialized local array, triggers a warning by compiler. Initial values are random: manual initialization, element by element, order does not matter, array element must always be inialized. Example code: double balance[5] = {1000. 0, 2. 0, 3. 4, 7. 0, 50. 0};

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents