CS 235 Roper Attendance Quizzes

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following describes testing the smallest testable piece of the software?

Unit testing.

Suppose you have a binary search tree. Which kind of traversal would print the contents in increasing order?

Inorder.

Why might one use a linked list instead of a vector?

Inserting in the middle of a linked list is more efficient.

With the recursive linear search algorithm given in the book, how many items in the list need to be checked if the item is not in the list?

Every item in the list.

True or false: The maze solving algorithm will not function properly if there is more than one possible path through the maze.

False

Which of the following most accurately describes the behavior of a queue?

First in, first out (FIFO).

GET QUESTIONS FROM PREVIOUS LECTURES!!!

GET QUESTIONS FROM PREVIOUS LECTURES!!!

Which of the following most accurately describes the behavior of a stack?

Last in, first out

In what order should catch clauses appear?

Most specific to most general.

The inorder traversal sequence of a binary tree is A B C. The root is _______.

Not a unique binary tree.

__________ traversal doesn't exist.

Outorder

If one class has two functions with the same name, but that take different arguments, this is an example of _______.

Overloading

Why are there two entries for the vector operator[] and at member functions?

The return value can be const or non-const.

When comparing recursion and iteration, all of the following are true EXCEPT

There is always an recursive solution to a problem that is solvable by iteration.

Traversal algorithms are fairly simple. What attribute of trees makes that so?

Trees are recursive data structures.

Suppose you are writing a program with polymorphism, but only the base class functions are being called! What is the likely source of the bug?

You forgot to make the base class functions virtual.

Which of the following is NOT a reason to override a function? a. You are writing a function to implement an ADT. b. You made a child class so you need to override every function. c. You want to change the functionality of a derived class. d. You want to add to the functionality of the base class.

You made a child class so you need to override every function.

With the recursive binary search algorithm given in the book, how many items in the list need to be checked if the item is not in the list?

log(n), where n is the number of items in the list.

Inserting at the head of a single-linked list is _______ inserting at the tail.

more efficient than

The code for a templated vector object ________________.

must be in the header file or in a file included by the header

Searching for an item in a linked list is O(___). Searching in a binary search tree is O(___).

n, log(n)

As a first guess, the order of complexity of three nested loops is probably__________.

n3

What is the Big O of a program which has (i) a nested loop inside a nested loop and the innermost loop has 2 simple statements, (ii) a nested loop with 2,000 simple statements inside the inner loop, and (iii) a loop with 20,000 simple statements?

n3

To check for balanced parentheses, use a stack of

parentheses

The most obvious use of an iterator is as a(n)

pointer

Use of parentheses _______________________.

results in everything within the parentheses evaluating to a single value

The assignment operator __________.

is called when a already initialized object is assigned a new value from another existing object

Postfix and prefix expression operator precedence _______________________.

is determined by their order

The precedence of infix expression operators _______________________.

is superseded by parentheses

What makes backtracking different from random trial and error?

Backtracking is a systemic approach that will not try the same path more than once.

Which of the following stack configurations are correct in terms of precedence? Let the far left be the bottom of the stack, and the right be the top. a. + % b. * - c. + + d. / *

+ %

How many base cases are in the maze solving algorithm?

3

What is the matching postfix expression to the following infix expression: 7 + ( 2 * 3 ) / 9?

7 2 3 * 9 / +

What is the result of the postfix expression: 4 7 * 20 -?

8

What is a C++ concept?

A C++ concept serves as a constraint by limiting the set of arguments that are accepted as template parameters.

What things are necessary in a recursive function?

A base case and a recursive call.

Which of the following would NOT be a good application for a binary tree?

A family tree.

Why might a doubly linked list be more advantageous than a singly linked list?

A singly linked list can only be traversed in the forward direction.

Which of the following is an example of an 'has-a' relationship? a. A jet plane has a plane. b. A plane has a jet plane. c. A train engine has a train. d. A train has a train engine.

A train has a train engine.

Which of the following functions is the least efficient when implemented recursively?

