Vectors

Vectors - Vectors 4/1/2003 9:03 AM Outline and Reading The...

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

View Full Document Right Arrow Icon
4/1/2003 9:03 AM Vectors 1 Vectors 4/1/2003 9:03 AM Vectors 2 Outline and Reading The Vector ADT (§5.1.1) Array-based implementation (§5.1.2) 4/1/2003 9:03 AM Vectors 3 The Vector ADT 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: ± elemAtRank (int r): returns the element at rank r without removing it ± replaceAtRank (int r, Object o): replace the element at rank r with o ± insertAtRank (int r, Object o): insert a new element o to have rank r ± removeAtRank (int r): removes the element at rank r Additional operations size () and isEmpty () 4/1/2003 9:03 AM Vectors 4 Applications of Vectors Direct applications ± Sorted collection of objects (elementary database) Indirect applications ± Auxiliary data structure for algorithms ± Component of other data structures
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.

This note was uploaded on 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 2

Vectors - Vectors 4/1/2003 9:03 AM Outline and Reading 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