Solutions for those exercises.

Questions

  1. Put a checkmark in the box corresponding to true statements.

    • Abstract data types have exactly one implementation.
    • Data structures are generally useful to store and retrieve data.
    • A data type generally comes with allowed operations.
    • In data structures classes, ergonomics is the main metrics to compare programs.
    • In data structures classes, hardware is generally ignored.
  2. Rank the following from 1 (“best”, fast to execute, slow to grow) to 5 (“worst”, fast to grow, slow to execute):

    • cubic
    • linear
    • linearithmic
    • logarithmic
    • exponential
  3. Complete the following sentences:

    • A quadratic order of magnitude is denoted ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟.
    • A ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ order of magnitude is denoted .
    • A factorial order of magnitude is denoted ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟.

Problems

  1. Write a code snippet (no need to include using statements or Main header) that displays the sum of all the values in a score int array that you can suppose declared and initialized. What is the worst case time complexity of the algorithm you wrote, relative to the size of the array score?