CS 159 Final Review
The fscanf function references the name of the file pointer variable but NOT the name of the external file as one of its parameters.
False
The insertion sorting algorithm will complete one exchange involving at most two elements per pass.
False
The name of the external file is the parameter to the fclose function.
False
The selection sorting algorithm can only be used to sort data in an ascending order (from smallest to largest).
False
The strcmp function will compare two strings until unequal characters are found or until the end of the strings is reached.
False
The strcpy function will ensure that the source data does not exceed the capacity of the destination array.
False
The string length function strlen returns the length of the string including the delimiter character.
False
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.
False
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 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
One problem associated with storing variable data in a fixed-length data structure is how to tell the data from the nondata.
True
Since no size is specified in gets, it reads data until it finds a newline.
True
Since the string is an array its name cannot be used as the left operand of the assignment operator.
True
Static memory allocation requires that the declaration and definition of the memory be fully specified in the source program.
True
The * character can be used in the format string of an fscanf function to skip a value in a data file of the data type specified by the conversion code in the placeholder.
True
The C programming language provides two options for requesting memory, static allocation and dynamic allocation.
True
The act of dereferencing a pointer variable permits access to the value at the memory location to which the pointer variable points (or refers).
True
The asterisk character (*) is used in two different contexts for pointer variables; for declaration and for dereferencing.
True
The binary searching algorithm will always find a target in an array faster than the sequential searching algorithm.
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 data in a string may be variable in length but the array in which it is stored is of a fixed-length.
True
The deference of an array name is the value of its first element.
True
The delimiter used by the C programming language is the first character in the ASCII character sequence.
True
The fclose function can only be used to a close a connection that has been successfully opened.
True
The first parameter to the strcpy function is the source of the data to copied into the second parameter.
True
The following code segment uses pointer arithmetic to access and display the contents of the array. int i; int a[5] = {1, 3, 5, 2, 4}; for(i = 0; i < 5; i++) { printf("%d ", *(a + i));}printf("\n");
True
The following expressions are identical for the array a and integer n: (a + n) and &a[n]
True
The following expressions are identical for the array a and integer n: *(a + n) and a[n]
True
The gets function will take a line of input and make a string with terminal delimiter out of it.
True
The goal of a searching algorithm is to find the location of a target element inside of an array.
True
The indirection and address operators are the inverse of each other and when combined in an expression they cancel each other.
True
The indirection operator (*) is a unary operator whose operand must be a pointer value.
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 malloc function allocates a block of memory that contains the number of bytes specified in its parameter.
True
The malloc function returns the starting address of the memory allocated.
True
The memory allocated as a result of the malloc function is not initialized and we should assume that it will contain unknown values.
True
The name of a string is a pointer to the beginning of the string.
True
The name of an array is a pointer constant to its first element.
True
The name of an integer array can be assigned to an integer pointer variable.
True
The name of the external file being accessed is case sensitive when referenced in the fopen function call.
True
The number of exchanges that can potentially occur on a given pass of the bubble sort may be greater than 1.
True
The outer loop in each of the three sorting algorithms is responsible for ensuring the number of passes required are completed.
True
The parameter to the feof function is a file pointer variable.
True
The proper initialization of a pointer variable will include an address on the right side of the assignment operator with the pointer variable on the left.
True
The result of the malloc function is assigned to a pointer variable.
True
The scanf function will read data until it finds a whitespace, putting each character in the array in order.
True
The scanf function will replace the whitespace character with the delimiter at the end of the string.
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 size of an element is determined by the type of the pointer.
True
The strcpy function will return the sum of the differences in the two arrays being compared.
True
The value of a pointer variable can change during the execution of a program.
True
The value returned from the fopen function is used to initialize a file pointer variable.
True
The value returned from the fscanf function is the data value that was read from the external file.
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
Virtually all string implementations treat a string as a variable-length piece of data.
True
We can initialize a string by assigning a value to it when it is defined.
True
When a newline is read by the gets function it is discarded and replaces with the delimiter.
True
When a whole array is passed to a function the called function can declare the array using the traditional indexing notation [ ] or as a simple pointer variable.
True
When adding an integer to the name of an array the result is a value that corresponds to another index location. [Assume integer does not exceed bounds of the array.]
True
When the file pointer variable stores a value equal to zero it means the external file failed to open as expected.
True
Working with an uninitialized pointer variable is a logical error.
True
A character pointer value is returned from the strstr function.
False
A string constant is a sequence of characters enclosed in single quotes.
False
A value of the FILE* type cannot be returned from a user-defined function.
False
Any file extension of the external file being accessed is optional in the fopen function call.
False
If using an external file (via a file pointer variable) for input to a program then all input for the program must come from the external source.
False
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.
False
The C programming language uses fixed-length, delimited strings.
False
The binary searching algorithm will terminate when the first variable is greater than the last.
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
The bubble sorting algorithm is optimized to stop the sorting process when the array is detected as being in a sorted state.
False
The bubble sorting algorithm will complete one exchange involving at most two elements per pass.
False
The fclose function should always be called as the final statement in your program.
False
The feof function will return a zero when the end of the file has been reached.
False
No length checking is possible with gets and it is recommended that it never be used.
True
The value of a file pointer variable must be returned when making use of a user-defined function to open an external file. [In other words, file pointer variables ARE NOT passed by address.]
Treu
A (sort) pass is the movement of one element from the unsorted to sorted sublist.
True
A disadvantage of the delimiter is that it eliminates on character from being used for data.
True
A file pointer variable used to read external data into a program should always be compared with an error value to determine the data file was opened as expected before allowing the program to continue.
True
A pointer is a variable that stores an address as its value.
True
A standard string function will use the delimiter to determine the end of the data.
True
A user-defined function may be declared to return a pointer value.
True
A value of the FILE* type can be used as a parameter to a user-defined function.
True
All of the memory management functions are found in the standard library (stdlib.h).
True
An address operator is not necessary when working with the scanf function and a string because the name of the string already represents an address.
True
An extra space for a character in memory is necessary to store the delimiter character.
True
Because the name of the external file being accessed is known before compiling our programs it should be represented in your program as a symbolic/defined constant.
True
Dynamic memory allocation uses predefined functions to allocate memory for data while the program is running.
True
Every time we want a called function to access a variable in the calling function we pass the address of that variable to the 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
If we need to know the size of any data type the sizeof operator will give us the exact size in bytes.
True
In all three sorting algorithms studied the list (array) is divided into two sublists (subsections), sorted and unsorted.
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 C programming language a string is stored in an array of characters.
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