C++ Final Exam

¡Supera tus tareas y exámenes ahora con Quizwiz!

c. the root of the tree

In a binary tree class, you usually have a pointer as a member that is set to: a. the leftmost child node b. the first leaf node c. the root of the tree d. the deepest leaf node e. None of these

False

In a binary tree, each node must have a minimum of two children. Group of answer choices True/False

False

In a binary tree, the branches go only from a child to a parent. Group of answer choices True/False

first node

In a circular linked list, the last node points to the Group of answer choices head pointer tail pointer first node None of these

front

In a dequeue operation, the element at the ________ of the queue is removed.

circle

In a diagram of a binary tree, each node is represented as a(n) ____. Group of answer choices line triangle circle rectangle

a. immediate

In a directed graph G, for each vertex, v, the vertices adjacent to v are called ____ successors. a. immediate b. adjacent c. path d. parallel

False

In a directed graph, the pairs (u,v) and (v,u) represent the same edge. a. True b. False

b. weighted

In a graph G, if the edges connecting two vertices have weights assigned to them, the graph is called a ____ graph. a. source b. weighted c. spanning d. minimal

b. weighted

In a graph G, if the edges connecting two vertices have weights assigned to them, the graph is called a ____ graph. a. source b. weighted c. spanning d. minimal

a. immediate

In a graph directed G, for each vertex, v, the vertices adjacent to v are called ____ successors. a. immediate b. adjacent c. path d. parallel

head

In a linked list, the address of the first node in the list is stored in a separate location, called the ____ or first. Group of answer choices head pointer front top

more than one other node, plus the previous node in sequence

In a non-linear linked list, a node can point to Group of answer choices only the next node in sequence only the previous node in sequence more than one other node, plus the previous node in sequence all of the other nodes in the list None of these

waiting

In a queuing system, every customer has a customer number, arrival time, ____________________ time, transaction time, and departure time.

catch(...){ }

In a sequence of try/catch blocks, the last catch block of that sequence should be ____. Group of answer choices catch(...){ } catch(int x){ } catch(str){ } catch(exception){}

c. directed

In a(n) ____ graph, the edges are drawn using arrows. a. pointed b. vector c. directed d. undirected

c. directed

In a(n) _____ graph, the edges are drawn using arrows. a. pointed b. vector c. directed d. undirected

structured data type

In a(n) ____________________ data type, each data item is a collection of other data items.

ANSWER: directed

In a(n) ____________________ graph, the tail of a pictorial directed edge is the origin, and the head is the destination.

Inorder

In a(n) ____________________ traversal, the binary tree is traversed as follows: 1. Traverse the left subtree 2. Visit the node 3. Traverse the right subtree

inorder

In a(n) ____________________ traversal, the binary tree is traversed as follows: 1. Traverse the left subtree 2. Visit the node 3. Traverse the right subtree

preorder

In a(n) ____________________ traversal, the binary tree is traversed as follows: 1. Visit the node. 2. Traverse the left subtree. 3. Traverse the right subtree.

breadth first

In addition to the inorder, preorder, and postorder traversals, a binary tree can also be traversed level-by-level, which is also known as ____________________ traversal.

False

Output will be the same if you use InOrder, PostOrder, or PreOrder traversals of the same binary tree. Group of answer choices True/False

underflow

Popping an element from an empty stack is called ____. Group of answer choices overflow underflow exception overloading

False

Postfix notation requires the use of parenthesis to enforce operator precedence.

____________________ algorithm builds the tree iteratively by adding edges until a minimal spanning tree is obtained.

Prim's

static

Queues that are implemented as arrays are called ________ queues.

indirectly

Suppose that function A calls function B, function B calls function C, function C calls function D, and function D calls function A. Function A is then ____________________ recursive.

Terminate the program. ?

Suppose you have written a program that inputs data from a file. If the input file does not exist when the program executes, then you should choose which option? Group of answer choices Terminate the program. Include code in the program to recover from the exception. Log the error and continue. Include code in the header file.

True

T/F A binary tree has no cycles.

True

T/F A graph might have cycles; therefore, and we might not be able to traverse the entire graph from a single vertex (for example, if the graph is not connected)

True

T/F A simple path is a path in which all vertices, except possibly the first and last vertices, are distinct.

False

T/F In a directed graph, the pairs (u, v) and (v, u) represent the same edge.

True

T/F It is possible to design Prim's algortihm so that it is of the order O(n^2)

False

T/F Linked lists cannot be used to implement an adjacency list.

False

T/F The depth first traversal is similar to the postorder traversal of a binary tree.

False

T/F The implementation of a breadth first graph traversal uses a stack.

True

T/F The two most common graph traversal algorithms are depth first traversal and breadth first traversal.

Falseq

T/F We can always traverse an entire graph from a single vertex.

TRUE

T/F: the average time for ins/search grows with N/M = L (N - number of items, M - number of slots, L - load factor)

TRUE

T/F: the higher the number of buckets, the higher the needed memory

TRUE

T/F: the higher the number of buckets, the lower the collisions

True

T/F? Every call to a recursive function requires the system to allocate memory for the local variables and formal parameters.

True

T/F? In a recursive function, the base case stops the recursion.

False, 7 moves?

T/F? In the Tower of Hanoi recursive program, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is 8.

False, they run until the computer runs out of memory.

T/F? Infinite recursions execute forever on a computer.

True

T/F? The following is a valid recursive definition to determine the factorial of a non-negative integer. 0! = 1 1! = 1 n! = n * (n - 1)! if n > 0

True

T/F? The following is an example of a recursive function. void print(int x) { if (x > 0) { cout << x << " " ; print (x - 1); } }

True

T/F? To design a recursive function, you must determine the limiting conditions.

False, the general case must be reduced to a base case.

T/F? With recursion, the base case must eventually be reduced to a general case.

True

T/F? You can use a recursive algorithm to find the largest element in an array.

False

T/F? The following is an example of a recursive function, where nextNum is a function such that nextNum(x) = x + 1. int recFunc(int x) { return nextNum(nextNum(x)); }

fourth

The ____________________ Fibonacci number in a sequence is the sum of the second and third Fibonacci numbers.

ANSWER: shortest path

The ____________________ algorithm gives the shortest distance for a given node to every other node in the graph.

copy

The ____________________ constructor executes when an object is declared and initialized using another object.

depth ?

The ____________________ of a path in a binary tree is the number of branches on that path.

assignment

The ____________________ operator causes a member-wise copy of the member variables of the class.

ANSWER: breadth first breadth-first

The ____________________ traversal of a graph is similar to traversing a binary tree level by level.

data value of a pointer

The actual data type of the value of all pointers, whether integer, float, character, or otherwise, is the same, a long hexadecimal number that represents a memory address.

top

The addition and deletion of elements of a stack occurs only at the ______ of the stack.

a node can be inserted or removed faster from a linked list than from a vector

The advantage a linked list has over a vector is that Group of answer choices a linked list can dynamically shrink or grow and a vector cannot a linked list is smaller than a vector a node can be inserted or removed faster from a linked list than from a vector data removal and insertion are more accurate with a linked list than with a vector None of these

True

The associativity of the operator = is from right to left. Group of answer choices True/False

True

The binary tree structure is called a "tree" because it resembles an upside-down tree. Group of answer choices True/False

False

The bottom element of the stack is the last element added to the stack.

runtime_error

The class ____ is designed to deal with errors that can be detected only during program execution. Group of answer choices

data encapsulation

The combining of data and related operations is called __________________

True

The constructors of a derived class can (directly) initialize only the (public data) members inherited from the base class of the derived class. Group of answer choices True/False

True

The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared.

True

The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared. Group of answer choices True/False

True

The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared. True/False

False

The depth first traversal is similar to the postorder traversal of a binary tree. a. True b. False

b. weight

The edges connecting two vertices can be assigned a non-negative real number, called the ____ of the edge. a. key b. weight c. width d. height

b. weight

The edges connecting two verticies can be assigned a non-negative real number, called the _____ of the edge. a. key b. weight c. width d. height

bottom

The elements at the ____________________ of the stack have been in the stack the longest.

False

The expression a + b is the same in both infix notation and postfix notation.

True

The first item placed onto a stack is always the last item removed from the stack. Group of answer choices True/False

ab- cd +*

The following expression (a - b) * (c + d) is equivalent to which of the following postfix expression?

a new stack of integers, implemented as a vector

The following statement stack< int, vector <int> > iStack; indicates:

​range-based

The form of the for loop shown below is called a(n) ____________________ for loop. for (dataType identifier : arrayName) statements

assert

The function ____ can check whether an expression meets the required conditions; if the conditions are not met, it terminates the program. Group of answer choices check look assert what

what

The function ____ returns a string containing an appropriate message. Group of answer choices where what when log

->

The function that overloads the ____ operator for a class must be declared as a member of the class. Group of answer choices :: * -> +

type *var-name; int *ip; // pointer to an integer double *dp; // pointer to a double float *fp; // pointer to a float char *ch // pointer to character

The general form of a pointer variable declaration is −

const

The general form of the functions to overload the binary operators as member functions of a class is returnType operator#(____ className&) const; a. & b. class c. const d. *

const className& operator=(const className&);

The general syntax for the function prototype to overload the assignment operator = for a class is ____. Group of answer choices friend className& operator=(const className&); className& operator=(className&); string className& operator=(className&); const className& operator=(const className&);

friend istream& operator>>(istream&, className&);

The general syntax to overload the stream extraction operator >> for a class is ____. a. istream& operator>>(istream&, className&); b. friend istream& operator>>(istream&, className&); c. const istream& operator>>(istream&, className&); d. friend operator>>(istream&, className&);

tree pointer

The head pointer, anchored at the top of a binary tree, may be called the Group of answer choices root node tree pointer binary pointer leaf pointer node pointer

interface file

The header file is also known as the ____________________.

False

The heading of a try block can contain ellipses in place of a parameter. Group of answer choices True/False

True

The height of a tree describes how many levels there are in the tree. Group of answer choices True/False

#ifndef

The preprocessor directive ____________________ is used to prevent multiple inclusions of a header file in a program.

traversing

The process of stepping through the nodes of a binary tree is known as Group of answer choices climbing traversing stepping through branching out None of these

False

The programmer must declare in advance the size of a dynamic stack or queue. T/F

an endless loop

The programmer must ensure that a recursive function does NOT become Group of answer choices a static function a virtual function an endless loop a dynamic function None of these

an endless loop

The programmer must ensure that a recursive function does not become:

False

The public members of a class must be declared before the private members. Group of answer choices True/False

managing the order of print jobs, communications software, operating systems

The queue data structure is commonly applied in connection with:

base case

The recursive algorithm must have one or more base cases, and the general solution must eventually be reduced to a(n) ____________________.

zero

The recursive factorial function calculates the factorial of its parameter. Its base case is when the parameter is ________.

bool

The return type of the function operator == is ____. a. void b. int c. char d. bool

istream

The return type of the function to overload the operator >> must be a reference to a(n) ____ object. a. istream b. ostream c. stream d. iostream

true

The search function searches the binary search tree for a given item. If the item is found in the binary search tree, it returns ____. Group of answer choices true false a reference to the node where the item was found 1

determined by the order in which values are inserted

The shape of a binary tree is Group of answer choices always triangular always balanced determined by the programmer determined by the order in which values are inserted None of these

c. greedy

The shortest path algorithm is also called the ___ algorithm. a. recursive b. minimal c. greedy d. spanning

c. greedy

The shortest path algorithm is also called the ____ algorithm. a. recursive b. minimal c. greedy d. spanning

d. Dijkstra

The shortest path algorithm was developed by ____. a. Euler b. Kruskal c. Prim d. Dijkstra

d. Dijkstra

The shortest path algorithm was developed by ______, a. Euler b. Kruskal c. Prim d. Dijkstra

c. weight

The shortest path is the path with the smallest ____. a. length b. index c. weight d. key

c. weight

The shortest path is the path with the smallest ______. a. length b. index c. weight d. key

ANSWER: source

The starting vertex of a shortest path in a graph is called the ____________________.

*board[6]

The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;

The following function should swap the values contained in two integer variables, num1 and num2. What, if anything, is wrong with this function? void swap(int num1, int num2) { int temp = num2; num2 = num1; num1 = temp; } a. You must first initalize temp to 0 before using it. b. The variable temp should first be set to num1, not num2. c. The swap function must use reference parameters. d. The last line should be temp = num1. e. Nothing is wrong with this function.

The swap function must use reference parameters

.memberName

The syntax for accessing a struct member is structVariableName____. Group of answer choices .memberName *memberName [memberName] $memberName

inorder, preorder, postorder

The three traversal algorithms discussed for binary trees are ____, ____, and ____. Group of answer choices order, preorder, postorder in, preorder, order order, preorder, post inorder, preorder, postorder

catch

The try block is followed by one or more ____ blocks. Group of answer choices throw finally do catch

True

The two most common graph traversal algorithms are depth first traversal and breadth first traversal. a. True b. False

True

The width of a tree is the largest number of nodes in the same level. Group of answer choices True/False

True

The width of a tree is the largest number of nodes in the same level. True/False

deque

This is a container that provides quick access to elements at the front and the back of the list.

deque

This is a double-ended queue.

is empty

Three lines at the end of an arrow in the diagram of a binary tree indicate that the subtree ____. Group of answer choices has three branches has three children is full is empty

throw

Throwing an exception is typically done using the ____________________ statement.

True

To access a structure member (component), you use the struct variable name together with the member name; these names are separated by a dot (period). Group of answer choices True/False

member-wise

To compare struct variables, you compare them ____. Group of answer choices by reference by value index-wise member-wise

