Download presentation
Presentation is loading. Please wait.
Published byPercival Walker Modified over 9 years ago
1
CH 6 : VECTORS, LISTS AND SEQUENCES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM NANCY M. AMATO 1
2
VECTORS (CH 6.1) The Vector ADT (Ch. 6.1.1) Array-based implementation (Ch. 6.1.2) 2
3
VECTOR ADT (CH 6.1.1) The Vector ADT extends the notion of array by storing a sequence of arbitrary objects An element can be accessed, inserted or removed by specifying its rank (number of elements preceding it) An exception is thrown if an incorrect rank is specified (e.g., a negative rank) 3
4
APPLICATIONS OF VECTOR Direct applications Sorted collection of objects (elementary database) Indirect applications Auxiliary data structure for algorithms Component of other data structures 4
5
ARRAY-BASED VECTOR (CH 6.1.2) STORAGE 012n i 0 5
6
ARRAY-BASED VECTOR (CH 6.1.2) INSERTION 6 V 012n i V 012n i V 012n e i
7
ARRAY-BASED VECTOR (CH 6.1.2) DELETION 7 V 012n r V 012n e i V 012n i
8
PERFORMANCE Array based Vector at(i), set(i,e) insert(i,e) Best Case Worst Case Average Case erase(i) Best Case Worst Case Average Case size(), empty() 8 Array based Vector at(i), set(i,e) insert(i,e) erase(i) size(), empty()
9
EXERCISE 9
10
VECTOR SUMMARY Array based Vector( Fixed or Growable) List Singly or Doubly Linked insert(i,e) and erase(i) at(i) and set(i,e) size() and empty() 10
11
ITERATORS AND POSITION (CH 6.2.1) 11
12
LISTS AND SEQUENCES List ADT (Ch. 6.2.2) Doubly linked list (Ch. 6.2.3) Sequence ADT (Ch. 6.3.1) Implementations of the sequence ADT (Ch. 6.3.2-3) 12
13
LIST ADT (CH 6.2.2) 13
14
INSERT(P,E) 14 ABXC ABC p ABC p X q pq
15
ERASE(P) 15 ABCD p ABC D p ABC
16
PERFORMANCE 16
17
LIST SUMMARY Singly-linked ListDoubly-linked List Worst case Average case Best case 17 Singly-linked ListDoubly-linked List
18
SEQUENCE ADT (CH 6.3.1) 18
19
APPLICATION OF SEQUENCES The Sequence ADT is a basic, general-purpose, data structure for storing an ordered collection of elements Direct applications: Generic replacement for stack, queue, vector, or list Small database (e.g., address book) Indirect applications: Building block of more complex data structures 19
20
ARRAY BASED IMPLEMENTATION OF SEQUENCE (CH 6.3.3) 20 0123 positions elements S lf
21
SEQUENCE SUMMARY Circular Array based SequenceDoubly-linked List based Sequence 21 Circular Array based SequenceDoubly-linked List based Sequence
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.