Calculating the nth Fibonacci number.

Which representation of a queue has the most favorable Big Os for the operations (as discussed in class)?

Circular array

What features are considered fundamental by the C++ standard to containers?

Containers grow as needed. Containers hold objects.

How do contiguous and non-contiguous stack implementations compare?

Contiguous implementations have space penalties.

Suppose the following operations are performed on an empty stack: Push A, push B, push C, push E, pop, and push D. What would be the next value to be accessed from this stack?

D

What is C++ object delegation?

Delegation allows exposure to some functionality of a pre-existing class, but still control access through your own interface.

Suppose we are trying to use multiple inheritance, but the compiler reports that there is an ambiguity about our variable named 'var'. What can we do to resolve this error?

Refactor the parent classes by combining them. Rename the variable of one of the parent classes. Specify which parent you are taking the variable from with 'Parent1::var'.

For which type of error are try and catch most appropriate?

Run-time errors.

What is regression testing?

Testing to make sure a change did not have an unintended consequence.

What is the downside of recursion?

The function may result in a run-time error when there is no more memory available.

All of the following are true of iterators EXCEPT what?

The iterator end() function returns a pointer to the last element in the container.

What typically happens as a consequence of the "++iter" component of: for (list<Item>::iterator iter = a_list.begin(); iter != a_list.end(); ++iter) { }

The iterator pointer advances to the next element of the list.

When a recursive function returns after three iterations because it hits a base case, where does it return to?

The previous iteration, right after it called the next iteration.

There are two general ways to implement ADT Stack, ___________ or ___________,

a contiguous structure; a linked structure

The friend declaration

allows a function external to a class to access the private members of that class.

The order of expression operators _______________________.

alone does not guarantee a consistent result

What is the Big-O of a vector reserve function?

amortized order 1

The size of a vector ________________________________.

automatically increases as new elements are added to it

A vector is a template class _________________________.

based on an array

An independent copy refers to __________.

being able to modify one of the objects without affecting the other

When the array representation of ADT queue becomes full, _______.

call a reallocate function specialized for the array-based queue

The contiguous implementation of an ADT queue

calls for a circular array

A nested class ______________.

can lead to more readable and maintainable code

What is the proper relationship between class List and class Ordered_List?

class Ordered_List has-a List

Generally speaking, a sequential ADT can be represented using a(n) ________.

contiguous structure or a linked structure

Recursion typically is justified when it reduces ______________.

design and coding time

A template class typically ______________.

facilitates the same set of operations on a variety of data types

Compared with a linked list, a binary tree ________.

has nodes with two child nodes instead of one next node

For common stack, queue, input-restricted deque, and output restricted deque data structures, each ______________.

should "have-a" deque as a data member

In a class that contains a pointer to a dynamically allocated int, the destructor ________ invalidate the pointer because __________.

should, the memory pointed to by the pointer must be freed to prevent memory leaks

The "order of complexity" of an algorithm expresses ____________.

the limiting behavior of a function when the argument tends towards infinity

When a queue is implemented with a singly-linked list,

the queue class must have a head and tail pointer.

In tail recursion, ____________.

the recursive call is the last executable statement in the function

When two unary operators appear together and have the same precedence, _______________________.

they're evaluated right to left

Suppose you want to access the next element of a stack. Which function would you call?

top()

Which of the following is an example of an 'is-a' relationship? a. A jet plane is a plane. b. A plane is a jet plane. c. A train engine is a train. d. A train is a train engine.

A jet plane is a plane.

Pick the best statement: a. A queue differs from a stack in only one operation. b. A queue differs from a stack in several operations. c. A stack is simply a queue with a different name. d. Stacks and queues are largely unrelated.

A queue differs from a stack in only one operation.

Pick the best relationship for queues and deques.

A queue has-a deque.

Suppose the following operations are performed on an empty queue: Push A, push B, push C, push E, pop, and push D. What would be the next value to be accessed from this queue?

B

Why is Node typically defined as a struct in the private part of the host class?