True

To delete an entire list, normally you must traverse the list, deleting each node, one by one. Group of answer choices True/False

True

To delete an item from the binary search tree, you must do the following: 1. Find the node containing the item (if any) to be deleted. 2. Delete the node. Group of answer choices True False

customer

To describe a queuing system, we use the term ____ for the object receiving the service. Group of answer choices receiver server customer provider

server

To describe a queuing system, we use the term ____ for the object that provides the service. Group of answer choices client server customer provider

constructors

To guarantee that the member variables of a class are initialized, you use ____. Group of answer choices accessors mutators constructors destructor

friend

To include the operator function operator+ as a nonmember function of the class rectangleType, its prototype in the definition of rectangleType is: ____ rectangleType operator+(const rectangleType&, const rectangleType&); a. bool b. friend c. double d. int

arranged in ascending order

To insert a new node in ascending order into a list, the list must be Group of answer choices arranged in descending order randomly ordered empty arranged in ascending order None of these

no

To overload the pre-increment (++) operator for a class, if the operator function is a member of that class, it must have ____ parameter(s).

False

To remove a node that has children, you must first remove the children. Group of answer choices True/False

indirect

Tracing through ____ recursion is more tedious than tracing other recursive forms.

A graph might have cycles; therefore, we might not be able to traverse the entire graph from a single vertex. Group of answer choices True/False

True

A queue is a First In First Out data structure.

True

A selection sort and a binary search can be applied to STL vectors as well as arrays.

True

All components of an array are of the same data type. Group of answer choices True/False

True

For a compiler that is older than C++11 it is necessary to put spaces between the angled brackets that appear next to each other when defining a stack. Group of answer choices True/False

True

If you are using the bubble sort algorithm to sort an array in descending order, the smaller values move toward the end.

True

In a recursive function, the base case stops the recursion.

True

In protected inheritance, public and protected members of the base class become the protected members of the derived class. Group of answer choices True/False

True

Most operator functions can either be member functions or nonmember functions of a class. Group of answer choices True/False

True

On average, an item is just as likely to be found near the beginning of an array as near the end.

True

Stacks and queues can be implemented as arrays or linked lists. Group of answer choices True/False

True

T/F During the sorting phase of insertion sort, the array containing the list is divided into two sublists, sorted and unsorted

True

T/F Suppose that L is a sorted list of size 1024, and we want to determine whether an item x is in L. From the binary search algorithm, it follows that every iteration of he while loop cuts the size of the search list by half

True

T/F The binary search algorithm can be written iteratively or recursively

True

T/F The selection sort algorithm finds the location of the smallest element in the unsorted portion of the list.

True

T/F The sequential search algorithm does not require that the list be sorted.

True

The associativity of the operator = is from right to left. Group of answer choices True/False

True

The constructors of a derived class can (directly) initialize only the (public data) members inherited from the base class of the derived class. Group of answer choices True/False

True

The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared.

True

The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared. Group of answer choices True/False

True

The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared. True/False

True

The first item placed onto a stack is always the last item removed from the stack. Group of answer choices True/False

True

The following is a valid recursive definition to determine the factorial of a non-negative integer. 0! = 1 1! = 1 n! = n * (n - 1)! if n > 0

True

The following is an example of a recursive function. void print(int x) { if (x > 0) { cout << x << " " ; print (x - 1); } }

True

The infix expression (a + b) * (c - d / e) + f is equivalent to the postfix expression ab+ cde /-* f+

True

The number of comparisons made by a binary search is expressed in powers of two.

True

The two most common graph traversal algorithms are depth first traversal and breadth first traversal. Group of answer choices True/False

True

To access a structure member (component), you use the struct variable name together with the member name; these names are separated by a dot (period). Group of answer choices True/False

True

To design a recursive function, you must determine the limiting conditions.

True

You can use a recursive algorithm to find the largest element in an array.

True

Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference. Group of answer choices True/False

True ?

false

True/False: A recursive function cannot call another function.

true

True/False: Any algorithm that can be coded with recursion can also be coded with an iterative structure.

True

True/False: Like a loop, a recursive function must have some method to control the number of times it repeats.

True

True/False: Recursive algorithms are less efficient than iterative algorithms.

True

True/False: The speed and amount of memory available to modern computers diminishes the performance impact of recursion so much that inefficiency is no longer a strong argument against it.

False

True/False: When recursion is used on a linked list, it will always display the contents of the list in reverse order.

12, 81

What is the output of the following code? int *p; int x; x = 12; p = &x; cout << x << ", "; *p = 81; cout << *p << endl; Group of answer choices 12, 12 12, 81 81, 12

x = 2; y = 3;

What is the output of the following code? queueType<int> queue; int x, y; x = 2; y = 3; queue.addQueue(x); queue.addQueue(y); x = queue.front( ); queue.deleteQueue( ); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); y = queue.front( ); queue.deleteQueue( ); cout << "x = " << x << endl; cout << "y = " << y << endl;

True

When working with a linked list one of the basic operations you can perform is to destroy the list. Group of answer choices True/False

False

When writing the definition of a friend function, the name of the class and the scope resolution operator precede the name of the friend function in the function heading. Group of answer choices True/False

False

When you build a linked list in the backward manner, a new node is always inserted at the end of the linked list. Group of answer choices True/False

True

When you delete a node from a list, you must ensure that the links in the list are not permanently broken. Group of answer choices True/False

another pointer

When you dereference a pointer to a pointer, the result is Group of answer choices a value of the data type that is pointed to another pointer not possible to determine a null pointer None of these

The preprocessor directive ____________________ is used to prevent multiple inclusions of a header file in a program.

#ifndef

recursive

A ________ function is one that calls itself

queue

A ________ is processed in a manner similar to customers standing in a grocery check-out line—the first customer in line is the first served.

dynamic

A ________ stack or queue is built around the linked-list.

pointer

A ____________ is a variable whose value is the address of another variable you can work with it.. Like any variable or constant, you must declare a pointer before

pointer

A ____________ is a variable whose value is the address of another variable. Like any variable or constant, you must declare a pointer before you can work with it.

class

A ___________________ is a templete in accordance to which objets are created.

two pointers, one for the left child and one for the right child

A binary tree can be created using a struct or class containing a data value and Group of answer choices a pointer to the first child node a pointer to the last child node two pointers, one for the left child and one for the right child two data nodes None of these

a. simple

A graph is called a(n) ____ graph if it has no loops and no parallel edges. a. simple b. undirected c. directed d. weighted

a. simple

A graph is called a(n) ____ graph if it has no loops and no parallel edges. a. simple b. undirected c. directed d. weighted

True

A graph might have cycles; therefore, we might not be able to traverse the entire graph from a single vertex. a. True b. False

Increment

Which of the following arithmetic operations is allowed on pointer variables? Group of answer choices Increment Modulus Multiplication Division

True

You can use an assignment statement to copy the contents of one struct into another struct of the same type. Group of answer choices True/False

Iterative

____ control structures use a looping structure, such as while, for, or do...while, to repeat a set of statements.

dynamic, static

________ queues are more intuitive and easier to understand than ________ queues.

What does & do

___________ denotes a reference instead of a pointer to an object

ANSWER: Prim's

____________________ algorithm builds the tree iteratively by adding edges until a minimal spanning tree is obtained.

With the binary search algorithm, ____ key comparison(s) is/are made in the successful case---the last time through the loop. a. one b. two c. n-2 d. n

a. one

After the second iteration of bubble sort for a list of length n, the last ____ elements are sorted. a. two b. three c. n-2 d. n

a. two

The following expression (a - b) * (c + d) is equivalent to which of the following postfix expression?

ab- cd +*

A queue is a data structure in which the elements are ________.

added to the rear and deleted from the front

The ____ operator can be used to return the address of a private data member of a class. Group of answer choices dereferencing destructor address of member access

address of

A stack can be adapted to store ________ data types.

all

A stack can be adapted to store ________ data types. Group of answer choices all only built-in C++ only abstract deque-like None of these

all

In the average case, sequential search typically searches ____. a. one quarter of the list b. one third of the list c. one half of the list d. the entire list

c. one half of the list

A(n) ____________________ block specifies the type of exception it can catch and contains an exception handler.

catch

The try block is followed by one or more ____ blocks. Group of answer choices throw finally do catch

catch

1. computing hash code 2. collision handling

challenges faced in hashing

A static queue can be implemented as a ________.

circular array

Which of the following class definitions makes the public members of the class aClass become the public members of the class bClass? Group of answer choices class aClass: public bClass{ //... }; class bClass: public aClass{ //... }; class bClass: aClass{ //... }; class aClass: bClass{ //... };

class bClass: public aClass{ //... };

Which of the following statements creates a new exception class? Group of answer choices class myClass {}; class myClass {} implements exception; class myExceptionClass {} extends exception; class myExceptionClass {} throws exception;

class myClass {};

the destructor function

A linked list class must take care of removing the dynamically allocated nodes and this is done by Group of answer choices the constructor function the destructor function overriding the removal function overloading the memory persistence operator None of these

False

A list that contains pointers to the previous node, the next node, and a node in the third dimension is known as a triple linked list. Group of answer choices True/False

d. component

A maximal subset of connected vertices is called a ____ of G. a. cycle b. union c. subset d. component

d. component

A maximal subset of connected verticies is called a ____ of G. a. cycle b. union c. subset d. component

c. weight

A minimal spanning tree of G is a spanning tree with the minimum ____. a. path b. cycle c. weight d. height

c. weight

A minimal spanning tree of G is a spanning tree with the minimum ______ a. path b. cycle c. weight d. height

leaf

A node in a binary tree is called a(n) ____ if it has no left and right children. Group of answer choices edge branch leaf path

c. leaf node

A node that has no children is a a. root node b. head node c. leaf node d. pure binary node e. None of these

a variable whose content is a memory address

A pointer variable

storage of local variables tracking nested loops tracking nested function calls

A practical application of the stack data type in a computer system is:

True

A problem can be solved with recursion if it can be broken down into successive smaller problems that are the same as the overall problem. Group of answer choices True/False

client

A program or software that uses and manipulates the objects of a class is called a(n) ____________________ of that class.

True

A queue is a First In First Out data structure.

added to the rear and deleted from the front

A queue is a data structure in which the elements are ________.

first in, first out

A queue is a data structure that stores and retrieves item in the ________ manner. Group of answer choices last in, first out first in, last out first in, first out random None of these

first in, first out

A queue is a data structure that stores and retrieves items in this manner.

False

A real-world example of the queue data structure can be seen in a stack of cafeteria trays where the last tray pushed onto the stack is the first tray removed. T/F

False

A recursive function cannot call another function. Group of answer choices True/False

tail

A recursive function in which the last statement executed is the recursive call is called a(n) ____ recursive function.

base case

A recursive function is designed to terminate when it reaches its ________.

True

A selection sort and a binary search can be applied to STL vectors as well as arrays. True False

exception

A(n) ____ is an occurrence of an undesirable situation that can be detected during program execution. Group of answer choices crash exception misfire bug

b. free

A(n) ____ tree T is a simple graph such that if u and v are two vertices in T, a unique path exists from u to v. a. rooted b. free c. spanning d. weighted

b. free

A(n) ____ tree T is a simple graph such that if u and v are two vertices in T, a unique path exists from u to v. a. rooted b. free c. spanning d. weighted

stack

A(n) ________ is an abstract data type that stores and retrieves items in a last-in-first-out manner.

catch

A(n) ____________________ block specifies the type of exception it can catch and contains an exception handler.

conversion

A(n) ____________________ constructor converts its argument to an object of the constructor's class.

set

A(n) ____________________ is a collection of distinct elements of the same type.

doubly

A(n) ____________________ linked list is a linked list in which every node has a next pointer and a back pointer.

ANSWER: breadth first breadth-first

A(n) ____________________ ordering of the vertices of the accompanying graph is 0, 1, 3, 4, 2, 5, 7, 8, 6, 9.

ANSWER: depth first depth-first

A(n) ____________________ ordering of the vertices of the accompanying graph is 0, 1, 4, 3, 2, 5, 7, 8, 6, 9.

distribution

A(n) ____________________ returns random numbers whose likelihoods correspond to a specific shape such as uniform or normal.

stack

A(n)_____ is a list of homogeneous elements in which the addition and deletion of elements occurs only at one end.

The behavior of quick sort is ___ in the worst case and ___ in the average case. a. O(nlog2n), O(nlog2n) b. O(n^2), O(n) c. O(nlog2n), O(n^2) d. O(n^2), O(nlog2n)

d. O(n^2), O(nlog2n)

Two primary queue operations are:

enqueue and dequeue

A(n) ____________________ returns random numbers whose likelihoods correspond to a specific shape such as uniform or normal.

distribution

The quick sort algorithm uses the _______ technique to sort a list.

divide and conquer

A ________ stack or queue is built around the linked-list.

dynamic

A dynamic queue can be implemented as a ________.

dynamic linked list

________ queues are more intuitive and easier to understand than ________ queues.

dynamic, static

A(n) ____ is an occurrence of an undesirable situation that can be detected during program execution. Group of answer choices crash exception misfire bug

exception

True

After deleting the desired item from a binary search tree, the resulting tree must be a binary search tree. Group of answer choices True/False

c) 0 1 1 2 2 3

After the following statements execute, what are the contents of matrix? int matrix[3][2]; int j, k; for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) matrix[j][k] = j + k; Group of answer choices a) 0 0 1 1 2 2 b) 0 1 2 3 4 5 c) 0 1 1 2 2 3 d) 1 1 2 2 3 3

False

All binary tree traversals start at the left-most child node. Group of answer choices True/False

False

