DS02_Ch03a - 3 Lists Stacks and Queues CHAPTER 1 Abstract...

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

View Full Document Right Arrow Icon
CHAPTER 3 Lists, Stacks, and Queues §1 Abstract Data Type (ADT) Definition Data Type = { Objects } { Operations } 【 Example 【 int = { 0, ± 1, ± 2, , INT_MAX, INT_MIN } { + , - , × , ÷ , % , } Definition An Abstract Data Type (ADT) is a data type that is organized in such a way that the specification on the objects and specification of the operations on the objects are separated from the representation of the objects and the implementation on the operations. 1/14
Background image of page 1

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

View Full DocumentRight Arrow Icon
§2 The List ADT Objects : ( item 0 , item 1 , ⋅ ⋅ ⋅ , item N - 1 ) Operations : Finding the length , N , of a list. Printing all the items in a list. Making an empty list. Finding the k- th item from a list, 0 k < N . Inserting a new item after the k -th item of a list, 0 k < N . Deleting an item from a list. Finding next of the current item from a list. Finding previous of the current item from a list. ADT: Why after? 2/14
Background image of page 2
1. Simple Array implementation of Lists §2 The List ADT array[ i ] = item i MaxSize has to be estimated. Address Content array+ i item i array+ i +1 item i +1 …… …… …… …… Sequential mapping Find_Kth takes O(1) time. Insertion and Deletion not only take O( N ) time, but also involve a lot of data movements which takes time. 3/14
Background image of page 3

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

View Full DocumentRight Arrow Icon
§2 The List ADT 2. Linked Lists Address Data Pointer 0010 0011 0110 1011 SUN QIAN ZHAO LI 1011 0010 0011 NULL Head pointer ptr = 0110 ZHAO QIAN SUN LI ptr NULL Initialization: typedef struct list_node *list_ptr; typedef struct list_node { char data [ 4 ] ; list_ptr next ; } ; list_ptr ptr ;
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 10/20/2011 for the course COMPUTER S 10586 taught by Professor Jilinwang during the Spring '09 term at Zhejiang University.

Page1 / 14

DS02_Ch03a - 3 Lists Stacks and Queues CHAPTER 1 Abstract...

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