Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ssd5_mcq

.docx
Скачиваний:
8
Добавлен:
25.02.2016
Размер:
40.05 Кб
Скачать

A backtracking algorithm is one that (a) uses recursion to test all possible solutions for a problem

A typical implementation of a deque in the C++ STL minimizes the need to copy elements upon the frontal insertion of new items by (c) reserving memory at the front of the deque's stored elements

A C-style string is stored as an array of characters that ends with _____ character. (b) a '\0'

A divide-and-conquer algorithm typically makes use of (d) recursion

A graph-searching strategy that processes vertices in layers such that layers closest to the starting point are searched before those that are more distant is known as a _____ search. (c) breadth-first

A hash table that stores whether or not a key is present, but does not associate any other information with the key, is commonly known as (b) a hash set

A node in a tree that does not have a predecessor is called (b) a root

A node in a tree that does not have any children is called (d) a leaf

A priority queue can be implemented with which of the following data structures? A set, A multiset

(c) II only

A programmer can detect a syntax error in a C++ program when the program is (a) compiled

Access to ranges of elements in an STL container is typically handled by (c) iterators

All of the following characters are allowed to be part of a valid C++ identifier except (d) hyphen

An STL adapter provides (d) a new programming interface for an existing STL container

An ordered set of directives that can be carried out mechanically is known as a(n) (c) algorithm

Assume that Thing is a user-defined class, and consider the following function.

Thing f

Thing& A {

Thing B;

B.x = A.x;

return B;}

Where in this code will a copy constructor be used? (c) In the return operation

Assume that Thing is a user-defined class, and consider the following code fragment, where B is an instance of Thing.

Thing A = B;

Which of the following is a class member that is used in this code fragment? (b) The copy constructor

Assume that Thing is a user-defined type. Which of the following print functions for Thing is the safest and most efficient? (d) void print( const Thing& x );

At the end of the _____ stage for a C++ program, a(n) _____ can be produced. (c) linking, executable image

C++ is said to be an object-oriented language because of its support for (b) classes, inheritance, and polymorphism

C++ supports which of the following features? Classes, Inheritance, Exceptions (b) I, II, and III

Consider the following program fragment that calls the method count_if in the C++ Standard Template Library.

deque<int> numbers;

count_if(numbers.begin(), numbers.end(), is_odd);

Which of the following declarations for the method is_odd is correct for the call to count_if? bool is_odd(int i);

Consider the following pseudo-code, which indicates part of a standard binary tree algorithm.

print( node ) {

print data;

if( there is a left child ) print( left child );

if( there is a right child ) print( right child ); }

Which of the following is the standard name for this algorithm? (a) Preorder traversal

Consider the following C++ function that uses a divide and conquer approach to calculate the sum of a range of numbers.

int sum(int i, int j) {

if (i == j) {

return i; }

else {

int mid = (i+j) / 2;

int result = sum(i,mid) + sum(mid+1,j);

return result; } }

Which of the following lines of code from the above function divides this problem into sub-problems? (b) int result = sum(i,mid) + sum(mid+1,j);

Consider a data set of 100 items. Which of the following is a search algorithm (are search algorithms) that could possibly examine 25 items in this set before succeeding? Linear search, Binary search (b) I only

Consider the following definition of a recursive function f.

bool f( int x ) {

if( (x & 1) == 1 ) return (x == 1);

return f( x >> 1 ); // right shift }

The value returned by the call f(x) will determine whether the input x is (d) a power of 2

Consider the following definition of a recursive function ff.

int ff( int n ) {

if( n == 0 ) return 1;

return 2 * ff( n - 1 ); }

If n > 0, what is returned by ff( n )? (c) 2n

Consider the following inheritance declarations.

class Base {

public: int x;

private: int y; };

class Derived: public Base {

public: int z; };

Derived D; )

Under these declarations, which of the following statements, if any, will fail to compile? (b) D.y = 555;

Consider the following template swap function.

template<typename T>