All binary tree traversals start at the left-most child node. Group of answer choices True/False

True

All components of an array are of the same data type. Group of answer choices True/False

what

All derived classes of the class exception override the function ____________________ to issue their own error messages.

False

All mathematical problems are designed to be more efficient using recursive solutions. Group of answer choices True/False

a null pointer

All node pointers that do NOT point to other nodes are set to Group of answer choices the root of the tree a parent node their leftmost child node a null pointer None of these

True

All nodes to the right of a node hold values greater than that node's value. Group of answer choices True/False

object

An _____________ is an instance of a class, an entity created using a class definition.

d. loop

An edge incident on a single vertex is called a(n) ____. a. block b. cycle c. component d. loop

d. loop

An edge incident on a single vertex is called a(n) _________. a. block b. cycle c. component d. loop

abstract data type

An item specified in terms of operations is called an ?

False

An object that is being thrown cannot be an anonymous object. Group of answer choices True/False

operator

Any function that overloads an operator is called a(n) ____________________ function.

inserting

Appending a node means adding it to the end of a list, and ________ a node means putting a new node in the list, but not necessarily at the end. Group of answer choices concatenating popping clamping inserting None of these

True ?

Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference. Group of answer choices True/False

False

As parameters to a function, class objects can be passed by reference only. Group of answer choices True/False

Which of the following is an allowable aggregate operation on a struct? Group of answer choices Arithmetic Assignment Input/output Comparison

Assignment

A queue is a data structure that stores and retrieves item in the ________ manner. Group of answer choices last in, first out first in, last out first in, first out random None of these

first in, first out

A queue is a data structure that stores and retrieves items in this manner.

first in, first out

Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series.

first, last

Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series. Group of answer choices last, first first, last efficiently, first efficiently, last None of these

first, last

Static stacks have a ________ size and are implemented as ________. Group of answer choices fixed, linked lists variable, arrays fixed, arrays variable, linked lists None of these

fixed, arrays

Static stacks have a ________ size, and are implemented as ________.

fixed, arrays

40

Assume the key of the left child below the root node of a binary search tree is 30. The value in the root node could be ____. Group of answer choices 0 10 30 40

0 through 999

Assume you have the following declaration double salesData[1000];. Which of the following ranges is valid for the index of the array salesData? Group of answer choices 0 through 999 0 through 1000 1 through 1001 1 through 1000

class or struct

Because each node of a linked list has two components, we need to declare each node as a(n) ____. Group of answer choices reference and string int and object index and element class or struct

False

Before you can perform a bubble sort, the data must be stored in descending order. Group of answer choices True/False

A(n) ____ function is a nonmember function that has access to all members of the class. Group of answer choices access protected friend void

friend

Data that is to be sorted in ascending order is ordered a. from lowest value to highest value b. from highest value to lowest value c. with a binary search algorithm d. by identifying the middle value and going up and down from there e. None of these

from lowest to highest value

In a dequeue operation, the element at the ________ of the queue is removed.

front

When an element is added to a queue, it is added to the rear. When an element is removed from the queue, it is removed from the rear middle front depends on how the programmer writes the code None of these

front

When an element is added to a queue, it is added to the rear. When an element is removed, it is removed from the ________.

front

Let f and g be real-valued functions. Assume that f and g are nonnegative, that is, for all real numbers n, f(n) <= 0 and g(n) >= 0. We say that f(n) is ________ of g(n), written f(n) = O(g(n)), if there exist positive constants c and n0 such that f(n) <= cg(n) for all n >= n0

Big-O

True

Binary trees are commonly used to organize key values that index database records. Group of answer choices True/False

subtrees

Binary trees can be divided into Group of answer choices branches leaves subtrees sawdust None of these

True

Deleting a leaf node from a binary tree is not difficult but deleting a non-leaf node requires several steps. Group of answer choices True/False

If you try to add a new item to a full stack, the resulting condition is called a(n) ____. Group of answer choices override overflow overload underflow

overflow

In a quick sort, all of the sorting work is done by the function ________

partition

A sequence of branches in a comparison tree is called a(n) _______

path

The first step in the quick sort partition algorithm is to determine the _____ and swap it with the first element in the list.

pivot

The ________ operation allows an item to be removed from a stack.

pop

You can perform the operation ____ to remove the top element from the stack. Group of answer choices dequeue top pop push

pop

The ________ operation allows an item to be stored on a stack.

push

You can perform the add operation, called _____, to add an element onto the stack.

push

A stack has two primary operations:

push, pop

A ________ is processed in a manner similar to customers standing in a grocery check-out line—the first customer in line is the first served.

queue

A container that provides quick access to elements at the front and the back of the list is a Group of answer choices stack queue deque All of these None of these

queue

If data is transmitted faster than it can be processed, it can be held in a ________ for processing.

queue

If data is transmitted faster than it can be processed, it can be held in a ________ for processing. Group of answer choices stack queue static array static deque None of these

queue

The form of the for loop shown below is called a(n) ____________________ for loop. for (dataType identifier : arrayName) statements ​

range-based

The following is the pseudocode for which type of algorithm? For start = each array subscript, from the first to the next-to-last minIndex = start minValue = array[start] For index = start + 1 To size - 1 If array[index] < minValue minValue = array[index] minIndex = index End If End For swap array[minIndex] with array[start] End For a. bubble sort b. binary sort c. bubble search d. selection sort e. None of these

selection sort

For a list of length n, the ____________________ sort makes exactly (n(n - 1))/2 key comparisons and 3(n - 1) item assignments.

selection

The __________ sort usually performs fewer exchanges than the __________ sort. a. bubble, selection b. binary, linear c. selection, bubble d. ANSI, ASCII e. None of these

selection, bubble

The ____________________ algorithm gives the shortest distance for a given node to every other node in the graph.

shortest path

A graph is called a(n) ____ graph if it has no loops and no parallel edges. Group of answer choices simple undirected directed weighted

simple

The advantage of a linear search is its a. complexity b. efficiency c. simplicity d. speed e. None of these

simplicity

Array elements must __________ before a binary search can be performed. a. summed b. set to zero c. positive integers d. sorted e. None of these

sorted

Algorithms used to arrange random data in some order are __________ algorithms. a. standard search b. sorting c. linear d. binary search e. None of these

sorting

A tree T is called a(n) ____ tree of graph G if T is a subgraph of G such that V(T) = V(G); that is, if all vertices of G are in T. Group of answer choices weighted spanning rooted directed

spanning

A(n) ____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end. Group of answer choices stack queue array linked list

stack

A(n) ________ is an abstract data type that stores and retrieves items in a last-in-first-out manner.

stack

A(n)_____ is a list of homogeneous elements in which the addition and deletion of elements occurs only at one end.

stack

Select all that apply. Data structures that can dynamically store elements and can grow and shrink in size are Group of answer choices stacks arrays queues deques

stacks deques

Data structures that can dynamically store elements and can grow and shrink in size are:

stacks, queues, deques

Queues that are implemented as arrays are called ________ queues.

static

A practical application of the stack data type in a computer system is:

storage of local variables tracking nested loops tracking nested function calls

Select all that apply. A practical application of the stack data type in a computer system is Group of answer choices storage of local variables tracking nested loops tracking nested function calls None of these

storage of local variables tracking nested loops tracking nested function calls

var = 20; // actual variable declaration. int *ip; // pointer variable ip = &var; - Does what ? _________________________________________

store address of var in pointer variableint

All of these

Deleting a node that has two children offers an opportunity to use Group of answer choices a function that returns a pointer to a pointer a function parameter that is a pointer to a pointer double indirection All of these None of these

True

Dereferencing a pointer to a pointer gives you another pointer. True/False

True ?

Duplicates are allowed in a binary search tree. Group of answer choices True/False

child

Each link in a binary tree node points to a(n) ____ of that node. Group of answer choices parent child value sibling

two

Every node in a binary tree has at most ____ children. Group of answer choices one two three four

back; next

Every node in a doubly linked list has two pointers: ____ and ____. Group of answer choices top; bottom back; next current; forward previous; forward

A catch block specifies the type of exception it can catch and immediately terminates the program. Group of answer choices True/False

False

A linear search can only be implemented with integer values.

False

A real-world example of the queue data structure can be seen in a stack of cafeteria trays where the last tray pushed onto the stack is the first tray removed. T/F

False

An exception is an occurrence of an undesirable situation that can be detected during program compilation. Group of answer choices True/False

False

An object that is being thrown cannot be an anonymous object. Group of answer choices True/False

False

As parameters to a function, class objects can be passed by reference only. Group of answer choices True/False

False

Before you can perform a bubble sort, the data must be stored in descending order.

False

Before you can perform a selection sort, the data must be stored in ascending order.

False

If an object is created in a user program, then the object can access both the public and private members of the class. Group of answer choices True/False

False

If you try to add a new item to a full stack, the resulting conditions is called an outflow.

False

In C++, pointer variables are declared using the reserved word pointer. Group of answer choices True/False

False

In the Tower of Hanoi recursive program, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is 8.

False

In the linked implementation of stacks, the memory to store the stack elements is allocated statically.

False

In the linked implementation of stacks, the memory to store the stack elements is allocated statically. Group of answer choices True False

False

In the linked implementation of stacks, the memory to store the stack elements is allocated statically. T/F

False

In the statementint* p, q;p and q are pointer variables. Group of answer choices True False

False

Operator functions typically return void. Group of answer choices True/False

False

Postfix notation requires the use of parenthesis to enforce operator precedence.

False

Relational operations can be used on struct variables. Group of answer choices True/False

False

T/F During the second iteration of a selection sort, the smallest item is moved to the top of the list

False

T/F If n = 1000, then to sort the list, selection sort, the smallest item is moved to the top of the list

False

T/F In a binary search, first, the search item is compared with the last element of the list

False

T/F In a bubble sort, the smaller elements move toward the bottom, and the larger elements move toward the top of the list.

False

T/F The swap function of quick sort is written differently from the swap function for selection sort.

False

The bottom element of the stack is the last element added to the stack.

False

The bubble sort is an easy way to arrange data in ascending order but it cannot arrange data in descending order.

False

The expression a + b is the same in both infix notation and postfix notation.

False

The following is an example of a recursive function, where nextNum is a function such that nextNum(x) = x + 1. int recFunc(int x) { return nextNum(nextNum(x)); }

False

The heading of a try block can contain ellipses in place of a parameter. Group of answer choices True/False

False

The linear search repeatedly divides the portion of an array being searched in half.

False

The programmer must declare in advance the size of a dynamic stack or queue. T/F

False

The public members of a class must be declared before the private members. Group of answer choices True/False

False

We can always traverse an entire graph from a single vertex. Group of answer choices True/False

False

When the program knows the exact contents of a list and can access any element on demand, the data structure is known as a stacked deque. Group of answer choices True/False

False

When writing the definition of a friend function, the name of the class and the scope resolution operator precede the name of the friend function in the function heading. Group of answer choices True/False

False

You are more likely to find an item by using a binary search than by using a linear search.

False

1. it can only represent a finite set of elements without collisions 2. coming up with a good hash function is non trivial (not easy) 3. only useful for search() and insert() operations alone as it does not create order

what are the limitations of hashing?

1. index with collisions can be treated as linked lists, instead of storing T/F in each index, store the data as list types instead

what are the ways of handling collision?

returns which bucket item x is located

what does bucket(item x) do?

returns the number of buckets

what does bucket_count() do?

returns the load factor

what does load_factor() do?

value of item changes from false to true

what happens when a data is inserted in a data indexed integer set?

an infinite number of times

How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n + 1); } }

value

If a class object is passed by ____________________, the contents of the member variables of the actual parameter are copied into the corresponding member variables of the formal parameter.

indirectly

If a function A calls a function B and function B calls function A, then function A is ____________________ recursive.

uses up all available stack memory, causing the program to crash

If a recursive function does not contain a base case, it ________.

reference

If a variable is passed by ____________________, then when the formal parameter changes, the actual parameter also changes.

False

If an object is created in a user program, then the object can access both the public and private members of the class. Group of answer choices True/False

queue

If data is transmitted faster than it can be processed, it can be held in a ________ for processing.

1. verify if value of index is True 2. if ambiguous, verify if linked list contains desired data

what happens when you search a data in a data indexed integer set?

when two or more data have the same hash code

what is collision?

items with the same hash code are stored as list types (array, linked lists, etc)

what is external chaining?

it is the conversion of an arbitrary data into an integer

what is hashing?

O(1)

what is the (best) complexity of insertion using hashing?

O(1)

what is the (best) complexity of search using hashing?

O(Q)

what is the complexity of insertion and search in external chaining given a maximum chain length of Q?

more than O(1)

what is the complexity of searching in a data indexed integer set with ambiguity?

hash table

what is the data structure used in hashing?

if the number of items is greater than the number of slots, then multiple items have the same hash code

what is the pigeonhole principle?

1. minimizes ambiguity 2. requires a bit of randomness

what makes a good hash code?

queue

If data is transmitted faster than it can be processed, it can be held in a ________ for processing. Group of answer choices stack queue static array static deque None of these

infinite

If every recursive call results in another recursive call, then the recursive function (algorithm) is said to have ____ recursion.

overloaded

If the corresponding functions in the base class and the derived class have the same name but different sets of parameters, then this function is ____ in the derived class.

classB::functionName();

If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class, you use the statement ____. Group of answer choices classD::functionName(); classB::functionName(); classD.functionName(); classB.functionName();

b. directed

If the elements of E(G) are ordered pairs, G is called a(n) ____ graph. a. undirected b. directed c. weighted d. spanning

b. directed

