CS159 - Midterm 2 True/False

Ace your homework & exams now with Quizwiz!

Pretest Loop Minimum # of times loop is iterated

0

Post test Loop Minimum # of times loop is iterated

1

The only way to complement a NOT operator is with another NOT operator.

false

The selection sorting algorithm can only be used to sort data in an ascending order (from smallest to largest).

false

The short circuit method of evaluating logical expressions does not apply to loop control expressions.

false

This for loop will iterate 6 times: for(i = 1; i <= 32; i * 2)

false

To pass the whole array to a function you need to use the name of the array followed by empty square braces [] in the function call statement.

false

Using the name of an array in the data list of a single printf function will result in the output of all elements of the array.

false

When passing a whole array to the function the total size of the array is necessary in the definition of the called function.

false

When passing a whole array to the function the total size of the array is necessary in the function call.

false

Pretest Loop # of times actions inside the body of the loop are executed

one less than the loop control expression

Pretest Loop # of times loop control expression is evaluated

one more time than the loop iterates

Post test Loop # of times actions inside the body of the loop are executed

the same number of times

Post test Loop # of times loop control expression is evaluated

the same number of times

3 && -3 && 10 && -10

true

3 == 3 && -1 && 1

true

3 == 4 || 6 || 8

true

3 || -3 || 10 || -10

true

3 || 6 && 0

true

6 % 2 || 7 % 2

true

A (sort) pass is the movement of one element from the unsorted to sorted sublist.

true

A counter controlled loop may execute a constant number of iterations.

true

A limited amount of control structures are permissible in the main function to ensure that it is the main function which makes most of the function calls for a program.

true

A nested loop is a repetitive process contained inside of another repetitive process.

true

A piece of data is called logical if it conveys the idea of true or false.

true

According to the course standards a for loop should only be used with counter controlled processes.

true

According to the course standards if all three expressions are not needed in a for loop then you should instead make use of a while loop for your pretest looping needs.

true

An iteration is one execution of all statements found inside the body of a loop.

true

An iterative solution involves the use of a loop to solve a repetition problem.

true

Array declarations will determine the type, name, and size of the array.

true

Arrays can be passed in two ways; by individual elements or the whole array.

true

Arrays must be declared and defined before they can be used.

true

Associated with a case label is zero or more executable statements.

true

C programmers use other types, such as integers, to represent logical data.

true

Complementing a condition is one way to potentially remove negative logic from an expression.

true

Control forcing statements such as break, continue, exit, and the use of multiple return statements in a user defined function are prohibited by course standards as mechanisms to terminate repetitive processes.

true

Course standards prohibit the use of break to terminate any repetition construct.

true

Elements of an array, themselves individual values of a given data type, are passed by value from calling to called function.

true

Exchanging the '<' for a '>' in the code on line 21 of page 495 of the C programming text will sort the data in the array from largest (index 0) to smallest (index of last minus one).

true

For a value to be potentially used as an index it must be an integral value or an expression that evaluates to such.

true

If a data value is zero it is considered false, but any non zero value is considered true.

true

In a fixed length array the size of the array is known when the program is written.

true

In a post test loop the minimum number of times that the statements found inside of the loop are executed is one.

true

In a pretest loop the control expression is evaluated before each iteration, including the first iteration.

true

In all three sorting algorithms studied the list (array) is divided into two sublists (subsections), sorted and unsorted.

true

In an else if the if condition is evaluated first and additional else if conditions are evaluated until a condition is found to be true.

true

In general, the use of the sequential search is limited to small data sets or those that are not searched often.

true

In the declaration of a user defined function with a two dimensional array as a parameter the size of the second dimension is required.

true

Indexed references to individual elements of an array are simply calculated addresses where the index value is added to the address represented by the name of the array.

true

Individual elements of an array can be passed by address through the use of the address operator.

true

Input validation is an example of an event controlled problem.

true

It is a course standard to indent all code within the body of a selection construct two additional spaces.

true

It is a course standard to make use of a symbolic/defined constant to represent the size of a statically declared array.

true

It is a course standard to make use of { and } with all if else constructs.

true

It is expected for many cases that the code for the validation of input be found in the same function that contains the prompt for input and scanf statement.

true

It is only the starting point of the array in memory that is represented by the name of an array and not the ending point.

true

It is possible for the number of times a counter controlled loop will iterate to depend on the value of a single variable or expression.

true

It is possible that during a single pass of the selection sorting algorithm that the order of the data in the array will be the same as it was after the previous pass.

true

It is possible to indicate on a structure chart when a user defined function is called from within a section construct.

true

It is possible to update/change/alter the loop control variable of a for loop inside of its body.

