Answer the following statements true (T) or false (F)

1. Each activation frame contains all the function’s code, as well as the automatic variables and formal parameters.
2. The activation frames in nested function calls are handled in a last-in/ first-out order.
3. A binary search works with any array of numbers.
4. For the binary search in the text to work, the element searched for must actually be present in the array.

1. False
There is only one copy of the function’s code. The activation record contains the local variables and parameters created at each invocation of the function.But you can think of the activation frame as containing the functions code. The text does say only one copy but the discussion is almost as if there is a copy on each activation frame as a useful fiction.
2. True
Suppose function A calls function B, calls function C. The A’s activation record is placed on top of the A’s caller’s activation record. B’s activation record is placed on top of A’s and C’s is placed on top of A’s. When A returns, its activation record is removed from the stack, and when B returns, its activation record is removed, and so on. All this in last-in-first-out order.
3. False
One of the preconditions for the binary search in the text is that the array be sorted in increasing order.
4. False
The routine in the text sets the bool reference variable to false if the key is not found.

Computer Science & Information Technology

You might also like to view...

Each table column in Excel must have a unique name

Indicate whether the statement is true or false

Computer Science & Information Technology

In which cloud computing category would a company deliver cloud services to their own employees using Hyper-V?

A. Public cloud B. DaaS C. Private cloud D. IaaS

Computer Science & Information Technology