If the elements of E(G) are ordered pairs, G is called a(n) _____ graph. a. undirected b. directed c. weighted d. spanning

there are no nodes in the list

If the head pointer points to nullptr, this indicates Group of answer choices the list has been previously created and then destroyed the list needs to be destroyed there are no nodes in the list the list is full and cannot accept any new nodes None of these

bad_alloc

If the operator new cannot allocate memory space, this operator throws a(n) ____________________ exception.

a. parallel

If two edges, e1 and e2, are associated with the same pair of vertices {u, v}, then e1 and e2 are called ____ edges. a. parallel b. adjacent c. connected d. incident

a. parallel

If two edges, e1 and e2, are associated with the same pair of verticies {u, v} then e1 and e2 are called _____ edges. a. parallel b. adjacent c. connected d. incident

memory

If you execute an infinite recursive function on a computer, the function executes until the system runs out of ____________________.

one

If you overload the binary arithmetic operator + as a member function, how many objects must be passed as parameters?

overflow

If you try to add a new item to a full stack, the resulting condition is called a(n) ____. Group of answer choices override overflow overload underflow

False

If you try to add a new item to a full stack, the resulting conditions is called an outflow.

what

If you want to include members in your exception class, you typically include the function ____. Group of answer choices that this log what

True

In C++, any class can be considered an exception class. Tru/False

False

In C++, pointer variables are declared using the reserved word pointer. Group of answer choices True/False

.

In C++, the ____ is called the member access operator. Group of answer choices . , :: #

.(dot)

In C++, the ____ symbol is an operator, called the member access operator. Group of answer choices :(colon) .(dot) ,(comma) $ (dollar sign)

::

In C++, the scope resolution operator is ____. Group of answer choices : :: $ .

b. source

In Prim's algorithm for the minimal spanning tree, we start at a designated vertex, which we call the ____ vertex. a. index b. source c. root d. destination

b. source

In Prim's algorithm for the minimal spanning tree, we start at a designated vertex, which we call the ____ vertex. a. index b. source c. root d. destination

ANSWER: empty

A graph is ____________________ if the number of vertices is zero.

False

(T/F?) A friend function does not have access to the private data members of the class.

True

(T/F?) Both parameters of the function to overload the operator << are reference parameters.

True

(T/F?) In C++, >> is used as a stream extraction operator and as a right shift operator.

True

(T/F?) In C++, operator is a reserved word.

True

(T/F?) Most operator functions can either be member functions or nonmember functions of a class.

False

(T/F?) Operator functions typically return void.

True

(T/F?) Operators can be overloaded either for objects of the user-defined types, or for a combination of objects of the user-defined type and objects of the built-in type.

True

(T/F?) The associativity of the operator = is from right to left.

False

(T/F?) The declaration of a friend function cannot be placed within the private part of the class.

False

(T/F?) When writing the definition of a friend function, the name of the class and the scope resolution operator precede the name of the friend function in the function heading.

The function that overloads the ____ operator for a class must be declared as a member of the class. Group of answer choices :: * -> +

->

In C++, the ____ is called the member access operator. Group of answer choices . , :: #

.

In C++, the ____ symbol is an operator, called the member access operator. Group of answer choices :(colon) .(dot) ,(comma) $ (dollar sign)

.(dot)

Given the following code, assume the myQueue object is a queue that can hold integers and that value is an int variable. Assume that the dequeue function, called on line 4, stores the number removed from the queue in the value variable. What will the statement on line 5 display? Group of answer choices 0 1 2 None of these

0

In the array representation of a stack, the stack is initialized simply by setting stackTop to

0

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: cout << value << endl; Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable. What will the statement in line 5 display?

0

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: myStack.pop(value); 6: myStack.pop(value); 7: cout << value << endl; Assume that the pop function, called in line 4, 5 and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?

0

What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++) cout << list[j] << " "; cout << endl; Group of answer choices 0 1 2 3 4 0 5 10 15 0 5 10 15 20 5 10 15 20

0 5 10 15 20

Assume you have the following declaration double salesData[1000];. Which of the following ranges is valid for the index of the array salesData? Group of answer choices 0 through 999 0 through 1000 1 through 1001 1 through 1000

0 through 999

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.enqueue(3); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in line 4 and 6 stores the number removed from the queue in the value variable. What will the statement in line 7 display?

1

What is the output of the following code? int *p; int x; x = 12; p = &x; cout << x << ", "; *p = 81; cout << *p << endl; Group of answer choices 12, 12 12, 81 81, 12

12, 81

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____. 4 14 24 26

14

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ________.

14

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____. 4 14 24 26

14 ?

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.dequeue(value); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in line 4, 5 and 6 stores the number removed from the queue in the value variable. What will the statement in line 7 display?

2

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: cout << value << endl; Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable. What will the statement in line 5 display?

2

Using a linear search to find a value that is stored in the last element of an array that contains 20,000 elements, __________ elements must be compared. a. 20,000 b. only the first two c. only half d. 2,000 e. None of these

20,000

What is the output after the following code executes? int numerator = 5; int denominator = 25; int temp = 0; temp = numerator; numerator = denominator; denominator = temp; cout << numerator << "/" << denominator << " = " << (numerator/denominator) << endl; a. 5/25 = numerator/denominator b. 5/25 = 0 c. 5/25 = 0.2 d. 25/5 = 5 e. 25/5 = 25/5

25/5 = 5

int mystery(int list[], int first, int last) { if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last); } Consider the accompanying definition of the recursive function mystery. Given the declaration: int alpha[5] = {1, 4, 5, 8, 9}; what is the output of the following statement? cout << mystery(alpha, 0, 4) << endl;

27

In the case of an unsuccessful search, it can be shown that for a list of length n, a binary search makes approximately ________ key comparisons

2log2n 2logn

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: myStack.push(3); 6: myStack.pop(value); 7: cout << value << endl; Assume that the pop function, called in line 4, 5 and 6, stores the number popped from the stack in the value variable. What will the statement in line 5 display?

3

The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____. 10 30 42 44

42

The postfix expressions 5 6 + 4 * 10 5 / - = evaluates to ________.

42

int puzzle(int start, int end) { if (start > end) return start - end; else if (start == end) return start + end; else return end * puzzle(start + 1, end - 1); } Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << puzzle(3, 7) << endl;

42

What is the value of x after the following statements execute? int x = 25; int *p; p = &x; *p = 46; Group of answer choices nullptr 0 25 46

46

Consider the following definition of the recursive function mystery. int mystery(int num) { if (num <= 0) return 0; else if (num % 2 == 0) return num + mystery(num - 1); else return num * mystery(num - 1); } What is the output of the following statement? cout << mystery(5) << endl;

50

What is the output of the following code? queueType<int> queue; int x, y; x = 2; y = 6; queue.addQueue(x); queue.addQueue(y); x = queue.front( ); queue.deleteQueue( ); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); while (!queue,isEmptyQueue( ) ) { cout << queue.front( ) << " "; queue.deleteQueue( ); } cout << endl;

6 4 2 3

What is the output of the following code? ​ queueType<int> queue; int x, y; ​ x = 2; y = 6; queue.addQueue(x); queue.addQueue(y); x = queue.front(); queue.deleteQueue(); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); ​ while (!queue.isEmptyQueue()) { cout << queue.front() << " "; queue.deleteQueue(); } cout << endl ​ Group of answer choices 6 2 3 3 6 2 4 2 6 3 3 3 6 4 2 3

6 4 2 3

int mystery(int list[], int first, int last) { if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last); } Consider the accompanying definition of the recursive function mystery. Given the declaration: int beta[10] = {2, 5, 8, 9, 13, 15, 18, 20, 23, 25}; What is the output of the following statement? cout << mystery(beta, 4, 7) << endl;

66

int puzzle(int start, int end) { if (start > end) return start - end; else if (start == end) return start + end; else return end * puzzle(start + 1, end - 1); } Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << puzzle(5, 10) << endl;

720

In C++, the scope resolution operator is ____. Group of answer choices : :: $ .

::

two pointers, one for the left child and one for the right child

A binary tree can be created using a struct or class containing a data value and Group of answer choices a pointer to the first child node a pointer to the last child node two pointers, one for the left child and one for the right child two data nodes None of these

True

A binary tree has no cycles. a. True b. False

graph

A binary tree is also a(n) ____. Group of answer choices stack linked list graph array

three levels

A binary tree with a height of three has Group of answer choices six nodes one root and three nodes with two children each three levels three subtrees None of these

False

A catch block specifies the type of exception it can catch and immediately terminates the program. Group of answer choices True/False

automatic

A class object can be ____. That is, it is created each time the control reaches its declaration, and destroyed when the control exits the surrounding block. Group of answer choices static automatic local public

n-dimensional array

A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____. Group of answer choices matrix vector n-dimensional array parallel array

deque

A container that provides quick access to elements at the front and the back of the list is a Group of answer choices stack queue deque All of these None of these

queue

A container that provides quick access to elements at the front and the back of the list is a Group of answer choices stack queue deque All of these None of these

recursive

A definition in which something is defined in terms of a smaller version of itself is called a(n) ____ definition.

Which of the following is true about a derived class? Group of answer choices A derived class can directly access any member variable of the base class. A derived class can redefine any public member function of the base class. A derived class can have at most one base class. A derived class can redefine any member function of the base class.

A derived class can redefine any member function of the base class.

-

A destructor has the character ____, followed by the name of the class. Group of answer choices . :: # ˜

the previous node

A doubly linked list keeps track of the next node in the list as well as Group of answer choices itself the head node the tail node the previous node None of these

dynamic linked list

A dynamic queue can be implemented as a ________.

variable, linked list

A dynamic stack has a ________ size, and is implemented as a(n) ________.

linked list

A dynamic stack may be implemented as a(n) ________ and can expand or shrink with each push or pop operation. Group of answer choices array structure linked list Either array or structure None of these

linked list

A dynamic stack may be implemented as a(n) ________, and expand or shrink with each push or pop operation.

directly recursive

A function is called ____ if it calls itself.

to expedite the process of searching large sets of information

A good reason to use the binary tree structure is Group of answer choices to expedite the process of searching large sets of information aesthetics and program design code readability that it is more flexible than the unary tree structure None of these

c. vertices

A graph G is a pair, G = (V, E), where V is a finite nonempty set called the set of ____ of G, and the elements of E are the pairs of elements of V. a. nodes b. branches c. vertices d. edges

c. vertices

A graph G is a pair, G = (V, E), where V is a finite nonempty set called the set of ____ of G, and the elements of E are the pairs of elements of V. a. nodes b. branches c. vertices d. edges

c. subgraph

A graph H is called a(n) ____ of G if V(H) is a subset of V(G) and E(H) is a subset of E(G); that is, every vertex of H is a vertex of G, and every edge in H is an edge in G. a. matrix b. intersection c. subgraph d. union

c. subgraph

A graph H is called a(n) ____ of G if V(H) is a subset of V(G) and E(H) is a subset of E(G); that is, every vertex of H is a vertex of G, and every edge in H is an edge in G. a. matrix b. intersection c. subgraph d. union

ANSWER: subset

A set Y is called a(n) ____________________ of X if every element of Y is also an element of X.

True

A simple path is a path in which all vertices, except possibly the first and last vertices, are distinct. a. True b. False

all

A stack can be adapted to store ________ data types.

all

A stack can be adapted to store ________ data types. Group of answer choices all only built-in C++ only abstract deque-like None of these

array

A stack can be implemented as either a(n) _______ or a linked structure.

push, pop

A stack has two primary operations:

LIFO

A stack is a(n) _______ data structure.

circular array

A static queue can be implemented as a ________.

heterogeneous

A struct is typically a ____ data structure. Group of answer choices simple dynamic heterogeneous linked

True

A subtree is an entire branch of a tree from one particular node down. Group of answer choices True/False

True

A subtree is an entire branch of a tree, from one particular node down. True/False

b. spanning

A tree T is called a(n) ____ tree of graph G if T is a subgraph of G such that V(T) = V(G); that is, if all vertices of G are in T. a. weighted b. spanning c. rooted d. directed

b. spanning

A tree T is called a(n) ____ tree of graph G if T is a subgraph of G such that V(T) = V(G); that is, if all verticies of G are in T. a. weighted b. spanning c. rooted d. directed

ANSWER: spanning tree

A tree T is called a(n) ____________________ of graph G if T is a subgraph of G such that V(T ) = V(G).

d. rooted

A tree in which a particular vertex is designated as a root is called a(n) ____ tree. a. spanning b. weighted c. free d. rooted

d. rooted

A tree in which a particular vertex is designated as a root is called a(n) ______ tree. a. spanning b. weighted c. free d. rooted

friend

A(n) ____ function is a nonmember function that has access to all members of the class. Group of answer choices access protected friend void

friend

A(n) ____ function is a nonmember function that has access to all members of the class. a. access b. protected c. friend d. void

stack

A(n) ____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end. Group of answer choices stack queue array linked list

Which of the following is true about classes and structs? Group of answer choices By default, all members of a struct are public and all members of a class are private. A struct variable is passed by value only, and a class variable is passed by reference only. An assignment operator is allowed on class variables, but not on struct variables. You cannot use the member access specifier private in a struct.

By default, all members of a struct are public and all members of a class are private.

virtual

C++ provides ____ functions as a means to implement polymorphism in an inheritance hierarchy, which allows the run-time selection of appropriate member functions. Group of answer choices redefined overridden virtual overloaded

The QuickSort algorithm was developed in 1960 by ________.

C.A.R. Hoare

parameterized

Class templates are called ____ types. a. structured b. parameterized c. member d. polymorphic

C and D are binary trees.

