CS 235 Final Study

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

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

False

True or false: There is always a recursive solution to a problem that is solvable by iteration

False

A priority queue

Is a container adapter that uses a specific underlying container, e.g. vector or deque.

The sequential representation of ADT deque:

Isn't practical, too many O(n) operations

If you need to provide a stack, a queue, a deque, an input-restricted deque, and an output-restricted deque:

Each of the others should "have" a deque as a data member

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: Every binary tree is either complete or full

False

True or false: A node's inorder predecessor, a node's parent, the largest value in the node's left subtree, the value found by going left from the node and then going right as far as possible, are the same thing

False, they're all the same thing except for the parent

Which of the following functions is the LEAST efficient when implemented recursively? - Calculating n factorial, calculating the nth Fibonacci number, Finding the greatest common divisor, raising x to the power of n

Fibonacci

What most accurately describes the behavior of a queue?

First in, first out (FIFO)

Compared with a linked list, a binary tree

Has nodes with two child nodes insstead of one next nodes

Which strategy for implementation of stacks/linked lists is most likely to be successful?

Implementing a stack by using an underlying linked list.

A private data member is visible ___

In the class in which it is declared

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

Inorder

Testing the interactions among smaller units is called ___

Integration testing

What accurately describes the behavior of a stack?

Last in, first out

Postorder traversal

Left, right, root

Inorder traversal

Left, root, right

What is the mathing infix expression to the following postfix expression: 8 9 + 4 * -

None, it's invalid

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

Not a unique binary tree.

If the size of a heap is n, the performance is ___ for insertion

O(logN)

Infix->Postfix uses a stack of ___, Postfix evaluation a stack of ___, and postfix->infix a stack of ___

Operators, operands, operators

___ traversal doesn't exist.

Outorder

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.

In tail recursion,

The recursive call is the last executable statement in the function

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

Trees are recursive data structures

There are two general ways to implement ADT Stack:

Using a contiguous structure or a linked structure

For the contiguous representation of ADT deque, when an end of the deque is reached:

Wrap around to the other end

With the recursive binary search algoritm given in the book, how many items in the list need to be checked if the item isn't in the list?

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

The contiguous implementation of ADT deque is ___

more like the implementation of ADT queue

Searching for an item in a linked list is O(___). Searching in a BSTs is o(___).

n, log(n)

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

operators

To check for balanced parentheses, use a stack of ___

parenthese

What's the best way to visit every node of a circular list exactly once?

Begin at the head and ask if the next node in the list is the head

5th rank precedence

<<, >>

14th rank precedence

=

8th rank precedence

& (bitwise and)

11th rank precedence

&& (logical and)

3rd rank precedence

*, /, %

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: + %, * -, + +, / *

+ %

4th rank precedence

+ (addition), - (subtraction),

2nd rank precedence

++, --, +, -, (unary plus/minus) !, ~, new

Polymorphism expects:

- Functions with common signatures at different levels in a hierarchy - Functions with common signatures at different levels, with at least the highest-level function declared virtual - Pointers to objects (probably higher in the heirarchy)

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

If a particular binary tree is full and has 100 leaf nodes, how many internal nodes does it have?

99

6th rank precednece

<, <=, > >=

7th rank precedence

==, !=

13th rank precedence

?: (conditional)

Recursion typically is justified when it reduces

design and coding time

What is a 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

What wouldn't be a good application for a binary tree?

A family tree

Pick the best statement: -A complete binary tree is a full binary tree -A full binary tree is a complete binary tree -A complete binary tree is a full binary tree and vice versa -A full binary tree need not be complete and vice versa

A full binary tree need not be complete and vice versa

What happens when a recursive function calls itself?

A new instance of the function is called

What is recursion?

A problem-solving approach that causes functions to call themselves with differnet arguments

How are stacks and queues related?

A queue differs from a stack in only one operation.

What is the best relationship for queues and deques:

A queue has-a deque

A priority queue is an extension of queue with the following properties:

An element with high priority is dequeued before an element with low priority

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

Which representation of a Queue has the most favorable big O?

Circular Array

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

Containers grow as needed and hold objects.

Generally speaking, an ADT can be represented using a(n) ___.

Contiguous or linked structure

Suppose 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 controls access through your own interface.

A heap

Requires every subtree to be a heap.

Preorder traversal

Root, left, right

With a heap,

The largest complete tree of height h has 2^h -1 nodes

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

1st rank precedence

[], (), ., ->,

9th rank precedence

^ (bitwise exclusive or)

What makes backtracking different from random trial and error?

backtracking is a systemic approach that won't try the same path more than once

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

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

class Ordered_List has-a List

A binary tree's conceptual counterpart of a double-linked list ___

consists of links to left and right subtrees; two links per node

What is the downside of recursion?

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

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

top()

The reallocate function for class Queue ___

typically doesn't copy elements to identical index positions

Writing "towers of Hanoi" code for 64 disks is:

virtually the same as for 3 disks

10th rank precedence

| (bitwise or)

12th rank precedence

|| (logical or0


Kaugnay na mga set ng pag-aaral

Government and the Economy Online Practice

View Set

Pharm Practice Q from Tutoring page

View Set

Geometry (PARALLELOGRAMS: RHOMBUS)

View Set