Skip to main content

Section 5.7 Summary and Reading Questions

  1. A statically allocated C++ array is an ordered collection of one or more C++ data values of identical type stored in contiguous memory.
  2. A vector is a dynamically allocated array with many useful methods. It is more similar to the Python list than the array.
  3. C++ strings are a sequential collection of zero or more characters. They are very similar to Python strings.
  4. A hash table is used to store keys-value pairs. It applies a related hash function to the key in order to compute the location of the associated value. Look-up is typically very fast.
  5. A set is an unordered collection of unique values.

Reading Questions Reading Questions

1.

Which C++ structure is the best choice for a group of ordered data of a fixed length?
  • array
  • Correct!
  • hash table
  • No. hash tables are not ordered.
  • string
  • A string would only work for character data. Try again.
  • vector
  • There is a better choice given that the group is fixed length.
  • more than one of the above
  • Only of the above is best.

2.

3.

4.

You have attempted 1 of 5 activities on this page.