DS&A

Data Structures and Algorithms

Exercises: Using Collections

Feb 122018

Before attempting these exercises, you should read the posts about abstract data types, arrays and stacks and queues.

Exercises

  1. In each of the following scenarios, choose appropriate collection types to represent the required data, and explain your choice:
    1. A 16-digit payment card number is validated by an arithmetic formula which uses the individual digits.
    2. A web browser records the sequence of URLs visited by a user during a browsing session.
    3. An image editor records the edits made by the user, so that an ‘undo’ button can be supported.
    4. A currency exchange matches a buyer with whichever seller offers the best exchange rate.
  2. In each of the following scenarios, choose appropriate combinations of collection types to represent the required data, and explain your choice:
    1. An order form allows a customer to enter their postcode, and then choose their delivery address from a drop-down menu of options.
    2. A program simulates Conway’s game of life.
    3. A university records system allows module marks to be queried, given a student ID number and a module code.
  3. For each of your answers to questions 1. and 2., write down which of the collection types’ operations would be needed to implement the required behaviour.

There are no published comments.

New comment

Your comment will not appear until a moderator approves it.

Atom

hosted on werp.site