lec05 - 05-1/45 Implementations of List ADT Properties of...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 05-1/45 Implementations of List ADT Properties of array and linked implementations Separate and inner node classes Singly and doubly linked lists Evaluating and selecting a data structure CSE 12 Fundamental Data Structures: The Array and Linked Structures 05-2/45 Introduction Any interface can be correctly implemented in many ways However, different correct implementations may have different performance characteristics It is important to know these characteristics, as they affect the performance of the resulting software 05-3/45 Collection ADT's An ADT specifies a range of values that instances of the type can have, and operations on those values A collection ADT can use various data structures to implement its values A particular choice for a data structure is sometimes called the backing store For the List ADT, the backing store is typically chosen to be either an array, or a linked list 05-4/45 Static vs. Dynamic arrays Static array fixed size of array is determined at compile time a variable name is permanently bound to the array FORTRAN has static arrays Dynamic array size of array can be determined at run time variable name may be bound to different arrays at different times Java supports dynamic arrays 05-5/45 Array Characteristics An array is a homogeneous data structure: all elements must be of the same type The elements of an array are in adjacent memory locations Because each cell has the same size, and the cells are adjacent in memory, it is possible to quickly calculate the address of any array cell, if the address of the first cell is known so accessing any array cell costs just a multiplication, an addition, and a memory access an array is a random (direct) access structure 05-6/45 Linked Structure Characteristics Nodes in a linked structure are allocated dynamically, so the number of nodes in the linked structure can grow and shrink as needed The nodes of a linked structure are created at different times, and are probably not adjacent in memory Even if the address of the first node in a linked structure is known, it is impossible to calculate the address of another node; instead each node stores the location of the next node in the structure so a node access requires visiting all previous nodes in the structure in sequence a linked structure is a sequential access structure 05-7/45 Array Versus Linked Structures 05-8/45 Array Operations Searching O( n ) if array is unsorted, O(log n ) if sorted Resizing can make a new array that is smaller or larger than the original array: ( size of new array) Replacing an element O(1) Inserting an element O( n ), due to data movement Deleting an element O(1) or O( n ) depending on implementation Traversing bidirectional 05-9/45 Linked List Operations Searching O( n ) Resizing not needed Replacing an element...
View Full Document

This note was uploaded on 06/15/2011 for the course ECON 1 taught by Professor Aben during the Fall '07 term at City College of San Francisco.

Page1 / 45

lec05 - 05-1/45 Implementations of List ADT Properties of...

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

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