Consider that A is a binary tree, C and D are the subtrees of A. Which of the following statements is always true? Group of answer choices C and D are binary trees. C and D are search binary trees. C and D are empty trees. A is empty.

private

Consider the following class definition: class dClass: bClass { //class members list }; The class dClass is derived from the class bClass using the ____ type of inheritance. Group of answer choices public private protected static

b.void dClass::print() const{dClass:print();cout << " " << y << endl;}

Consider the following class definitions:class bClass{public:void setX(int);void print() const;private:int x;};class dClass: public bClass{public:void setXY(int, int);void print() const;private:int y;}; Which of the following statements correctly redefines the member function print of bClass? a.void dClass::print() const{bClass::print();cout << "y = " << y << endl;} b.void dClass::print() const{dClass:print();cout << " " << y << endl;} c.void dClass::print() const{cout << x << " " << y << endl;} d.void bClass::print() const{cout << x << " " << y << endl;}

tail

Consider the following code. int fact(int num) { if (num == 0) return 1; else return num * fact(num - 1); } The function fact is an example of a(n) ____________________ recursive function.

int alpha[] = {3, 5, 7, 9, 11};

Consider the following declaration: int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this statement? Group of answer choices int alpha[] = {3, 5, 7, 9, 11}; int alpha[] = {3 5 7 9 11}; int alpha[5] = [3, 5, 7, 9, 11]; int alpha[] = (3, 5, 7, 9, 11);

21

Consider the following definition of the recursive function mystery. int mystery(int first, int last) { if (first > last) return 0; else if (first == last) return first; else return first + mystery(first + 1, last - 1); } What is the output of the following statement? cout << mystery(6, 10) << endl;

50

Consider the following definition of the recursive function mystery. int mystery(int num) { if (num <= 0) return 0; else if (num % 2 == 0) return num + mystery(num - 1); else return num * mystery(num - 1); } What is the output of the following statement? cout << mystery(5) << endl;

4 3 2 1

Consider the following definition of the recursive function print. void print(int num) { if (num > 0) { cout << num << " "; print(num - 1); } } What is the output of the following statement? print(4);

5

Consider the following recursive definition, where n is a positive integer. F(1) = 3 F(n) = F(n - 1) + 1 if n > 1 The value of F(3) is ____________________.

reference

Consider the following statements: void pointerParameters(int* &p, double *q) { . . . } In the function pointerParameters, the parameter p is a(n) ____________________ parameter.

It is an array of structs.

Consider the following statements: struct supplierType { string name; int supplierID; }; struct applianceType { supplierType supplier; string modelNo; double cost; }; applianceType applianceList[25]; Which of the following best describes applianceList? Group of answer choices It is a multidimensional array. It is a struct. It is an array of structs. It is a struct of arrays.

True

Data in a struct variable must be read one member at a time. Group of answer choices True/False

stacks, queues, deques

Data structures that can dynamically store elements and can grow and shrink in size are:

p = new int; delete p; p = new int;

Fix code for memory leak: p = new int; p = new int;

True

For a compiler that is older than C++11 it is necessary to put spaces between the angled brackets that appear next to each other when defining a stack. Group of answer choices True/False

selection

For a list of length n, the ____________________ sort makes exactly (n(n - 1))/2 key comparisons and 3(n - 1) item assignments.

True

For classes with pointer data members, you must explicitly overload the assignment operator and include the destructor. Group of answer choices True/False

functions

Functions defined in a class are called ____________

True

Given the declaration int *p; The statement p = new int[50]; dynamically allocates an array of 50 components of type int and p contains the base address of the array. Group of answer choices True/False

0

Given the following code, assume the myQueue object is a queue that can hold integers and that value is an int variable. Assume that the dequeue function, called on line 4, stores the number removed from the queue in the value variable. What will the statement on line 5 display? Group of answer choices 0 1 2 None of these

sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][3];

Given the following declaration: int j; int sum; double sale[10][7]; which of the following correctly finds the sum of the elements of the fourth column of sale? Group of answer choices sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][3]; sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][4]; sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][4]; sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][3];

a. Konigsberg bridge

Graph theory started in 1736 with the ___ problem. a. Koingsberg bridge b. Tower of Hanoi c. Westminster d. League of Augsburg

a. Königsberg bridge

Graph theory started in 1736 with the ____ problem. a. Königsberg bridge b. Tower of Hanoi c. Westminster d. League of Augsburg

3

How many needles are used in the Tower of Hanoi problem?

two: remove the node without breaking links, then delete it from memory

How many steps are involved in the process of deleting a node? Group of answer choices one: delete the node from memory two: remove the node without breaking links, then delete it from memory three: create a blank node, remove the node being deleted, insert the blank node four: create a blank node, insert the blank node before the node being deleted, remove the node being deleted, delete the blank node None of these

5

How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n - 1); } }

two: one for the node under inspection and one for the previous node

In an insertion or deletion routine: how many pointers are you required to create for use during the traversal process? Group of answer choices two: one for the node under inspection and one for the previous node two: one for the node under inspection and one for the next node one: for the node being inserted or deleted three: one for the node under inspection, one for the next node, and one for the following node

shallow

In copying a binary tree, if you use just the value of the pointer of the root node, you get a ____ copy of the data. Group of answer choices static shallow deep local

one

In evaluating a postfix expression, when the end of expression is encountered, how many elements must the stack contain so that no error is generated?

True

In protected inheritance, public and protected members of the base class become the protected members of the derived class. Group of answer choices True/False

False

In structs, you access a component by using the struct name together with the relative position of the component. Group of answer choices True/False

7

In the Tower of Hanoi problem, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is ____________________.

False

In the Tower of Hanoi recursive program, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is 8. Group of answer choices True/False

0

In the array representation of a stack, the stack is initialized simply by setting stackTop to

path

In the diagram of a binary tree, an arrow is called a(n) ____. Group of answer choices relation path directed line directed branch

0

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: cout << value << endl; Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable. What will the statement in line 5 display?

2

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.dequeue(value); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in line 4, 5 and 6 stores the number removed from the queue in the value variable. What will the statement in line 7 display?

1

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.enqueue(3); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in line 4 and 6 stores the number removed from the queue in the value variable. What will the statement in line 7 display?

2

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: cout << value << endl; Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable. What will the statement in line 5 display?

0

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: myStack.pop(value); 6: myStack.pop(value); 7: cout << value << endl; Assume that the pop function, called in line 4, 5 and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?

3

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: myStack.push(3); 6: myStack.pop(value); 7: cout << value << endl; Assume that the pop function, called in line 4, 5 and 6, stores the number popped from the stack in the value variable. What will the statement in line 5 display?

False

In the linked implementation of stacks, the memory to store the stack elements is allocated statically.

False

In the linked implementation of stacks, the memory to store the stack elements is allocated statically. True/False

False

In the linked implementation of stacks, the memory to store the stack elements is allocated statically. Group of answer choices True False

False

In the linked implementation of stacks, the memory to store the stack elements is allocated statically. T/F

False

In the statementint* p, q;p and q are pointer variables. Group of answer choices True False

Which of the following arithmetic operations is allowed on pointer variables? Group of answer choices Increment Modulus Multiplication Division

Increment

is-a

Inheritance is an example of a(n) ____ relationship. Group of answer choices is-a has-a handshaking had-a

False

Operator functions typically return void. Group of answer choices True/False

Consider the following statements: struct supplierType { string name; int supplierID; }; struct applianceType { supplierType supplier; string modelNo; double cost; }; applianceType applianceList[25]; Which of the following best describes applianceList? Group of answer choices It is a multidimensional array. It is a struct. It is an array of structs. It is a struct of arrays.

It is an array of structs.

True

It is possible to design Prim's algorithm so that it is of the order O(n2 ). a. True b. False

Which of the following solution methods would be the best choice for a mission control system?

Iterative

A stack is a(n) _______ data structure.

LIFO

ANSWER: edges

Let G be a weighted graph. Let u and v be two vertices in G, and let P be a path in G from u to v. The weight of the path P is the sum of the weights of all the ____________________ on the path P.

ANSWER: cycle

Let G be an undirected graph. Let u and v be two vertices in G. A(n) ____________________ in G is a simple path in which the first and last vertices are the same.

a. adjacent

Let G be an undirected graph. Let u and v be two vertices in G. Then u and v are called ____ if there is an edge from one to the other. a. adjacent b. weighted c. connected d. shortest path

a. adjacent

Let G be an undirected graph. Let u and v be two verticies in G. Then u and v are called _____ if there is an edge from one to the other. a. adjacent b. weighted c. parallel d. shortest path

n

Let T be a binary search tree with n nodes, in which n > 0. When T is linear, the search algorithm makes ____________________ key comparisons, in the unsuccessful case.

ANSWER: incident

Let e (u, v) be an edge in an undirected graph G. The edge e is said to be ____________________ on the vertices u and v.

False

Linked lists cannot be used to implement an adjacency list. a. True b. False

declare

Memory is allocated for struct variables only when you ____________________ them.

d. All of these

Methods of traversing a tree are: a. Inorder traversal b. Preorder traversal c. Postorder traversal d. All of these e. None of these

True

Most operator functions can either be member functions or nonmember functions of a class. Group of answer choices True/False

instance

Non-static member variables of a class are called the ____________________ variables of the class.

In general, the selection sort algorithm is good only for small lists because _______ grows rapidly as n grows.

O(n^2)

Any sorting algorithm that sorts a list of n distinct elements by comparison of the keys only, in its worst case, makes at least ______ key comparisons.

O(nlog2n) O(nlogn)

OOP implements ____. Group of answer choices UML IPE EIP OOD

OOD

OOD

OOP implements ____. Group of answer choices UML IPE EIP OOD

compute factorials, find GCD's, traverse linked lists

Recursion can be used to:

Which of the following solutions is easier to construct for the Tower of Hanoi problem?

Recursive

recursive

Recursive algorithms are implemented using ____________________ functions.

False

Relational operations can be used on struct variables. Group of answer choices True/False

computing factorials finding the greatest common divisor of two numbers doing a Binary Search multiplying two numbers traversing a linked list ?

Select all that apply. Which of the following problems can be solved using recursion? Group of answer choices computing factorials finding the greatest common divisor of two numbers doing a Binary Search multiplying two numbers traversing a linked list

storage of local variables tracking nested loops tracking nested function calls

Select all that apply. A practical application of the stack data type in a computer system is Group of answer choices storage of local variables tracking nested loops tracking nested function calls None of these

> < == ?

Select all that apply. Binary trees may be implemented as templates, but any data types used with them must support the ________ operator. Group of answer choices > < && == linked

stacks deques

Select all that apply. Data structures that can dynamically store elements and can grow and shrink in size are Group of answer choices stacks arrays queues deques

inserting finding deleting

Select all that apply. Which of the following operations can be performed on a binary search tree? Group of answer choices moving inserting finding placing deleting

True

Stacks and queues can be implemented as arrays or linked lists. Group of answer choices True/False

first, last

Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series.

first, last

Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series. Group of answer choices last, first first, last efficiently, first efficiently, last None of these

void printNum(int num) //Line 1 { //Line 2 if (n < 0) //Line 3 cout << "Num is negative" << endl; //Line 4 else if (num == 0) //Line 5 cout << "Num is zero" << endl; //Line 6 else //Line 7 { //Line 8 cout << num << " "; //Line 9 printNum(num - 1); //Line 10 } //Line 11 } //Line 12 Consider the accompanying definition of a recursive function. Which of the statements represent the base case?

Statements in Lines 3-6

fixed, arrays

Static stacks have a ________ size and are implemented as ________. Group of answer choices fixed, linked lists variable, arrays fixed, arrays variable, linked lists None of these

fixed, arrays

Static stacks have a ________ size, and are implemented as ________.

template <class Type> funcType cType<Type>::func(parameters)

