CIS
[INSERT TITLE HERE] 2
Running head: [INSERT TITLE HERE]
[INSERT TITLE HERE]
Student Name
Allied American University
Author Note
This paper was prepared for [INSERT COURSE NAME], [INSERT COURSE ASSIGNMENT] taught by [INSERT INSTRUCTOR’S NAME].
Dire ctions: Please answer the following questions.
- Write specifications using UML notation for a function that computes the sum of the first five positive integers in an array of n arbitrary integers.
What is an abstract data type?
- What steps should you take when designing an ADT?
- The following function computes the sum of the first n ≥ 1 integers. Show how this function satisfies the properties of a recursive function.
- Given an integer n > 0, write a recursive function countDown that writes the integers n, n – 1, . . . , 1. Hint: What task can you do and what task can you ask a friend to do for you?
- In the previous definition of writeArrayBackward, why does the base case occur when the value of first exceeds the value of last?
- Write a recursive function that computes and returns the product of the first n ≥ 1 real numbers in an array.
- What happens to the array items when the method add cannot add another entry to it, because it is already full?
- If a client of ArrayBag creates a bag aBag and a vector v containing five items, what happens to those items after the statement v = aBag.toVector() executes?
- What is an advantage and a disadvantage of calling the method getFrequencyOf from contains?
- Why are only a few changes necessary to reuse the code in Listing 3-2? How would you implement the changes using the “find and replace” functionality of a text editor or IDE?
- Why is a LinkedBag object not concerned about becoming full?
- How many assignment operations does the method that you wrote for the previous question require?
- Consider the language of these character strings: $, cc$d, cccc$dd, cccccc$ddd, and so on. Write a recursive grammar for this language.
- Write the prefix expression that represents the following infix expression: (a / b) * c – (d + e) * f