Final Programming
To determine that a item is not in an unordered array of 100 items, linear search must examine an average of ________ values.
100
If a bubble sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order, what order will the data be in after the first pass?
5 3 7 2 6 9
Binary search has time complexity O(nlogn).
False
Binary search splits the input in half for each iteration of the algorithm, like searching for a word in a paper dictionary. Open it in the middle and then select the correct side and repeat. So its runtime complextiy is Big-O(N2).
False
Binary search splits the input in half for each iteration of the algorithm, like searching for a word in a paper dictionary. Open it in the middle and then select the correct side and repeat. So its runtime complextiy is BigO(N ).
False
If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithm A is considered to be more efficient than Algorithm B.
False
To insert a node into a doubly linked list requires references to the node before and after the location we wish to insert the new node.
False
When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
False
The following is an algorithm to average a series of numbers ead from the keyboard: Prompt the user for the number of items Read the number of items (n) from the keyboard For each item Read the number from the keyboard Add it to the sum Divide sum by n Print the result to the screen Which of the follow expressions is the correct BigO complexity of the algorithm?
O(N)
The expression, 4N2-2N+1 is
Quadratic (degree 2)
A pointer with the value 0 (zero) is called the NULL pointer.
True
An array name is a pointer constant because the address it represents cannot be changed during run-time.
True
Bubble sort and selection sort can also be used with STL vectors.
True
For a linked structure you must allocate memory for each node.
True
Order of magnitude estimates don't work well if we are interested in behavior for small data sets.
True
We call it Big-O runtime complexity because we do not care about memory usage, just the execution of the instructions.
True
We call it BigO runtime complexity because we do not care about memory usage, just the execution of the instructions.
True
When you create a vector it is unnecessary to specify how many elements it will hold because it will expand in size as you add new values to it.
True
It is called asymptotic complexity analysis because ...
We want to use the largest values possible to even out small difference in algorithms
The ________, also known as the address operator, returns the memory address of a variable.
ampersand ( & )
Which of the following is a member function of the vector template?
back() capacity() empty() (All the above)
We can measure the complexity of an algorithm that solves a computational problem by determining the number of ________ for an input of size n.
basic steps it requires
Which of the following are potential problems when we use the delete operator on a pointer variable?
dangling pointers
A search can be performed on an array of
integers strings objects (All of the above.)
The advantage of a linear search is that
it can be used on unordered data
Which search algorithm steps sequentially through an array, comparing each item with the search value.
linear
To store a list in an array all items must be in adjacent elements, i.e. there can be no empty elements in the array other than at the end. For large lists, which of the following is true about the time required for inserting a new item into a linked list compared to insertion in such an array?
more efficient.
A sorting algorithm can be used to arrange a set of ________ in ________ order.
numeric values, descending strings, descending strings, ascending numeric values, ascending (All of the above.)
The ________ sort usually performs fewer exchanges than the ________ sort.
selection, bubble
The linear search is adequate for searching through ________ arrays, but not through ________ ones.
small, large
A pointer may be initialized with
the address of an existing object of the appropriate type.
To dereference a structure pointer and simultaneously access a member of the structure, the appropriate operator to use is
the structure pointer operator, >.