Suppose cType is a class template, and func is a member function of cType. The heading of the function definition of func is: ____. a. template <class Type> funcType cType<Type>func(parameters; b. template <class Type> funcType cType<Type> c. template <class Type> funcType cType<Type>::func(parameters) d. template <class Type> funcType cType<Type> == func(parameters)

cType<int> x;

Suppose cType is a class template, which can take int as a parameter. The statement: ____ declares x to be an object of type cType, and the type passed to the class cType is int. a. cType<int> x; b. cType int x; c. cType int :: x; d. cType int = x;

Suppose you have written a program that inputs data from a file. If the input file does not exist when the program executes, then you should choose which option? Group of answer choices Terminate the program. Include code in the program to recover from the exception. Log the error and continue. Include code in the header file.

Terminate the program. ?

True

The InOrder method of traversing a binary tree involves traversing the node's left subtree, processing the node's data, and then traversing the node's right subtree. Group of answer choices True/False

recursion

The InOrder, PreOrder, and PostOrder traversals can be accomplished using Group of answer choices recursion no pointers no arguments no parameters None of these

False

The PostOrder method of traversing a binary tree involves processing the node's data, traversing the node's right subtree, and then traversing the node's left subtree. True False

True

The PreOrder method of traversing a binary tree involves processing the node's data, traversing the node's left subtree, and then traversing the node's right subtree. Group of answer choices True False

True

The PreOrder method of traversing a binary tree involves processing the node's data, traversing the node's left subtree, and then traversing the node's right subtree. Group of answer choices True/False

lists stored in arrays or linear linked lists

The QuickSort algorithm is used to sort ________.

C.A.R. Hoare

The QuickSort algorithm was developed in 1960 by ________.

two sublists and a pivot

The QuickSort algorithm works on the basis of

True

The STL provides containers for deque and queue. Group of answer choices True/False

vector, deque, linked list

The Standard Template Library offers a stack template that may be implemented as a:

base

The ____ case is the case for which the solution to an equation is obtained directly.

copy

The ____ constructor is executed when an object is declared and initialized by using the value of another object. Group of answer choices default copy struct class

top

The ____ element of the stack is the last element added to the stack. Group of answer choices top bottom head tail

level

The ____ of a node in a binary tree is the number of branches on the path from the root to the node. Group of answer choices height level width size

level

The ____ of a node in a binary tree is the number of branches on the path from the root to the node. Group of answer choices height level width size

a. intersection

The ____ of sets A and B is the set of all elements that are in A and B. a. intersection b. union c. graph d. reunion

b. union

The ____ of sets A and B is the set of all elements that are in A or in B. a. intersection b. union c. graph d. reunion

b. union

The ____ of sets A and B is the set of all elements that are in A or in B. a. intersection b. union c. graph d. reunion

address of

The ____ operator can be used to return the address of a private data member of a class. Group of answer choices dereferencing destructor address of member access

top

The _____ element of the stack is the last element added to the stack.

a. intersection

The _____ of sets A and B is the set of all elements that are in A and B. a. intersection b. union c. graph d. reunion

quicksort

The ________ algorithm uses recursion to efficiently sort a list.

head

The ________ of a linked list points to the first node in the list. Group of answer choices starter head tail declaration None of these

depth

The ________ of recursion is the number of times a recursive function calls itself.

pop

The ________ operation allows an item to be removed from a stack.

push

The ________ operation allows an item to be stored on a stack.

a. root pointer

The ___________ in a binary tree is similar to the head pointer in a linked list. a. root pointer b. leaf pointer c. null pointer d. binary pointer e. None of these

False

The implementation of a breadth first graph traversal uses a stack. a. True b. False

True

The infix expression (a + b) * (c - d / e) + f is equivalent to the postfix expression ab + cde /-* f + Group of answer choices True/False

True

The infix expression (a + b) * (c - d / e) + f is equivalent to the postfix expression ab+ cde /-* f+

False

The intBinaryTree class has a public member function, findNode, that returns true if a value is not found and false if the value is found. Group of answer choices True/False

True

The item search, insertion, and deletion operations all require the binary tree to be traversed. Group of answer choices True/False

30

The key of the right child below the root node of a search binary tree is 40. The value in the root node could be ____. Group of answer choices 30 40 50 60

False (It is 0)

The level of the root node of a binary tree is 1. Group of answer choices True/False

nullptr

The link field of the last node of a linked list is ____. Group of answer choices nullptr 1 n-1 n

doubly linked list

The list container provided by the Standard Template Library is a template version of a Group of answer choices singly linked list doubly linked list circular linked list backward linked list None of these

preorder Sequence

The listing of the nodes produced by the preorder traversal of a binary tree is called the ____________________.

preorder sequence

The listing of the nodes produced by the preorder traversal of a binary tree is called the ____________________.

insertion ?

The most common operation performed on a binary tree is a(n) ____. Group of answer choices insertion deletion search traversal

operator<=

The name of the function to overload the operator <= is ____. a. operator<= b. <=operator c. <=new d. overload<=

derived

The new classes that we create from existing classes are called ____ classes. Group of answer choices sibling base derived parent

member selection

The only built-in operations on classes are assignment (=) and ____________________.

False ?

The operations to do inorder, preorder, and postorder traversals of a binary search tree are the same as those for a binary tree. Group of answer choices True/False

sizeof

The operators that cannot be overloaded are ., .*, ::, ?:, and ____________________.

there will be too many elements in the stack when the equal sign is encountered

The postfix expression 14 2 5 + = will generate an error, because ______.

14 ?

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____. 4 14 24 26

14

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ________.

contains an illegal operator

The postfix expression 3 5 + 2 ; 6 - = will generate an error, because it ______.

42

The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____. 10 30 42 44

42

The postfix expressions 5 6 + 4 * 10 5 / - = evaluates to ________.

enqueue and dequeue

Two primary queue operations are:

c. Kruskal

Two well-known algorithms, Prim's algorithm and _____'s algorithm, can be used to find a minimal spanning tree of a graph. a. Euler b. Dekart c. Kruskal d. Dijkstra

c. Kruskal

Two wellknown algorithms, Prim's algorithm and ____'s algorithm, can be used to find a minimal spanning tree of a graph. a. Euler b. Dekart c. Kruskal d. Dijkstra

before the definitions of all the functions

Typically, in a program, a struct is defined ____ in the program. Group of answer choices in the main function before the definitions of all the functions after the definitions of all the functions in any function

template

Using a class ____________________ allows you to define an arrayListType that can process any type of list.

classes

Using a class template, you can write a single code segment for a set of related ____. a. operators b. functions c. classes d. constructors

left, node's

Values are typically stored in a binary search tree so that a node's ________ child holds data that is less than the ________ data. Group of answer choices right, node's left, node's right, left child's left, right child's None of these

False

We can always traverse an entire graph from a single vertex. a. True b. False

False

We deallocate the memory for a linked list by calling the operator clear. Group of answer choices True/False

a new stack of integers, implemented as a vector

What does the following statement indicate? stack< int, vector > iStack; Group of answer choices a new stack of integers, implemented as a vector a new stack of integers, implemented as a deque a new stack named vector, implemented as integers a new vector named stack, implemented with integers None of these

0 5 10 15 20

What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++) cout << list[j] << " "; cout << endl; Group of answer choices 0 1 2 3 4 0 5 10 15 0 5 10 15 20 5 10 15 20

6 4 2 3

What is the output of the following code? queueType<int> queue; int x, y; x = 2; y = 6; queue.addQueue(x); queue.addQueue(y); x = queue.front( ); queue.deleteQueue( ); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); while (!queue,isEmptyQueue( ) ) { cout << queue.front( ) << " "; queue.deleteQueue( ); } cout << endl;

x = 9

What is the output of the following code? stackType<int> stack; int x, y; x = 4; x = 2; stack.push(6); stack.push(x); stack.push(x + 1); y = stack.top( ); stack.pop( ); stack.push(x + y); x = stack.top( ); stack.pop( ); cout << "x = " << x << endl;

x = 2 y = 3

What is the output of the following code? queueType<int> queue; int x, y; x = 2; y = 3; queue.addQueue(x); queue.addQueue(y); x = queue.front(); queue.deleteQueue(); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); y = queue.front(); queue.deleteQueue(); cout << "x = " << x << endl; cout << "y = " << y << endl; x = 2 y = 4 x = 4 y = 3 x = 2 y = 3 x = 3 y = 2

6 4 2 3

What is the output of the following code? ​ queueType<int> queue; int x, y; ​ x = 2; y = 6; queue.addQueue(x); queue.addQueue(y); x = queue.front(); queue.deleteQueue(); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); ​ while (!queue.isEmptyQueue()) { cout << queue.front() << " "; queue.deleteQueue(); } cout << endl ​ Group of answer choices 6 2 3 3 6 2 4 2 6 3 3 3 6 4 2 3

Traversal of a linked list

What is the purpose of the following code? current = head; while (current != nullptr) { //Process current current = current->link;} Group of answer choices Insertion of a node Selection of a node Traversal of a linked list Creation of a new list

5

What is the value of alpha[2] after the following code executes? int alpha[5]; int j; for (j = 0; j < 5; j++) alpha[j] = 2 * j + 1; Group of answer choices 1 4 5 6

46

What is the value of x after the following statements execute? int x = 25; int *p; p = &x; *p = 46; Group of answer choices nullptr 0 25 46

c. binary search tree

When a binary tree is used to facilitate a search, it is referred to as a: a. binary queue b. binary ordered deque c. binary search tree d. sort algorithm e. None of these

copy ??

When a class object is passed by value, the ____________________ constructor copies the value of the actual parameters into the formal parameters.

zero

When a stack is implemented as an array, the array is empty if the value of a stackTop is ______.

the root node

When an application begins by searching a binary tree, it starts at Group of answer choices the outermost leaf node the middle node, halfway between the root and the longest branch the rightmost child of the root node the root node None of these

front

When an element is added to a queue, it is added to the rear. When an element is removed from the queue, it is removed from the rear middle front depends on how the programmer writes the code None of these

front

When an element is added to a queue, it is added to the rear. When an element is removed, it is removed from the ________.

unwound

When an exception is thrown in a function, the function-call stack is ____ so that the exception can be caught in the next try/catch block. Group of answer choices destroyed allocated unbound unwound

terminate

When an exception is thrown, if the program does not handle the exception, then the function ____ is called to terminate the program. Group of answer choices log what terminate close

b. this

When an object invokes a member function, the member function references the pointer ____ of the object. a. object b. this c. address d. it

indirect recursion

When function A calls function B, which in turn calls function A, this is known as:

two

When the post-increment operator is overloaded as a nonmember function of the class, the operator function has ____ parameter(s).

False

When the program knows the exact contents of a list and can access any element on demand, the data structure is known as a stacked deque. Group of answer choices True/False

child nodes, or children

When the root node points to two other nodes, the nodes are referred to as Group of answer choices child nodes, or children parent nodes, or parents binary nodes subnodes None of these

root

When traversing a binary tree, the pointer current is initialized to ____. Group of answer choices nullptr llink rlink root

is theoretically impossible in a correctly developed binary tree structure ?

When working with a binary tree, a node that has more than two children Group of answer choices will be cut back by the compiler is theoretically impossible in a correctly developed binary tree structure is known as a triplet node None of these

class bClass: public aClass{ //... };

Which of the following class definitions makes the public members of the class aClass become the public members of the class bClass? Group of answer choices class aClass: public bClass{ //... }; class bClass: public aClass{ //... }; class bClass: aClass{ //... }; class aClass: bClass{ //... };

int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with the component type int? Group of answer choices int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}}; int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5}; int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5}; int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

first = nullptr; last = nullptr; count = 0;

Which of the following correctly initializes a doubly linked list in the default constructor? Group of answer choices head = nullptr; back = nullptr; head = 0; back = 0; count = 0; first = 0; last = 0; first = nullptr; last = nullptr; count = 0;

int rFibNum(int a, int b, int n)

Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number? a. bool rFibNum(int a, int b, int n) b. int rFibNum(int a, int b, int n) c. bool rFibNum(int a, int b) d. void rFibNum(int a, int b)

bool operator!=(const rectangleType&) const;

Which of the following function prototypes overloads the != operator for the class rectangleType? a. int operator!=(rectangle&) const; b. bool operator!=(const rectangleType&) const; c. int operator!=(const rectangleType) const; d. bool operator!=(rectangle&) const;

Make a copy of the linked list.

Which of the following is a basic operation on singly linked lists? Group of answer choices Retrieve the data of an arbitrary node. Swap the head and the last nodes. Determine whether the list is nearly full. Make a copy of the linked list.

d) assignment

Which of the following is a built-in operation on classes? a. increment b. relational operators c. decrement d. assignment

Assignment

Which of the following is an allowable aggregate operation on a struct? Group of answer choices Arithmetic Assignment Input/output Comparison

b) className operator++(int);

Which of the following is the general syntax of the function prototype to overload the post-increment operator as a member function? a. className operator++(); b. className operator++(int); c. friend className operator++(); d. friend className operator++(int);

className operator++();

Which of the following is the general syntax of the function prototype to overload the pre-increment operator ++ as a member function? a. friend className operator++(); b. className operator++(int); c. friend className operator++(int); d. className operator++();

friend className operator++(className&);

Which of the following is the general syntax of the function prototype to overload the pre-increment operator as a nonmember function? a. friend className operator++(className&); b. friend className operator++(); c. className operator++(); d. className operator++(int);

const Type& operator[](int index);

Which of the following is the syntax to declare the operator function operator[] as a member function of a class for constant arrays? Group of answer choices const Type& []operator(int index) const; const Type& operator[](int index) const; const Type& operator[](int index); const Type [](int index) const;

const Type& operator[](int index) const;

Which of the following is the syntax to declare the operator function operator[] as a member function of a class for constant arrays? a. const Type& operator[](int index) const; b. const Type& []operator(int index) const; c. const Type [](int index) const; d. const Type& operator[](int index);

a. Type& operator[](int index);

Which of the following is the syntax to declare the operator function operator[] as a member function of a class for nonconstant arrays? a. Type& operator[](int index); b. Type& []operator(int index); c. Type operator[](int index); d. Type [](int index);

A derived class can redefine any member function of the base class.

Which of the following is true about a derived class? Group of answer choices A derived class can directly access any member variable of the base class. A derived class can redefine any public member function of the base class. A derived class can have at most one base class. A derived class can redefine any member function of the base class.

By default, all members of a struct are public and all members of a class are private.

Which of the following is true about classes and structs? Group of answer choices By default, all members of a struct are public and all members of a class are private. A struct variable is passed by value only, and a class variable is passed by reference only. An assignment operator is allowed on class variables, but not on struct variables. You cannot use the member access specifier private in a struct.

pop

You can perform the operation ____ to remove the top element from the stack. Group of answer choices dequeue top pop push

A smaller disk can be placed on top of a larger disk

Which of the following rules should you follow to solve the Tower of Hanoi problem? a.You can remove disks only from the first needle. b. The removed disk must be placed on a smaller disk. c. Only two disks can be moved at a time. d. A smaller disk can be placed on top of a larger disk.

Iterative

Which of the following solution methods would be the best choice for a mission control system? a. Direct recursive b. Indirect recursive c. Iterative d. Infinite recursive

Recursive

Which of the following solutions is easier to construct for the Tower of Hanoi problem? Group of answer choices Recursive Iterative Procedural Step-by-step

Recursive

Which of the following solutions is easier to construct for the Tower of Hanoi problem? a. Iterative b. Procedural c. Step-by-step d. Recursive

