Fundamentals of Computer Science II (CSC-152 97F)

[News] [Basics] [Syllabus] [Outlines] [Assignments] [Examples] [Readings] [Bailey Docs]

# Outline of Class 16: Vectors

## Miscellaneous

• We'll hold most of the questions on assignment 3 until after the discussion of vectors and arrays.
• Yes, you need to turn in the "thought questions"
• Java is clever about array allocation. It doesn't allocate the full array until you reference the later parts of the array.
• There's still room for this Sunday's dinner. You'll even get a chance to meet my wife.
• We'll spend a few minutes on yesterday's square examples.
• What happens if you type an illegal entry (e.g., "alpha")?
• What happens if you end the input (with control-D)?

## Data Structures, Revisited

• In case you've forgotten, the primary intent of this course is to visit data structures and the algorithms used with data structures.
• As the name suggests, a data structure is a way of structuring data.
• In practice, we care about
• The interface to the data structure -- what methods it provides.
• The implementation of the data structure -- how it provides that those methods (and organizes the data).
• The efficiency of those methods, which is governed by how we represent the data and what algorithms we use.
• As we visit each data structure this term, we will begin by considering the interface, advance to implementation issues, and consider efficiency as we discuss the implementation.

## Vectors and Arrays

• One of the simplest data types is the vector, which many may refer to as an array.
• Bailey's vector is but one version of what a vector can be; it is designed to match the built-in Java vector.
• The primary intent of vectors and arrays is that you have a collection of objects of similar (the same) type that you can reference by number (using numbers in some reasonable range).
• What questions might you ask in changing that vague definition to a more concrete list of functions?
• What constructors should we support?
• Create new vectors?
• Create new vectors of specified size?
• Create new vectors of specified size with the same element in each position?
• Do we differentiate between the number of elements in a vector, the number of valid indices, and the number of elements the vector can hold?
• Can we change an assigned element?
• What happens if we can delete elements from the vector?
• Do the remaining elements change position?
• Do we simply get a hole in the vector?
• Do we get a default value at that position?
• ...
• Do we have a default/required lower-end of the range of indices?
• What happens if an illegal request is made?
• And what are the illegal requests?

Outlines: prev next

[News] [Basics] [Syllabus] [Outlines] [Assignments] [Examples] [Readings] [Bailey Docs]

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.