Understanding Array Indexing and Representation

Slide Note
Embed
Share

Visual guide explaining how arrays are indexed and stored in memory, including defining upper and lower bounds, determining array length, and denoting array elements. Example illustrations provided for easy comprehension of array concepts.


Uploaded on Sep 23, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. ELSE

  2. Set PTR: = LINK [PTR] [PTR now point to the next node]

  3. [End of li fl structure]

  4. [End of step 2 loop]

  5. [Search is unsuccessful]

  6. The elements of the array are reference representation by an index set consisting of n-consecutive numbers.

  7. The element of the array is stored respectively in successive memory location. Number n of element is called the length or size of the array.

  8. In general, the length or the numbers of the data element can be obtained by the index set of the formular:

  9. Length = UB LB+1 or length = UB LB+1

  10. UB = larger index called Upper Bound

  11. LB = smallest index called Lower Bound of the Array.

  12. NB: length = UB when LB=1

  13. The element of an array can be denoted by A1, A2, - - - - - -An

  14. Example:

  15. Let data is a six element linear array of integer such that:

  16. DATA [1] = 247 DATA [2] = 56 DATA [3] =429

  17. DATA [4] = 135 DATA [5] = 87 DATA [6] =156

  18. DATA 247, 56, 429, 135, 87

  19. This type of array data can be pictured in the form:

  20. DATA

  21. 1 247 2 87 6 56 3 156 429 4 135 5 DATA

  22. 247 56 429 135 87 156 OR

  23. Example 2:

  24. An automobile company uses an array AUTO to record the number of automobile sold each year from 1932- 1984

  25. Solution:

  26. AUTO [K] = number of automobile sold in the years.

  27. Lower Bound = LB = 1932

  28. Upper Bound = UB = 1984

  29. Length = UB LB+1

  30. = 1984 -1932+1

  31. Length = 53

  32. REPRESENTATION OF LINEAR ARRAY IN THE MEMORY

  33. Let LA be a linear array in the memory of a computer. Recall that the memory of computer is simply a sequence of address location as in figure below;

  34. 1000

  35. 1001

  36. 1002

Related


More Related Content