} Which of the following is (are) true regarding the linear-search algorithm?
It is generally suitable for large data sets.
The order in which the elements to be searched are arranged is unimportant.
The linear-search algorithm is used in the function find in the C++ Standard Template Library.
(a) I and II only (b) I, II, and III (c) III only (d) II and III only
• the main advantage of a linear search is that it does not require sorted data. Even if the data contained in a data set is stored in random order, a linear search still works as expected.
• The main disadvantage of a linear search is its suitability for only small data sets.
• The STL find() function performs a linear search on a container.
} Which of the following is (are) true about the nodes in a tree data structure?
A node can have at most two children. (not true)
A node can have multiple parents. (not true) 2 J
Items in the right child of a node are always greater than items in the left child. (It is not true in a ordinary tree. It is true for binary search tree only)
(a) I and III only (b) I, II, and III (c) I and II only (d) None
} Which of the following is (are) true about the C++ Standard Template Library (STL)?
Iterators provide access to elements in a container.
Iterators can only be moved forward through a container. (- not true)
Functions rbegin and rend return iterators to the last element and one position before the first element, respectively.
} The weighted path length for a path in a graph is the
(a) number of edges in the path (b) number of vertices plus the number of edges in the path (c) sum of the costs of each of the edges in the path (d) sum of the costs of each of the edges in the path divided by the number of edges
} Which of the following can be used to instantiate a C++ template class?
Primitive data types
User defined data types
(a) None (b) I and II (c) II only (d) I only
} Which of the following lines of C++ code begins a preprocessing directive for declaring a macro?
(a) #endif (b) #define (c) #include (d) #macro
} Which of the following indicates complexity functions listed in order of increasing growth rates?
(a) Quadratic, cubic, N log N (b) Linear, constant, logarithmic (c) N log N, log-squared, linear (d) Logarithmic, linear, cubic
D – is true
} Algorithms that run in _____ time typically perform fewer operations than algorithms that run in _____ time.
} Consider the following C++ definition of a recursive function func.
int func (int n) {
if (n <= 0)
return 1;
return n * func(n-2);
}
} Execution of the recursive function func will terminate
(a) only for even values of n (b) only for non-negative values of n (c) only for odd values of n (d) for all values of n
} Which of the following is (are) true about the sorting algorithm quicksort?
◦ I. Quicksort is typically implemented using recursion.
◦ II. Implementing an efficient quicksort algorithm involves selecting the element with the least value as the pivot.
(a) None (b) II only (c) I and II (d) I only
} In C++, the term type checking refers to
(a) syntax errors being identified during compilation (b) the dynamic binding of subtype objects to the type of their parent class (c) exceptions being raised due to overflow errors in the run-time environment (d) checking performed during compilation that ensures that only appropriate data values are assigned to data types
} In C++, output involves moving a sequence of _____ from a program to a device. This flow is commonly referred to as a _____.
} Consider implementing a program that is used to select an optimal move in a game. A common approach is to explore all possibilities recursively by implementing a _____ algorithm.
} In C++, a child class can pass a parameter to the constructor of its parent class
(a) by invoking the appropriate constructor in the initializer list (b) without explicitly invoking the parent class constructor (c) by using the keyword virtual (d) by using the keyword this
} What is the maximum depth of any node in a balanced binary tree containing 16 nodes?