# ch3 - Ch 3. The Data Structures: Lists 3.1 Introduction:...

This preview shows pages 1–7. Sign up to view the full content.

2001-2009 M. D. Evans All Rights Reserved 1 Ch 3. The Data Structures: Lists 3.1 Introduction : Problem : I/T at most 100 integers and O/T them in reverse. Soln: list 1-Dim array. Note: list vs 1-Dim array (part of ) DS one implementation for each DS we consider: 1. Its def/structure and generic opns. 2. Implementation of structure and opns. To Be Studied: 1. general lists - single - double - circular 2. queues and deques 3. stacks 4. trees 5. graphs (if time)

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

View Full Document
2001-2009 M. D. Evans All Rights Reserved 2 3.2 General Lists: Def : List of elements of type T = a sequence of elements of T together with opns: - initialize to empty - test empty - test full - determine length - retrieve elements (if not empty) - replace any element (if not empty) - insert new element anywhere (if not full) - delete existing element (if not empty) - traverse entire list - move to the next element General attributes of list: - size - collection of elements in list - current position - head - tail (?)
2001-2009 M. D. Evans All Rights Reserved 3 Note: sequence may be: a) Contiguous – all nodes ADJACENT in memory. or b) Linked – all nodes NOT NECESSARILY ADJACENT in mem.

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

View Full Document
2001-2009 M. D. Evans All Rights Reserved 4 3.3 Operations on lists implemented contiguously: Approaches to viewing the list in the array: 1. elements contiguous boy dog mouse zebra 2. elements sparse boy null dog mouse null null zebra Comparisons: which to use?? CONTIGUOUS SPARSE INSERTION DELETION HEAD, TAIL NEXT ITEM Use that suited best to application!
2001-2009 M. D. Evans All Rights Reserved 5 The list: Public: //regardless of the list’s implementation: Proc delete (item from list)

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

View Full Document
2001-2009 M. D. Evans
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/13/2010 for the course CMPT 225 taught by Professor Annelavergne during the Spring '07 term at Simon Fraser.

### Page1 / 21

ch3 - Ch 3. The Data Structures: Lists 3.1 Introduction:...

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

View Full Document
Ask a homework question - tutors are online