Because a struct's data members are public by default.

An ADT deque ______________.

is an abbreviation for "double-ended queue" represents a combination of a vector and a list supports random-access iterators and constant-time insertion and removal

What happens if an exception is thrown in a program and not caught?

The program aborts.

Why is the list class required to have a push_front function, but the vector is not?

The push_front function would be O(n), and functions must be at least amortized constant time to be required.

The contiguous implementation of ADT deque is ______________.

more like the contiguous implementation of ADT queue

A vector is _____________ efficient than an array _______________.

more, in terms of coding time, but not execution time or memory usage

C++ a. class type assignment operators can not be overridden and overloaded. b. is what is known as a weakly typed language. c. r-values and l-values must be different types. d. operands have a type and operations can be performed only on operands of the same or compatible types.

operands have a type and operations can be performed only on operands of the same or compatible types.

Pick the correct statement. a. A binary tree is a tree. b. A tree is not a binary tree and a binary tree is not a tree. c. A tree is a binary tree. d. "Tree" and "binary tree" are synonymous.

A binary tree is a tree.

Pick the best statement a. A complete binary tree is a full binary tree. b. A complete binary tree is a full binary tree and a full binary tree is a complete binary tree. c. A full binary tree need not be complete and a complete binary tree need not be full. d. A full binary tree is a complete binary tree.

A full binary tree need not be complete and a complete binary tree need not be full.

What happens when a recursive function calls itself?

A new instance of the function is called.

What kind of pointer should be included in a singly linked node?

A pointer to the next node.

What is recursion?

A problem solving approach that causes functions to call themselves with different arguments.

All of the following are true of Big-O analysis EXCEPT what? a. A simple way to determine the Big-O of an algorithm or program is to look at the loops invariants. b. Algorithms with exponential and factorial growth rates have practical limits due to computer resources. c. In general, we ignore all constants and drop the lower-order terms when determining the order of magnitude. d. The growth rate of f(n) will be determined by the fastest growing term, which is the one with the largest exponent.

A simple way to determine the Big-O of an algorithm or program is to look at the loops invariants.

Which of the following is TRUE concerning abstract classes and concrete classes? a. Concrete classes can define variables, but abstract classes cannot. b. Concrete classes can extend another class, but abstract classes cannot. c. Abstract classes can declare abstract member functions, but concrete classes cannot. d. Abstract classes can extend another class, but concrete classes cannot.

Abstract classes can declare abstract member functions, but concrete classes cannot.

Which of the following is a FALSE statement? a. An abstract class can extend another abstract class. b. An abstract class cannot be instantiated. c. Pointers to an abstract class may be declared. d. An abstract class contains only abstract functions.

An abstract class contains only abstract functions.

If N = size / 2 and M = size * size, what is the Big-O of the following: for (i = 0; i < N; i++) { // Sequence of statements } for (j = 0; j < M; j++) { // Sequence of statements }

O(n2)

To convert from infix (without parentheses) to postfix, use a stack of

operators

Infix-to-postfix uses a stack of ________, postfix evaluation a stack of _______, and postfix-to-infix a stack of _____.

operators, operands, operators

The reallocate function for class Queue

typically does not copy elements to identical index positions.

Writing "towers of Hanoi" code for 64 disks is

virtually the same as for 3 disks.

The default copy constructor may be used EXCEPT __________________.

when a deep copy is required

For the contiguous representation of ADT deque, when an end of the deque array is reached, it ________.

wraps around to the other end


Kaugnay na mga set ng pag-aaral

Order of events: French Revolution

View Set

Chemistry Unit 7 Quizzes 1-3 (Monarch)

View Set

(6) The Structure of the Constitution's Protections of Individual Liberties

View Set

Chemistry (fill in blank and essay)

View Set

Intro to Micro - Chapter 5 Quiz- Microbial Metabolism

View Set

Plate tectonics and the ocean floor

View Set

Ethics Ch. 1-6: Multiple Choice & True/False

View Set