DataStructures1

DataStructures1 - Regular Data Structures 1, 2, 3, 4, N-D...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Regular Data Structures 1, 2, 3, 4, N-D Arrays 1 © Popescu 2012
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Data Structures Store and organize data on computers Facilitate data processing Fast retrieval of data and of related data Similar to furniture with shelves and drawers Quick access Quick selection Data structure is designed according to data and data processing characteristics A big part of the data processing solution 2
Background image of page 2
Regular data structures: arrays Identical data elements tightly packed Direct access through indexing Index must be within array bounds Structure is implicit Neighbors are found through indexing No need to waste storage space for structure 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Regular data structures: arrays 1-D array A row 4
Background image of page 4
Example: houses on street The houses form a 1-D array House number serves as index You can refer to a house directly using its number An urban modeling SW application could store the houses on a street in a 1-D array 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example: today’s hourly temperatures at given location There are 24 hours 1 temperature reading for every hour 6
Background image of page 6
Example: today’s hourly temperatures at given location There are 24 hours 1 temperature reading for every hour A 1-D array with 24 elements Each element is a number 7 55 54 53 50 49 49 55 60 65 68 70 72 75 77 80 83 85 85 82 79 77 70 60 57
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example: hourly temperatures in West Lafayette on given day There are 24 hours 1 temperature reading for every hour A 1-D array with 24 elements Each element is a number We usually show indices in diagrams, but indices are NOT stored in the array 8 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 55 54 53 50 49 49 55 60 65 68 70 72 75 77 80 83 85 85 82 79 77 70 60 57
Background image of page 8
Example: hourly temperatures in West Lafayette on given day Let’s call the array T , from temperature To find the temperature at 8am Index the 9 th element of the array T[8] (i.e. index 8 in 0-based indexing) Read the value at T[8] to obtain 65 9 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 55 54 53 50 49 49 55 60 65 68 70 72 75 77 80 83 85 85 82 79 77 70 60 57
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example: hourly temperatures in West Lafayette on given day Change the temperature value at 7pm to 80 Assign 80 to T[19] We will denote assignment w/ equal sign T[19] = 80 10 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 55 54 53 50 49 49 55 60 65 68 70 72 75 77 80 83 85 85 82 80 77 70 60 57 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 55 54 53 50 49 49 55 60 65 68 70 72 75 77 80 83 85 85 82 79 77 70 60 57
Background image of page 10
Consider the following paragraph “In the midday breeze, where the willow is swaying, flowers are blooming.” Stored in 1-D array of 72 bytes (1 byte / char) 11 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 I n t h e m i d d a y b r e e z e , w h 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 e r
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 38

DataStructures1 - Regular Data Structures 1, 2, 3, 4, N-D...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online