void swap( T& a, T& b ){

T tmp = a; a = b; b = tmp; }

Determining the right choice of type parameter T occurs at which of the following times? (c) Compile time only

Consider the following code fragment concerning the STL list class.

list<int> L(10);

L[3] = 555;

The fragment will produce a compile time error because (d) the class list does not support the bracket operator

Consider the following code fragment, where L is a linked list of integers.

for( it = L.begin(); it != L.end(); ++it )

*it += 10;

Execution of this fragment has the effect of (d) adding 10 to each list element

Consider the following definition of a recursive function, power, that will perform exponentiation.

int power( int b, int e ) {

if( e == 0 ) return 1;

if( e % 2 = 0 ) return power( b * b, e/2 );

return b * power( b * b, e/2 ); }

Asymptotically in terms of the exponent e, the number of calls to power that occur as a result of the call power(b,e) is (a) logarithmic

Consider the following outline of a template sorting function.

template<class T> void sort( T a[], int n ) { ... }

For a given sorting algorithm S, which of the following is true about using this outline to implement S? (d) It is a reasonable way to implement S.

Consider the following C++ program segment:

int j[10];

for (int i = 0; i < 10; i++) {

j[i] = i;}

int *a = j;

a++;

After execution of this program segment, what will be the value of j[0]? (a) 0

Consider the following C++ program fragment, which is a partial declaration of the class string.

class string {

public:

string(const char* cstring = "");

bool operator== (const string & rhs); };

Given this class and two string objects called s1 and s2, which of the following is not a legal statement? (d) bool ans = ("hello" == s1);

Consider the following outline of a template array class.

template<typename T> class Array { ... }

Which of the following is true about using this outline to implement a general container class? (b) It is a reasonable way to implement such a class.

Consider the following C++ program segment:

int j = 5;

int *a = &j;

*a = *a + 4;

After execution of this program segment, what will be the value of the variable j? (a) 9

Consider the following definitions of a C++ class.

