Vectors - The Vector ADT (5.1) Vectors and Array Lists The...

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

View Full Document Right Arrow Icon
Vectors 1 © 2004 Goodrich, Tamassia Vectors and Array Lists Vectors 2 © 2004 Goodrich, Tamassia The Vector ADT (§5.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) Main vector operations: ± object elemAtRank (integer r): returns the element at rank r without removing it ± object replaceAtRank (integer r, object o): replace the element at rank with o and return the old element ± insertAtRank (integer r, object o): insert a new element o to have rank r ± object removeAtRank (integer r): removes and returns the element at rank r Additional operations size () and isEmpty () Vectors 3 © 2004 Goodrich, Tamassia Applications of Vectors Direct applications ± Sorted collection of objects (elementary database) Indirect applications ± Auxiliary data structure for algorithms
Background image of page 1

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

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

Page1 / 3

Vectors - The Vector ADT (5.1) Vectors and Array Lists The...

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

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