true

Iterative solutions are always better than recursive ones.

true

Multiway selection chooses among several alternatives.

true

Negative logic refers to any expression that begins with a NOT operator or that contains multiple NOT operators within.

true

No two switch case labels can represent the same constant expression value.

true

On the final pass through the selection sorting algorithm TWO values are brought over from the unsorted list into the sorted list.

true

Once the selection sort places a value in the sorted list that value will never move again in the remainder of the passes.

true

One approach to potentially make solving problems that require nested loops easier is to separate each repetitive process into its own function.

true

One motivation for making use of the binary search instead of the sequential search is the poor worst case performance of using the sequential search with a large data set.

true

Only the statements associated with the first true condition are executed in a multiway else if construct.

true

Passing the array name to a function allows changes in the called function to be available back in the calling function after it terminates.

true

Recursion is a repetitive process in which a function calls itself.

true

Recursion should not be used with event controlled processes as the result may be more function calls than the memory of the computer can accommodate.

true

Searching assumptions for each statement unless specified otherwise: • The data in the array is unique. • The amount of data in the array is equal to its capacity. • The use of the binary search is always applied to a sorted array.

true

Selection by itself is insufficient for input validation because it provides only a finite number of opportunities for the user to input valid data.

true

Similar to their required use in the if construct it is a course standard to always make use of { and } with all looping constructs.

true

The action that is responsible for changing the result of the loop control expression from true to false is the loop update.

true

The binary searching algorithm can be modified to work with an array that has been sorted from largest (at index zero) to smallest (at index SIZE of the array minus one).

true

The binary searching algorithm will terminate when the first variable is greater than the last.

true

The break statement results in the control of the program exiting the switch statement.

true

The bubble sorting algorithm compares neighboring elements in the unsorted list of the array and swaps their positions when they are not in the desired order.

true

The called function cannot identify whether the value it receives comes from an array, an individual variable, or an expression that evaluates to the expected type.

true

The case label represents an integral type value that is a possible result of the control expression.

true

The compiler will issue a warning when an assignment operator rather than the equality operator is used as the logical expression of an if condition.

true

The complement of the equal operator is the not equal operator.

true

The complement of x % 3 == 0 || x % 3 == 2 is x % 3 != 0 && x % 3 != 2 for all non negative integer (int) values of x.

true

The condition in a recursive function when which the recursive function calls stop is known as the base case.

true

The condition that determines whether the task to repeat is finished is known as the loop control expression.

true

The conditional expression has three operands and a two token operator.

true

The contents of a loop have been identified to be repeated in a program.

true

The control expression that follows the keyword switch may be a character expression.

true

The conversion code to use for input or output of an array element depends on the data type of the array.

true

The course standards limit the use of the break statement to only switch statements.

true

The declaration of a multidimensional array will include the extent, or size, of each dimension.

true

The do while loop will terminate with a semicolon after its loop control expression.

true

The else does not have a condition associated with it.

true

The else is executed only when all previously evaluated conditions are false.

true

The expressions if(a != 0) and if(!a) are complements.

true

The expressions if(a == 0) and if(a) are complements.

true

The following two logical expressions are equivalent for all integer (int) values of x: !(x < 10) and x >= 10

true

The following two logical expressions are equivalent for all non negative integer (int) values of x: x % 2 and x % 2 != 0

true

The goal of a searching algorithm is to find the location of a target element inside of an array.

true

The index value represents an offset from the beginning of the array to the element being referenced.

true

The initialization of the loop control variable must take place outside the body of a pretest loop.

true

The insertion sort takes a value from the unsorted sublist and inserts it into the proper location of the sorted sublist based on the values currently present in the sorted sublist.

true

The insertion sorting algorithm begins with one value in the sorted list before the first pass.

true

The logical AND (&&) operator is true only when both operands are true.

true

The logical expression of an if...else construct must be enclosed in parentheses.

true

The loop control variable is commonly a part of the loop control expression and the recipient of the loop update action.

true

The name of an array is a primary expression whose value is the address of the first element in the array.

true

The name of an array is a reference to the address of where it begins inside the memory of the computer.

true

The number of exchanges that can potentially occur on a given pass of the bubble sort may be greater than 1.

true

The number of times that the loop control expression is evaluated is one more than the number of iterations in a pretest loop.

true

The outer loop in each of the three sorting algorithms is responsible for ensuring the number of passes required are completed.

true

The reason that the C language does not pass whole arrays by value is the extra stress it would put on the memory of the computer to make a copy of an array.

true

The selection sort will identify one value in the unsorted sublist to move and become a part of the sorted sublist.

true

The selection sorting algorithm will complete one exchange involving at most two elements per pass.

