Chapter 6 Outcomes
Functions
Knowledge Outcomes
Define each of the key terms listed in the chart below.
| predefined function | user defined function | mathematical function |
| signature | result | recursion |
| iterative function | recursive function | base case |
| call trace | call tree | palindrome |
| side effects | global variables | var parameters |
Describe the difference between a function and a procedure (6.1).
Differentiate a function from a procedure based on the signature (6.1).
State the number of parameters, the data type of the parameter, and the data type of the value being returned by looking at the signature of a function (6.1).
Explain the general pattern needed to declare a function (6.2).
State the specification of the function if a pre and/or post condition is given (6.2).
Define and give an example of recursion (6.3).
Explain the difference in the number of function calls between an iterative solution and a recursive solution for the same problem (6.3).
Describe the difference between the iterative ("reverse.ti") and recursive ("revers2.ti") solutions for reversing a string (6.3 & 6.4).
In general terms, describe how the "clean.ti" function strips punctuation out of text (6.4).
In general terms, describe how the "lower.ti" function transforms all letters into lowercase text (6.4).
Explain what a side effect is, and the two ways that side effects can be generated (unintentionally) in a program (6.5).
Describe an instance when a programmer might want to intentionally produce a side effect in a program (6.5).
Skills Outcomes
Given the signature, provide the correct parameters (type and number) needed to call any predefined function (6.1).
Use functions within your program to compute or determine needed values (6.1).
Given a description of the task to accomplish, define and create a function (6.2).
Generate a trace table for a simple recursive function (6.3).
Trace the recursive function to reverse a string (6.3).
Trace the recursive function to count the occurrences of a character in a string (6.3).