{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

DataStructures1

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

Info icon This preview shows pages 1–13. 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right Arrow Icon
Regular data structures: arrays 1-D array A row 4
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
Image of page 5

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

View Full Document Right Arrow Icon
Example: today’s hourly temperatures at given location There are 24 hours 1 temperature reading for every hour 6
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
Image of page 7

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

View Full Document Right 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
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
Image of page 9

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

View Full Document Right 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
Image of page 10
Example: text in a paragraph 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 e t h e w i l l o w i s s w a y i n 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 g , f l o w e r s a r e b l o o m i n g .
Image of page 11

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

View Full Document Right Arrow Icon
Regular data structures: arrays 1-D array A row 2-D array Rows and columns, rows of rows 12
Image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern