DataStructures2Notes - 1 As mentioned at the end of the...

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

View Full Document Right Arrow Icon
1
Background image of page 1

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

View Full DocumentRight Arrow Icon
As mentioned at the end of the “regular data structures” lecture, arrays are not always suitable for a data processing application. As we saw, changes that imply changes to the array size are costly. Moreover, not all data that has to be processed is uniform in size and structure. For example, 1-D arrays allow an element to have two immediate neighbors, elements in 2-D arrays have 8 immediate neighbors and so on, which cannot accommodate scenarios where data elements have a varying number of neighbors. 2
Background image of page 2
To overcome these disadvantages, some data processing applications use irregular data structures. Of course, abandoning the regular structure of arrays comes at a cost: - irregular data structures are more complex to design, implement, use, maintain, - they are less efficient since some of the memory bytes go towards defining and storing structure, whereas in the case of arrays all bytes go towards the payload, - and it is also the case that one does not have direct access to all data, like in the case of arrays. 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
on 1-D arrays. Like 1-D arrays, a linked list is a 1-D sequence of elements. It is not an array, since the elements are not stored in a contiguous piece of memory, and therefore one cannot access the elements through indexing. There are explicit links between elements. A link is a memory address. A link says: “the data of interest is at address X”. The actual address X is chosen by the operating system during run time, and it is not important when designing the data structure or when writing the program. What is important is the semantic, the meaning: a pointer to a piece of memory where data “worth pointing to” is stored. In the case of the linked list, the link of one element points to where the next element is stored. The elements of the list are called “nodes”, since a node stores the data element and the link. Whereas in the case of the array indices were implicit, and were not stored, in the case of linked lists the links are explicit, they are actually stored in the data structure. In the example, the element might be stored as a floating point number on 32 bits, and the link, which is a memory address, could be stored using 32 bits as well. Consequently, there is a 100% overhead: the amount of memory used to store the
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/27/2012 for the course CS 177 taught by Professor Staff during the Spring '08 term at Purdue University-West Lafayette.

Page1 / 55

DataStructures2Notes - 1 As mentioned at the end of the...

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

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