class Array {

public:

typedef float Item; // <-- change here

Item& operator[](int i) {return arr[i];}

private:

int len; // length of array

Item *arr; // pointer to first elm};

template<typename T>

class Array {

public:

T& operator[](int i) {return arr[i];}

private:

int len; T *arr; };

The second definition of class Array is _____ versatile than the first _____ efficient at run time when used in a program. (b) more, and equally

Consider the following C++ program segment:

try {

throw out_of_range("out of range");}

catch (logic_error& e) {

cout << e.what(); }

catch (...) {

cout << "exception encountered";}

The above program segment will output which of the following character strings? (d) "out of range"

Consider the following C++ program segment:

try {

throw out_of_range("out of range");}

catch (runtime_error& e) {

cout << e.what(); }

catch (...) {

cout << "exception encountered";}

The above program segment will output which of the following character strings? (c) "exception encountered"

Consider the following C++ program segment:

try {

throw out_of_range("out of range");

cout << "try ";}

catch (...) {

cout << "catch ";}

The above program segment will output which of the following character strings? (c) "catch "

Consider the following template swap function and data types.

template<typename T> void swap( T& a, T& b ){

T tmp = a; a = b; b = tmp; }

char c1, c2;

int i1, i2;

float A[10];

Which of the following calls to swap produces a compile time error? swap( i1, c2 ), swap( c1, i2 );, swap( A[5], A[2] ); (b) I and II

Consider the following partial C++ template class definition.

template<typename T>

class Array {

public:

T& operator[](int i) {return arr[i];}

private:

int len; T *arr; };

Which of the following is a (are) correct template instantiation(s)? Array<int> A;, Array<double> A;, Array<Array<int> > A; (a) I, II, and III

Consider the following partial C++ templated class definition.

template<typename A, typename B>

class ...

The line of code template<typename A, typename B> will generally be followed by (c) a class definition containing the generic type parameters A and B.

Consider the following C++ program segment, which uses the STL.

stack<int,vector<int> > S;

Execution of the statement results in creation of which of the following? (b) A stack of integers

Consider the function defined as follows.

int f( int n ) {

if( n == 0 ) return 0;

if( (n & 1) == 0 ) return f(n/2);

return f(n/2) + 1; }

The value returned by the call f( 10 ); is (b) 2

Consider the following recursive definition of a function f in C++.

int f(int n) {

if( n == 0 ) {

return 1; }

else {

return f(n / 2); } }

The asymptotic running time of the call f(n) is most closely bound from above by (c) O(log n)

Consider the following definition of a recursive function f.

int f( int x ) {

if( x == 0 ) return 1;

return x * f( x - 1 ); }

The inputs for which f will terminate are all x such that x is (d) non-negative

Consider the following definition of a recursive function ff in C++.

int ff( int n, int m ){

if( n == 0 ) return m;

return ff( n - 1, m + 1 );}

Which of the following characterizes the value returned by the call f(n,m)? (b) The sum of m and n

Consider the following statement using the STL sort() routine.

sort( A.begin(), A.end(), f );

Which of the following most accurately describes the result of executing this statement? (a) Container A is sorted using the Boolean valued function f for comparisons.

Consider the following C++ template function.

template <class T>

void mystery_sort(vector<T>& v) {

for (int i = 0; i < v.size() - 1; i++) {

int best = i;

for (int j = i + 1; j < v.size(); j++) {

if (v[j] < v[best]) {

best = j; } }

if (best != i) {

T temp = v[i];

v[i] = v[best];

v[best] = temp; } } }

The above function implements which of the following sort algorithms? (a) Selection sort

Consider the following C++ code fragment.

for( int i = 1; i < n; i *= 2 ) body;

If body executes in O(1) time, then the asymptotic running time that most closely bounds the code fragment above is (d) O(log n)

Consider the following definition of a recursive function f.

int f( int x ) {

if( x == 0 ) return 1;

return x * f( x );}

For which inputs x will the call f(x) terminate? (b) For x = 0 only

Consider the following code fragment.

for( int i = n; i > 0; i /= 2 ) body;

If body executes in O(1) time, then the asymptotic running time that most closely bounds the fragment is (b) O(log n)

Consider the following definition of a recursive function ff in C++.

int ff( int n, int m ){

if( n == 0 ) return 0;

return ff( n - 1, m ) + m;}

Which of the following characterizes the value returned by the call f(n,m)? (d) The product of m and n

Consider the following C++ program segment, which uses the STL.

stack<int> S;

S.push(123);

S.push(456);

cout << S.pop() << endl;

Which of the following accurately describes what, if anything, fails in the segment? (a) A compilation error occurs because pop does not return a value.

Consider the following C++ program segment, assuming that string is a class.

string str1("Hello, World");

str1[5] = 'Z';

The overloaded operator[] function invoked in the above program segment should have which of the following return types? (d) char &

Consider the execution of the following.

vector<int> A(10,20);

Which of the following accurately describes what is created? (c) An array of 10 ints, each initialized to 20

Consider the following program segment.

vector<int> A(10);

A.resize(0);

A.push_back(5000);

At the end of an execution of this fragment, the size of vector A is (d) 1

Consider the following C++ program fragment.

vector<int> A(10);

A.push_back( 5000 );

At the end of an execution of this fragment, the size of vector A is (a) 11

Consider the following C++ program segment.

#include <iostream>

#include <cstdlib>

using namespace std;

int main(int argc, char* argv[]) {

return EXIT_SUCCESS;}

The first two lines of this program segment typically direct the preprocessor to (b) include the contents of two files into the program segment's source code

Consider the following declaration that makes use of a user-defined class Thing.

vector<Thing> A(10);

In order that it compile, the class Thing must have which of the following? (c) a default constructor

Consider the following C++ code segment intended to traverse the list L in reverse order.

list<int>::iterator it;

for( it = L.end(); it != L.begin(); --it ) {

cout << *it << endl; }

The code segment will not serve the intended purpose because (d) an attempt is made to access a non-existing list element

Decomposition of a problem involves which of the following? (a) Identifying entities and relationships that will aid in solving the problem

Differences between the STL adapter queue and the STL container deque include which of the following? queue provides support for iterators, whereas deque does not., queue provides access to only the first and last elements in a collection, whereas deque permits access to an entire collection. (a) II only

Dijkstra's algorithm and the Bellman-Ford algorithm both determine (d) the shortest path between two nodes in a graph

Djikstra's algorithm may be used to find the _____ path in a graph that contains edges with _____ weights. (c) shortest, only positive

During a failed search for an element in a completely balanced binary search tree of size 1,000,000, approximately how many nodes of the tree are visited? (a) 20

Execution of the code fragment

list<int> A(10);

does which of the following? (d) Creates a linked list of 10 ints, with each element initially 0.

Execution of which of the following statements sets an STL iterator it so that it points to the first element of a container A? (a) it = A.begin();

Each of the following C++ code fragments produces a memory leak except: (b) int *A = new int[10]; delete [] A;

Each of the following is a basic C++ type except (b) byte

Each of the following indicates a reasonable way to implement graphs except (c) a binary search tree

For an STL iterator it, execution of the statement it--;does which of the following? (b) Steps the iterator backwards to the previous item.

For an STL iterator it, execution of the statement ++it; does which of the following? (c) Advances the iterator to the next item.

For a template hash table class to work with some user-defined key type Thing, the user has to specify (a) the type Thing, a hash function for Thing, and equality testing for Thing.

How many calls to itself is a recursive function allowed to make? (c) Any number

How does C++ handle memory allocation? (b) Allocation and deallocation is the responsibility of the programmer.

If numbers 1,2,...,n are inserted into a binary search tree in random order, then the result for large n is a (d) reasonably balanced tree

If A is an STL vector, then the effect of executing the statement A.push_back( x ); is to (d) check whether the capacity of A is larger than the size of A, enlarges A if necessary, and append x to A

If A is an STL vector, then the effect of executing the statement A[i] = x; is to (c) write x to position i of the vector, without bounds checking

If A is an array of 100 integers, which of the following properly deallocates A? (d) delete [] A;

If templates were removed from C++, which of the following would be true? Some algorithms could no longer be implemented., Any particular algorithm could still be implemented, but often less elegantly., Any particular algorithm could still be implemented, but the efficiency would often be catastrophically worse. (d) None

If a user-defined class Complex has overloaded operator+=, then one would expect this operator to have which of the following declarations? (b) Complex& operator+=( const Complex& rhs );

Inheritance is an important feature of C++ because (a) it is a powerful code reuse mechanism

In STL vectors, _____ refers to the maximum number of items that can be stored without resizing, and _____ refers to the number of items stored. (b) capacity, size

In the context of hashing, what is meant by a collision? (d) Two different keys hash to the same slot.

In a template definition

template<typename T> ...

the template parameter T ranges over (c) all types

In a binary tree containing n nodes, the depth of the root node is (d) 0

In a search over a data set with 1000 items, the maximum number of items examined by a linear search is _____, and the maximum number of items examined by a binary search is _____. (a) 1000, 10

In C++, preprocessor directives begin with which of the following symbols? (c) #

In the C++ Standard Template Library, which of the following containers represents a collection of unique elements? (c) set

In the C++ Standard Template Library, which of the following containers stores only key-value pairs? (a) map

In the C++ standard template library (STL), which of the following is a property of const iterators for the list container? (b) They provide read-only access to a linked list.

In the C++ Standard Template Library (STL), the class queue is _____ that uses _____ for storage. (b) an adapter, a sequence container

In the C++ Standard Template Library, vectors and deques differ in their interfaces for handling which of the following operations? Insertion of an element at the front of the container, Insertion of an element at the end of the container, Removal of an element from the front of the container (b) I and III only

In the C++ standard exception hierarchy, which of the following classes is derived from class logic_error? (d) length_error

In C++, calling the method empty for the STL adapter queue returns (a) true if the queue contains no elements

In C++ exception handling, a try block must be followed by _____ catch block(s). (c) one or more

In C++, the preprocessor is (a) a tool that manipulates source files before compilation

In C++, the directive #include is processed by the (c) preprocessor

In C++, the ability for an entity to assume different types is known as (d) polymorphism

In C++, a preprocessor directive is a (a) single-line command introduced into a C++ source file

In C++ exception handling, intermediate exception handlers typically are used to: (c) ensure allocated resources are properly released

In STL, nodes of a linked list can be accessed using which of the following? STL iterators, Subscripts

(d) I only

In the STL, common algorithms are instantiated for multiple types of container classes by using _____ to provide a uniform interface between the algorithms and containers. (c) iterators

Lines at a store, file cabinets, and bookcases are real-world entities that most resemble _____ in computer science. (c) data structures

One thing that the STL vector and the STL list have in common is that both are (d) sequential containers

One reason for using an assert statement such as

assert( 0 <= i && i < 10 );

within code is to (b) terminate execution and send an error message whenever the condition is violated

Polymorphism is a mechanism that is used in order to (b) determine the type of an object dynamically at run time

Regarding C++ standard I/O, the _____ operator writes to a stream and the _____ operator reads from a stream. (b) <<, >>

Searching for an element in a binary search tree takes O(s) steps where s is (d) the depth of the tree

Searching for an element in a linked list containing n elements is most closely bounded from above by (a) O(n)

Suppose inf is an available ifstream and c is an available character. Consider the following code fragment.

do

c = inf.get();

while (!inf.eof() && isspace(c));

Which of the following accurately describes the effect of executing this fragment? (d) Characters are read until a non-white-space character is read or until the end of the file is reached.

Suppose hash() is a hash function. The main idea behind hashing is to use a key k to store a value v in which position of a table? (b) hash(k)

Suppose a user-defined class Thing has a simple constructor that does not require any calls to new. Which of the following is true about the destructor? (b) It might contain calls to delete, but might not.

The asymptotic running time that most closely bounds the performance of a selection sort on an input array with length n is (c) O(n2)

The asymptotic running time of merge sort with an input array of length n is most closely bound from above by? (c) O(n log n)

The asymptotic running time that most closely bounds the performance of insertion sort on an input array with length n is (c) O(n2)

The time to perform depth first search, starting at the first vertex of a graph with n vertices and e edges implemented as an adjacency list has what order? (b) O(n + e)

The proper tool for writing an array class that can have some instances with integer elements and other instances with float elements is the use of (b) templates

The main abstractions of the Standard Template Library include which of the following? Iterators, Exception handlers, Algorithms (b) I and III only

The STL is heavily based on (c) templates

The purpose of the assignment operator is to provide for proper assignment between objects

The purpose of function templates is to (d) easily specify a family of operationally equivalent functions

The purpose of a constructor is to (d) initialize data members of a class properly after space has been allocated

The size of an STL vector is defined to be the (c) number of elements currently stored in the vector

The capacity of an STL vector is defined to be the (a) maximum number of elements that can be stored in the vector without resizing

The nodes of a _____ linked list can be traversed _____. (c) singly, forward only

To indicate the end of the list, the final node in a typical singly-linked list stores _____ in place of a _____. (c) a null pointer, pointer to the next node

To access an element in a singly linked list, a program must (d) traverse all nodes in the list prior to that element

To read data from a file into a C++ program using class ifstream, it is necessary to include the _____ library header file. fstream

To which of the following is object-based programming ideally suited? (b) Encapsulation

Typical divide and conquer algorithms use _____ to divide a problem into smaller sub-problems. The _____ typically solve(s) these sub-problems directly. (d) recursive function calls, base case of the recursion

Typical implementations for which of the following STL containers store elements contiguously in memory? Vector, list (b) I only

Under what circumstances will a member function in C++ display polymorphic behavior? (a) If and only if the function is explicitly declared to be virtual

Using a backtracking technique to solve a problem typically involves (d) pursuing a possible solution until it is found to be a solution or a non-solution

What is the role of the destructor for the base class when an instance of a derived class goes out of scope? (c) It is called automatically.

What is the purpose of class templates? (d) To easily specify a group of related classes

What is the effect of the following C++ code fragment?

int A[100];

for( int *p = A; p < A + 100; ++p ) {

*p = 0;} (c) It zeroes out the 100 elements of array A.

What is composition? (c) It is the inclusion of one class in another as a data member.

What, if anything, is wrong with the following C++ code fragment?

bool *bp; int x;

bp = &x; (c) A pointer to an int cannot be assigned to a variable that is a pointer to a bool.

What, if anything, is wrong with the following code fragment?

Thing *ptr = new Thing;

ptr = NULL; (d) When executed, it will create an instance of Thing and then remove the only reference to this instance without destroying it first.

What is the runtime overhead of a divide-and-conquer algorithm that recursively processes two equal halves of a problem that each have an overhead of O(n)? (b) O(n log n)

What would be the consequences for algorithms if recursion were removed from C++? (c) All algorithms could still be implemented, but often less elegantly.

What is the purpose of using memoizing? (d) To store return values of functions, in order to avoid recomputation

Which of the following statements about C++ is (are) true: It is strongly typed., It has been standardized by ISO. (b) I and II

Which of the following is (are) true of recursive algorithms and the backtracking problem-solving technique? Recursive algorithms implement backtracking by reducing a problem into smaller and smaller sub-problems., Recursive algorithms cannot be used to implement backtracking., Recursive algorithms that implement backtracking do not typically have a base case. (c) I only

Which of the following statements might be produced by the decomposition of a problem into objects and relationships? "A is a type of B", "A B contains a C" (d) I and II

Which of the following is a C++ data structure that represents a list of entries consisting of unique keys and their associated values? (c) map

Which of the following is (are) true of the minimax strategy for deciding the optimal move in a two-person game? It assumes that a human player will eventually make a mistake by playing a move that is not optimal., It is commonly used with a backtracking algorithm. (b) II only

Which of the following is true about the depth of a tree with exactly three nodes? (d) It is at most two.

Which of the following is not a predefined stream object in C++? (a) cfile

Which of the following statements about arrays and linked lists is (are) true in the context of a sorting algorithm? The sorting algorithm is asymptotically faster if the elements are in an array rather than a linked list., For the algorithm to be implemented, direct element access must be supported in both the containers. (a) None

Which of the following statements is true of a breadth-first search? (d) It processes nodes in order of increasing distance from a starting node.

Which of the following search algorithms can be applied to unsorted data? Linear search, Binary search (a) I only

Which of the following is a C++ data structure that represents an ordered list with no duplicate items? (d) set

Which of the following statements is true of both depth-first and breadth-first searches? (b) From a given starting node, they will not necessarily explore all other nodes in a graph.

Which of the following traversals of a binary search tree will produce a sorted list if a visit to a node prints what is stored there? (a) Inorder

Which of the following is the main reason for using recursion? (b) To obtain short, elegant solutions

Which of the following indicates the primary difficulty with hashing in general? (a) Collisions will occur.

Which of the following is true about a good hash function? (c) It should produce apparently random values for given items.

Which of the following operations is (are) typically more efficient in a linked list than in a vector? Removal of the first element, Random element access

(c) I only

Which of the following statements regarding C++ exception specifications is (are) true? An exception specification can guarantee that a function does not throw any exceptions., An exception specification can permit a function to throw any type of exception. (c) I and II

Which of the following is (are) true about template classes in C++? Methods cannot be overloaded in templated class definitions., Private data of a templated class cannot be declared to have the type of the templated parameter. (c) None

Which of the following is not a basic operation that can be performed on a queue? (a) Inserting an item into the second position of the queue

Which of the following statements about both arrays and linked lists is (are) true? Direct element access using subscripts is supported in both the containers., Both can be searched using binary search., Elements of both the containers can be sorted. (a) III only

Which of the following statements is (are) typical of divide and conquer algorithms? Recursive function calls are used to divide a problem into smaller and smaller sub-problems., Concurrent programming is used to divide the necessary processing between multiple processors. (a) I only

Which of the following is true about the run-time efficiency of using template functions versus using nontemplate functions? (d) The run-time efficiency is the same for both.

Which of the following is necessary in order to obtain polymorphic behavior in C++? (d) Pointers or references are used with virtual functions.

Which of the following is true about compilation of a template function or class? (c) Compilation takes slightly longer.

Which of the following describes a difference between template functions and template classes in C++? (d) The compiler determines the types of a template function's arguments, but the types of template classes must be stated explicitly when declaring objects.

Which of the following statements is (are) true about the locations of a linked list's nodes in memory? Nodes must appear at a fixed distance from one another in memory., The order of elements in a list must match the order of the list's nodes in memory. (a) None

Which of the following is (are) typically true about linked lists? Objects in a linked list are stored contiguously in memory., All elements in a list are copied to new locations in memory upon frontal insertions to the list. (a) None

Which of the following is true of inheritance? (b) It provides for the elegant construction of a new class from an existing class.

Which of the following is (are) typically managed using a stack? Implementation of function calls in a procedural programming language, Evaluating arithmetic expressions, taking precedence rules into account, Handling jobs sent to a printer, and ensuring that the first jobs to be submitted are printed first (b) I and II only

Which of the following operations are valid for C++ pointer arithmetic? Addition, Subtraction, Multiplication (b) I and II only

Which of the following statements is (are) true of typical implementations of vectors and deques? A vector's implementation uses one array, whereas a deque's implementation uses multiple arrays., Insertions at the front of a deque tend to be more efficient than insertions at the front of a vector. (a) I and II

Which of the following C++ operators is the dereference operator? (b) *

Which of the following expressions evaluates to true in C++ if and only if the index variable i is in bounds for an array of size 10? (d) 0 <= i && i < 10

Which of the following is true about a class without a (user-defined) constructor? (b) It may have a destructor, but might not.

Which of the following is true about the total number of nodes in a binary tree with depth two? (c) It is at most seven.

Which of the following is true about the total number of nodes in a tree with depth two? (b) There is no bound on the number of nodes.

Which of the following statements is true of the selection-sort algorithm? It is a divide-and-conquer algorithm typically implemented using recursion., An implementation of the algorithm typically requires the use of a hash table. (b) None

Which of the following statements regarding the design of the Standard Template Library (STL) in C++ is (are) true? Each STL algorithm is usable with one specific container., The STL does not use templates and instead relies on polymorphism. (d) None

Which of the following statements is (are) true regarding C-style strings? They are terminated by the null character., Storing a five-character string requires at least seven characters. (b) I only

Which of the following statements is (are) true about stacks? Elements are inserted and deleted in last-in-first-out order., Stacks can be implemented using linked lists., Stacks can be implemented using arrays. (c) I, II, and III

Which of the following statements is (are) true regarding strings in C++? Strings in C++ are supported by the standard class string., A constructor for the class string can accept a C-style string as an argument. (d) I and II

Which of the following is an example of a pure virtual function? (a) virtual int Compute() = 0;

Which of the following is the C++ preprocessor directive for file inclusion? (d) #include

Which of the following statements is true about a reference used as a function parameter? (d) It allows a function to modify the original object passed in as the argument.

Which of the following is true about the default parameter passing mechanism in C++? (b) It is call-by-value.

Which of the following statements creates p as an alternative name for the variable i? (d) int &p = i;

Which of the following declares p to be a pointer to an integer? (a) int *p;

Which of the following is true about variables with dynamic extent? (a) They are created and destroyed by the programmer.

Which of the following statements properly allocates an array of 100 integers? (c) int *A = new int[100];

Which of the following lists of C++ types are ordered increasingly by size, as computed by sizeof()? (d) char, short, int, long

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]