true

The short circuit method of evaluating logical expressions will stop evaluating the current expression as soon as the result can be determined.

true

The statements found inside of an if...else may be any statement, including another if...else construct.

true

The switch construct can only be used when the selection condition reduces to an integral expression.

true

The while loop requires the use of parentheses around the loop control expression.

true

There is no semi colon that follows the logical expression of an if...else construct.

true

This for loop will iterate 10 times: for(i = 0; i < 10; i++)

true

This for loop will iterate 5 times: for(i = 12345; i != 0; i /= 10)

true

To determine a target value is not found in an unsorted list while using the sequential searching algorithm every element must be examined.

true

To sort an array of N elements a N - 1 sort passes are required to guarantee that data always ends in a sorted state.

true

Values once placed in the sorted sublist of the insertion sort are subject to be moved again as the algorithm progresses.

true

Variables and loops are commonly used together to generate index values to access the elements of an array.

true

When accessing an array element the C language does not check whether the index is within the boundary of an array.

true

When attempting to print the result of a logical expression that is true as an integer the result will always be 1.

true

When different variables are being evaluated as expressions it is better to use a nested if...else rather than the multiway else if.

true

When the selection is based on a range of values, or the condition is not integral, we use the else if for our multiway selection needs.

true

When the statements associated with one case have been executed the program flow continues with the statements for the next case.

true

When writing a selection construct the most probable conditions should come before those that occur less frequently.

true

While the default technique of passing array elements is by value it is possible to pass elements by address using the & operator (and the * operator in the function being called).

true

With each comparison made in the binary search approximately half of the remaining elements in the array are eliminated as possible locations of the target.

true

You can make use of x++, ++x, x += 1, and x = x + 1 interchangeably as the update (third) expression of a for loop to increment the loop control variable.

true

The bubble sorting algorithm will complete one exchange involving at most two elements per pass.

false

The capacity of a multidimensional array is the sum of the extent, or size, of each dimension.

false

The complement of the greater than operator is the less than operator.

false

The complement of x > 0 && x < 10 || y + 2 == 0 is x <= 0 || x >= 10 && y + 2 != 0

false

The dangling else logical error can be corrected by indenting the if and else the same number of spaces.

false

The gcc compiler as used on the guru.itap.purdue.edu server this semester will permit a variable to be declared and initialized in the first expression of a for loop. See examples on pages 318 and 319 of your C programming text.

false

The insertion sorting algorithm will complete one exchange involving at most two elements per pass.

false

The logical OR (||) operator is true only when exactly one of its operands is true.

false

The maximum number of actions that can be associated with a switch case label is one.

false

The number of times the update action is executed is equal to the number of times the loop control expression is evaluated in a for loop.

false

In order for two, or more, repetitive processes to be considered nested they must appear in the same user defined function.

false

In this course you will be expected to validate for the input of both the range of acceptable values and the correct data type.

false

It is always a logical error to associate two switch case labels with a common set of actions.

false

The AND and OR operator share the same level of operator precedence.

false

The address operator is not necessary in a scanf to accept input for an individual array element when using the indexing technique.

false

The binary searching algorithm is not applicable when the values found in the array are not unique.

false

The binary searching algorithm will always find a target in an array faster than the sequential searching algorithm.

false

The bubble sort operates faster when moving the larger values to the highest index than when moving the smaller values towards index zero.

false

Each switch case label is the keyword case followed by a constant expression inside of single quotes.

false

If a target value is not present in a sorted list then every element of that list must be compared before that fact can be determined.

false

If more than one element of an array is passed to a function in a single function call then those elements are passed by address.

false

If the number of values provided for initialization of an array is fewer than the size of the array then the remaining elements have no known value.

false

The bubble sorting algorithm is optimized to stop the sorting process when the array is detected as being in a sorted state.

false

In an event controlled loop we know the number of times that the actions found inside the body of the loop will be executed.

false

A reasonable effort should be made to convert most while loops into for loops.

false

All arrays sent to a given user defined function must be of the same defined size.

false

All elements of one array can be assigned to another through the use of the assignment operator and the name of each array (example: x = y).

false

Arrays in the C programming language use a one based index.

false

Conditional expressions cannot be nested as the resulting code becomes too complex.

false

Declaration and definition of an array will include a default initialization of all elements.

false


Related study sets

Antimicrobial Drugs - Chapter Exam 15

View Set

NCLEX Practice Questions to Remember

View Set

OB Chap 21 Nursing Management of Labor and Birth at Risk

View Set

Chapter 9: Building a New Venture Team

View Set

AP Environmental Science Unit 7 Exam Review

View Set