class myClass {};

Which of the following statements creates a new exception class? Group of answer choices class myClass {}; class myClass {} implements exception; class myExceptionClass {} extends exception; class myExceptionClass {} throws exception;

int alpha[25];

Which of the following statements declares alpha to be an array of 25 components of the type int? Group of answer choices int alpha[25]; int array alpha[25]; int alpha[2][5]; int array alpha[25][25];

throw 2;

Which of the following statements throws a valid exception in C++? Group of answer choices throw.function(); throw 2; throws str; 4 throw;

a) struct studentType { int ID; };

Which of the following struct definitions is correct in C++? Group of answer choices a) struct studentType { int ID; }; b) struct studentType { string name; int ID; double gpa; } c) int struct studentType { ID; } d) struct studentType { int ID = 1; };

circular linked

Which type of list does NOT contain a null pointer at the end of the list? Group of answer choices backwards linked doubly linked circular linked null linked None of these

it encounters a null pointer

While traversing a list, a node pointer knows when it has reached the end of the list if Group of answer choices it encounters the newline character it encounters a null pointer it finds itself back at the beginning of the list it encounters a sentinel such as 9999

False

With recursion, the base case must eventually be reduced to a general case. Group of answer choices True/False

assignment

With the exception of the ____________________ operator and the member selection operator, operators must be overloaded to be used on class objects.

b. subset

Y is a(n) ____ of X if every element of Y is also an element of X. a. derivative b. subset c. inheritee d. shallow copy

b. subset

Y is a(n) ______ of X if every element of Y is also an element of X. a. derivative b. subset c. inheritee d. shallow copy

push

You can perform the add operation, called _____, to add an element onto the stack.

The following statement stack< int, vector <int> > iStack; indicates:

a new stack of integers, implemented as a vector

What does the following statement indicate? stack< int, vector > iStack; Group of answer choices a new stack of integers, implemented as a vector a new stack of integers, implemented as a deque a new stack named vector, implemented as integers a new vector named stack, implemented with integers None of these

a new stack of integers, implemented as a vector

A pointer variable

a variable whose content is a memory address

Which of the following struct definitions is correct in C++? Group of answer choices a) struct studentType { int ID; }; b) struct studentType { string name; int ID; double gpa; } c) int struct studentType { ID; } d) struct studentType { int ID = 1; };

a) struct studentType { int ID; };

Assuming the following list declaration, which element is at the position 0 after the first iteration of selection sort? int list [ ] = {16, 30, 24, 7, 62, 45, 5, 55} a. 5 b, 7 c. 16 d. 62

a. 5

The behavior of merge sort is ___ in the worst case and ___ in the average case. a. O(nlog2n), O(nlog2n) b. O(n^2), O(n) c. O(nlog2n), O(n^2) d. O(n^2), O(nlog2n)

a. O(nlog2n), O(nlog2n)

____ sort requires knowing where the middle element of the list is. a. merge b. bubble c. insertion d. selection

a. merge

How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n + 1); } }

an infinite number of times

ambiguity

another term for collision

A stack can be implemented as either a(n) _______ or a linked structure.

array

The function ____ can check whether an expression meets the required conditions; if the conditions are not met, it terminates the program. Group of answer choices check look assert what

assert

Let f be a function of n. By the term ______, we mean the study of the function f as n becomes larger and larger without bond.

asymptotic

A class object can be ____. That is, it is created each time the control reaches its declaration, and destroyed when the control exits the surrounding block. Group of answer choices static automatic local public

automatic

theta(L)

average run time for ins/sea

A sequential search of an n-element list takes ______ key comparisons if the item is not in the list. a. 0 b. n/2 c. n d. n^2

c. n

With insertion sort, the variable firstOutOfOrder is initialized to ____, assuming n is the length of the list. a. 0 b. 1 c. n - 1 d. n

b. 1

For a list of length n, selection sort makes ____ item assignments. a. n(n - 1)/2 b. 3(n - 1) c. 3(n) d. 4(n + 1)

b. 3(n - 1)

The sequential search algorithm uses a(n) ____ variable to track whether the item is found. a. int b. bool c. char d. double

b. bool

A sequential search of an n-element list takes ____ key comparisons on average to determine whether the search item is in the list. a. 0 b. n/2 c. n d. n^2

b. n

For a list of length n, insertion sort makes ___ key comparisons, in the worst case. a. n(n-1)/4 b. n(n-1)/2 c. n^2 d. n^3

b. n(n-1)/2

The ____ case is the case for which the solution to an equation is obtained directly.

base

Typically, in a program, a struct is defined ____ in the program. Group of answer choices in the main function before the definitions of all the functions after the definitions of all the functions in any function

before the definitions of all the functions

A comparison tree is a(n) __________ tree.

binary

The ______ search algorithm is the optimal worst-case algorithm for solving search problems by using the comparison menthod

binary

The following is the pseudocode for which type of algorithm? Set first to 0 Set last to the last subscript in the array Set found to false Set position to -1 While found is not true and first is less than or equal to last Set middle to the subscript halfway between array[first] and array[last] If array[middle] equals the desired value Set found to true Set position to middle Else If array[middle] is greater than the desired value Set last to middle - 1 Else Set first to middle + 1 End If End While Return position a. linear sort b. linear search c. binary search d. selection sort e. None of these

binary search

A __________ search is more efficient than a __________ search. a. character, string b. integer, double c. binary, linear d. linear, binary e. None of these

binary, linear

The elements at the ____________________ of the stack have been in the stack the longest.

bottom

A(n) ____________________ ordering of the vertices of the accompanying graph is 0, 1, 3, 4, 2, 5, 7, 8, 6, 9.

breadth-first

The following C++ function implements the ___sort algorithm. template <class elemType> void Sort (elemType list [ ], int length) { for (int iteration = 1; iteration < length; iteration++) { for (int index = 0; index < length - iteration; index++) { if (list [index] > list [index +1]) { elemType temp = list[index]; list [index] = list[index + 1]; list[ index + 1] = temp; } } } }

bubble

The following is the pseudocode for which type of algorithm? For maxElement = each subscript in the array, from the last to the first For index = 0 To maxElement - 1 If array[index] > array[index + 1] swap array[index] with array[index + 1] End If End For End For a. bubble sort b. binary sort c. bubble search d. selection sort e. None of these

bubble sort

After the following statements execute, what are the contents of matrix? int matrix[3][2]; int j, k; for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) matrix[j][k] = j + k; Group of answer choices a) 0 0 1 1 2 2 b) 0 1 2 3 4 5 c) 0 1 1 2 2 3 d) 1 1 2 2 3 3

c) 0 1 1 2 2 3

The formula to find the index of the middle element of a list is _________. a. (mid + last)/2 b.(first + last) - 2 c. (first + last) / 2 d. (first + mid) *2

c. (first + last) /2

Assume that list consists of the following elements. What is the result after bubble sort completes? int list [ ] = {2, 56, 34, 25, 73, 46, 89, 10, 5, 16}; a. 89 73 56 46 25 16 10 5 2 b. 2 56 34 25 5 16 89 46 73 c. 2 5 10 16 25 34 46 56 73 89 d. 2 10 16 25 34 46 56 73 89

c. 2 5 10 16 25 34 46 56 73 89

If n = 1000, to sort the list, bubble sort makes about ____ item assignments. a. 10,000 b. 100,000 c. 250,000 d. 500,000

c. 250,000

Consider the following list: int list [ ] = {4, 8, 19, 25, 34, 39, 45, 48, 66, 75, 89, 95} When performing a binary search, the target is compared first with _____. a. 4 b. 25 c. 39 d. 95

c. 39

We can trace the execution of a comparison-based algorithm by using a graph called a _____. a. pivot table b. partition table c. comparison tree d. merge tree

c. comparison tree

Which of the following correctly states the quick sort algorithm? a. if (the list size is greater than 1) { a. Partition the list into four sublists. b. Quick sort sublist1. c. Quick sort sublist2. d. Quick sort sublist3. e. Quick sort sublist4. d. Combine the sorted lists. } b. a. Find the location of the smallest element. b. Move the smallest element to the beginning of the unsorted list c. if(the list size is greater than 1) { a. Partition the list into two sublists, say lowerSublist and upperSublist. b. Quick sort lowerSublist c. Quick sort upperSublist d. Combine the sorted lowerSublist and sorted upperSublist } d. if the list is of a size greater than 1 { a. Divide the list into two sublists b. Merge sort the first sublist c. Merge sort the second sublist. d. Merge the first sublist and the second sublist }

c. if(the list size is greater than 1) { a. Partition the list into two sublists, say lowerSublist and upperSublist. b. Quick sort lowerSublist c. Quick sort upperSublist d. Combine the sorted lowerSublist and sorted upperSublist }

In a bubble sort for list of length n, the first step is to compare elements _____. a. list [0] and list [n] b. list[0] and list [n-1] c. list [0] and list[1] d. list[n-1] and list[n+1]

c. list[0] and list[1]

When working with the unsorted portion of a list, the second step in a selection sort is to _____. a. divide the list into two parts b. move the smallest element to the top of the list (position 0) c. move the smallest element to the beginning of the unsorted list d. find the smallest element

c. move the smallest element to the beginning of the unsorted list

rectangleType rectangle;

class rectangleType { public: void setLengthWidth(double x, double y); //Postcondition: length = x; width = y; void print() const; //Output length and width; double area(); //Calculate and return the area of the rectangle; double perimeter(); //Calculate and return the parameter; rectangleType(); //Postcondition: length = 0; width = 0; rectangleType(double x, double y); //Postcondition: length = x; width = y; private: double length; double width; }; Consider the accompanying class definition. Which of the following variable declarations is correct? Group of answer choices rectangle rectangleType; class rectangleType rectangle; rectangleType rectangle; rectangle rectangleType.area;

bigRect.setLengthWidth(3.0, 2.0);

class rectangleType { public: void setLengthWidth(double x, double y); //Postcondition: length = x; width = y; void print() const; //Output length and width; double area(); //Calculate and return the area of the rectangle; double perimeter(); //Calculate and return the parameter; rectangleType(); //Postcondition: length = 0; width = 0; rectangleType(double x, double y); //Postcondition: length = x; width = y; private: double length;double width;}; Consider the accompanying class definition, and the object declaration:rectangleType bigRect(14,10); Which of the following statements is correct? Group of answer choices bigRect.setLengthWidth(); bigRect.setLengthWidth(3.0, 2.0); bigRect.length = 2.0; bigRect.length = bigRect.width;

If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class, you use the statement ____. Group of answer choices classD::functionName(); classB::functionName(); classD.functionName(); classB.functionName();

classB::functionName();

A program or software that uses and manipulates the objects of a class is called a(n) ____________________ of that class.

client

insertion and selection

common tasks of data structures

To construct a search algorithm of the order less than log2n, it cannot be ______ based

comparison

Which of the following is the syntax to declare the operator function operator[] as a member function of a class for constant arrays? Group of answer choices const Type& []operator(int index) const; const Type& operator[](int index) const; const Type& operator[](int index); const Type [](int index) const;

const Type& operator[](int index);

The general syntax for the function prototype to overload the assignment operator = for a class is ____. Group of answer choices friend className& operator=(const className&); className& operator=(className&); string className& operator=(className&); const className& operator=(const className&);

const className& operator=(const className&);

To guarantee that the member variables of a class are initialized, you use ____. Group of answer choices accessors mutators constructors destructor

constructors

The postfix expression 3 5 + 2 ; 6 - = will generate an error, because it ______.

contains an illegal operator

The ____ constructor is executed when an object is declared and initialized by using the value of another object. Group of answer choices default copy struct class

copy

When moving array values for insertion sort, to move list[4] into list[2], first ____. a. move list [2] to list [3] b. delete list[2] c. move list [4] to list[3] d. copy list[4] into temp

d. copy list[4] into temp

If a list of eight elements is sorted using selection sort, the unsorted list is ____ after the second iteration. a. list[ 0 ] . . . list[ 1 ] b. list[ 0 ] . . . list[ 6 ] c. list[ 1 ] . . . list[ 7 ] d. list[ 2 ] . . . list[ 7]

d. list[ 2 ] . . . list[ 7]

Consider the following list: int list [ ] = {4, 8, 19, 25, 34, 39, 45, 48, 66, 75, 89, 95} When performing a binary search for 75, after the first comparison, the search is restricted to _____. a. list[0]...list[6] b. list[0]...list[7] c. list[5]...list[11] d. list[6]...list[11]

d. list[6]...list[11]

In the bubble sort algorithm, the following code accomplishes swapping values in elements at positions index and index + 1 a. list[index] = list[index + 1] list[index + 1] = list[index] b. list[index + 1] = list[index] list[index ] = list[index + 1] c. list[index] = temp; list[index ] = list[index + 1]; temp = list[index + 1]; d. temp = list[index]; list[index] = list[index + 1]; list[index + 1] = temp;

d. temp = list[index]; list[index] = list[index + 1]; list[index + 1] = temp;

sequential

data can be organized and processed sequentially using an array, called a(n) ____ list. Group of answer choices linked ordered sequential ascending

unordered_set()

data structure in c++ used for hashing

heaps

data structure used mostly for fetching the smallest/largest data

lists

data structure used mostly for sorting data

trees

data structure used mostly when searching

stacks, queues, and deques

data structure(s) used mostly for quick access of data

A(n) ____________________ ordering of the vertices of the accompanying graph is 0, 1, 4, 3, 2, 5, 7, 8, 6, 9.

depth-first

A container that provides quick access to elements at the front and the back of the list is a Group of answer choices stack queue deque All of these None of these

deque

This is a container that provides quick access to elements at the front and the back of the list.

deque

This is a double-ended queue.

deque

The new classes that we create from existing classes are called ____ classes. Group of answer choices sibling base derived parent

derived

When an array is sorted from highest to lowest, it is said to be in a. reverse order b. forward order c. ascending order d. descending order e. None of these

descending order

In a(n) ____ graph, the edges are drawn using arrows. Group of answer choices pointed vector directed undirected

directed

In a(n) ____________________ graph, the tail of a pictorial directed edge is the origin, and the head is the destination.

directed

A function is called ____ if it calls itself.

directly recursive

A struct is typically a ____ data structure. Group of answer choices simple dynamic heterogeneous linked

heterogeneous

simple approach: increase M

how do we ensure that the load factor L is small?

new_hashcode = old_hashcode%5;

how do we reduce hash codes (from 10 integers to 5 integers)?

1. every item is mapped into a bucket using a hash function (a typical hash function computes for (i) the hash code and (ii) the index = hash_code%M) 2. if L is so large, increase M 3. resolve ambiguity with external chaining or open addressing

how is hashing implemented?

In a graph directed G, for each vertex, v, the vertices adjacent to v are called ____ successors. Group of answer choices immediate adjacent path parallel

immediate

Let e (u, v) be an edge in an undirected graph G. The edge e is said to be ____________________ on the vertices u and v.

incident

pointer variable

int = *p declares a_________________________

Which of the following statements declares alpha to be an array of 25 components of the type int? Group of answer choices int alpha[25]; int array alpha[25]; int alpha[2][5]; int array alpha[25][25];

int alpha[25];

Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with the component type int? Group of answer choices int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}}; int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5}; int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5}; int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

Consider the following declaration: int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this statement? Group of answer choices int alpha[] = {3, 5, 7, 9, 11}; int alpha[] = {3 5 7 9 11}; int alpha[5] = [3, 5, 7, 9, 11]; int alpha[] = (3, 5, 7, 9, 11);

int alpha[] = {3, 5, 7, 9, 11};

Lines 5 and 6

int foo(int n) //Line 1 { //Line 2 if (n == 0) //Line 3 return 0; //Line 4 else //Line 5 return n + foo(n - 1); //Line 6 } //Line 7 Consider the accompanying definition of a recursive function. Which of the statements represent the general case?

Lines 3 and 4

int foo(int n) //Line 1 { //Line 2 if (n == 0) //Line 3 return 0; //Line 4 else //Line 5 return n + foo(n - 1); //Line 6 } //Line 7 Consider the accompanying definition of a recursive function. Which of the statements represents the base case?

27

int mystery(int list[], int first, int last) { if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last); } Consider the accompanying definition of the recursive function mystery. Given the declaration: int alpha[5] = {1, 4, 5, 8, 9}; what is the output of the following statement? cout << mystery(alpha, 0, 4) << endl;

66

int mystery(int list[], int first, int last) { if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last); } Consider the accompanying definition of the recursive function mystery. Given the declaration: int beta[10] = {2, 5, 8, 9, 13, 15, 18, 20, 23, 25}; What is the output of the following statement? cout << mystery(beta, 4, 7) << endl;

66

int mystery(int list[], int first, int last) { if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last); } Consider the accompanying definition of the recursive function mystery. Given the declaration: int beta[10] = {2, 5, 8, 9, 13, 15, 18, 20, 23, 25}; What is the output of the following statement? cout << mystery(beta, 4, 7) << endl; Group of answer choices 27 33 55 66

42

int puzzle(int start, int end) { if (start > end) return start - end; else if (start == end) return start + end; else return end * puzzle(start + 1, end - 1); } Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << puzzle(3, 7) << end;

720

int puzzle(int start, int end) { if (start > end) return start - end; else if (start == end) return start + end; else return end * puzzle(start + 1, end - 1); } Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << puzzle(5, 10) << endl;

Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?

int rFibNum(int a, int b, int n)

10

int recFunc(int num) { if (num >= 10) return 10; else return num * recFunc(num + 1); } Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << recFunc(10) << endl;

720

int recFunc(int num) { if (num >= 10) return 10; else return num * recFunc(num + 1); } Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << recFunc(8) << endl;

10

int recFunc(int num) { if (num >= 10) return 10; else return num * recFunc(num + 1); } Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << recFunc(10) << endl; Group of answer choices 10 11 100 110

Assume you have two integer variables, num1 and num2. Which of the following is the correct way to swap the values in these two variables? a. int temp = num1; num2 = num1; num1 = num2; b. int temp = num2; num2 = num1; num1 = temp; c. num1 = num2; num2 = num1; d. int temp = num1; num2 = temp; temp = num2; num1 = temp; e. None of these

int temp = num2; num2 = num1; num1 = temp;

The header file is also known as the ____________________.

interface file

Inheritance is an example of a(n) ____ relationship. Group of answer choices is-a has-a handshaking had-a

is-a

A(n) __________ search uses a loop to sequentially step through an array. a. binary b. unary c. linear d. relative e. None of these

linear

open addressing

other than external chaining what other ways can ambiguity in hashing be solved?

The following is the pseudocode for which type of algorithm? Set found to false Set position to -1 Set index to 0 While found is false and index < number of elements If list[index] is equal to search value found = true position = index End If Add 1 to index End While Return position a. linear sort b. linear search c. binary search d. selection sort e. None of these

linear search

A dynamic stack may be implemented as a(n) ________ and can expand or shrink with each push or pop operation. Group of answer choices array structure linked list Either array or structure None of these

linked list

A dynamic stack may be implemented as a(n) ________, and expand or shrink with each push or pop operation.

linked list

The QuickSort algorithm is used to sort ________.

lists stored in arrays or linear linked lists

An edge incident on a single vertex is called a(n) ____. Group of answer choices block cycle component loop

loop

The queue data structure is commonly applied in connection with:

managing the order of print jobs, communications software, operating systems

1. load_factor() 2. bucket(item x) 3. bucket_count()

methods that can be used under the hashing c++ data structure

A binary search begins with the __________ element of an array. a. first b. last c. largest d. middle e. None of these

middle

For a list of length n, the bubble sort makes exactly ________ key comparisons

n(n-1)/2

A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____. Group of answer choices matrix vector n-dimensional array parallel array

n-dimensional array

Regardless of the algorithm being used, a search through an array is always performed a. from lowest to highest element b. from highest to lowest element c. beginning with the middle element d. using a binary search algorithm e. None of these

none of these

In evaluating a postfix expression, when the end of expression is encountered, how many elements must the stack contain so that no error is generated?

one

Any function that overloads an operator is called a(n) ____________________ function.

operator

class rectangleType { public: void setLengthWidth(double x, double y); //Postcondition: length = x; width = y; void print() const; //Output length and width; double area(); //Calculate and return the area of the rectangle; double perimeter(); //Calculate and return the parameter; rectangleType(); //Postcondition: length = 0; width = 0; rectangleType(double x, double y); //Postcondition: length = x; width = y; private: double length; double width; }; Consider the accompanying class definition. Which of the following variable declarations is correct? Group of answer choices rectangle rectangleType; class rectangleType rectangle; rectangleType rectangle; rectangle rectangleType.area;

rectangleType rectangle;

A definition in which something is defined in terms of a smaller version of itself is called a(n) ____ definition.

recursive

Consider the following statements: void pointerParameters(int* &p, double *q) { . . . } In the function pointerParameters, the parameter p is a(n) ____________________ parameter.

reference

If a variable is passed by ____________________, then when the formal parameter changes, the actual parameter also changes.

reference

The top node of a comparison tree is call the ________ node.

root

A tree in which a particular vertex is designated as a root is called a(n) ____ tree. Group of answer choices spanning weighted free rooted

rooted

A __________ algorithm is a method of locating a specific item of information in a larger collection of data. a. sort b. search c. standard d. linear e. None of these

search

Stores 50 in the info field of the newNode

struct nodeType { int info; nodeType *link; }; nodeType *head, *p, *q, *newNode; newNode = new nodeType; Consider the accompanying code. What is the effect of the following statement? newNode->info = 50; Group of answer choices Stores 50 in the info field of the newNode Creates a new node Places the node at location 50 Cannot be determined from this code

A set Y is called a(n) ____________________ of X if every element of Y is also an element of X.

subset

Given the following declaration: int j; int sum; double sale[10][7]; which of the following correctly finds the sum of the elements of the fourth column of sale? Group of answer choices sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][3]; sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][4]; sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][4]; sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][3];

sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][3];

A recursive function in which the last statement executed is the recursive call is called a(n) ____ recursive function.

tail

Using a class ____________________ allows you to define an arrayListType that can process any type of list.

template

When an exception is thrown, if the program does not handle the exception, then the function ____ is called to terminate the program. Group of answer choices log what terminate close

terminate

The __________ is adequate for searching through small arrays. a. binary search b. the linear search c. unary search d. bubble sort e. None of these

the linear search

The postfix expression 14 2 5 + = will generate an error, because ______.

there will be too many elements in the stack when the equal sign is encountered

Throwing an exception is typically done using the ____________________ statement.

throw

Which of the following statements throws a valid exception in C++? Group of answer choices throw.function(); throw 2; throws str; 4 throw;

throw 2;

The ____ element of the stack is the last element added to the stack. Group of answer choices top bottom head tail

top

The _____ element of the stack is the last element added to the stack.

top

The addition and deletion of elements of a stack occurs only at the ______ of the stack.

top

The QuickSort algorithm works on the basis of

two sublists and a pivot

The general form of a pointer variable declaration is −

type *var-name; int *ip; // pointer to an integer double *dp; // pointer to a double float *fp; // pointer to a float char *ch // pointer to character

Popping an element from an empty stack is called ____. Group of answer choices overflow underflow exception overloading

underflow

The ____ of sets A and B is the set of all elements that are in A or in B. Group of answer choices intersection union graph reunion

union

When an exception is thrown in a function, the function-call stack is ____ so that the exception can be caught in the next try/catch block. Group of answer choices destroyed allocated unbound unwound

unwound

True or False (T/F)

values given to the index of a data indexed set

store address of var in pointer variableint

var = 20; // actual variable declaration. int *ip; // pointer variable ip = &var; - Does what ? _________________________________________

A dynamic stack has a ________ size, and is implemented as a(n) ________.

variable, linked list

The Standard Template Library offers a stack template that may be implemented as a:

vector, deque, linked list

A graph G is a pair, G = (V, E), where V is a finite nonempty set called the set of ____ of G, and the elements of E are the pairs of elements of V. Group of answer choices nodes branches vertices edges

vertices

C++ provides ____ functions as a means to implement polymorphism in an inheritance hierarchy, which allows the run-time selection of appropriate member functions. Group of answer choices redefined overridden virtual overloaded

virtual

Lines 3-6

void printNum(int num) //Line 1 { //Line 2 if (n < 0) //Line 3 cout << "Num is negative" << endl; //Line 4 else if (num == 0) //Line 5 cout << "Num is zero" << endl; //Line 6 else //Line 7 { //Line 8 cout << num << " "; //Line 9 printNum(num - 1); //Line 10 } //Line 11 } //Line 12 Consider the accompanying definition of a recursive function. Which of the statements represent the base case?

Lines 7-11

void printNum(int num) //Line 1 { //Line 2 if (n < 0) //Line 3 cout << "Num is negative" << endl; //Line 4 else if (num == 0) //Line 5 cout << "Num is zero" << endl; //Line 6 else //Line 7 { //Line 8 cout << num << " "; //Line 9 printNum(num - 1); //Line 10 } //Line 11 } //Line 12 Consider the accompanying definition of a recursive function. Which of the statements represent the general case?

In a queuing system, every customer has a customer number, arrival time, ____________________ time, transaction time, and departure time.

waiting

A minimal spanning tree of G is a spanning tree with the minimum ____. Group of answer choices path cycle weight height

weight

In a graph G, if the edges connecting two vertices have weights assigned to them, the graph is called a ____ graph. Group of answer choices source weighted spanning minimal

weighted

defined also as the number of indices of a data indexed set

what are buckets?

hashing without bucketing results to an array that has indices that may or may not contain data, and thus will be memory inefficient

what are the disadvantages of having large M?

What is the output of the following code? queueType<int> queue; int x, y; x = 2; y = 3; queue.addQueue(x); queue.addQueue(y); x = queue.front(); queue.deleteQueue(); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); y = queue.front(); queue.deleteQueue(); cout << "x = " << x << endl; cout << "y = " << y << endl; x = 2 y = 4 x = 4 y = 3 x = 2 y = 3 x = 3 y = 2

x = 2 y = 3

What is the output of the following code? queueType<int> queue; int x, y; x = 2; y = 3; queue.addQueue(x); queue.addQueue(y); x = queue.front( ); queue.deleteQueue( ); queue.addQueue(x + 2); queue.addQueue(x); queue.addQueue(y - 3); y = queue.front( ); queue.deleteQueue( ); cout << "x = " << x << endl; cout << "y = " << y << endl;

x = 2; y = 3;

What is the output of the following code? stackType<int> stack; int x, y; x = 4; x = 2; stack.push(6); stack.push(x); stack.push(x + 1); y = stack.top( ); stack.pop( ); stack.push(x + y); x = stack.top( ); stack.pop( ); cout << "x = " << x << endl;

x = 9

When a stack is implemented as an array, the array is empty if the value of a stackTop is ______.

zero


Conjuntos de estudio relacionados

Beckers World of the Cell: chapter 4a, multiple choice

View Set

HESI Adaptive Quizzing - Musculoskeletal

View Set

international relations midterm II

View Set

Marketing Mindtap for Chapters 10, 16, 17, 18

View Set