CS Final Practice

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The consequences of infinite recursion include which of the following? "Run-Time Stack Overflow" error occurs Memory space consumed Run-time stack grows Program memory usage decreases Computation speed increases

"Run-Time Stack Overflow" error occurs, Memory space consumed, Run-time stack grows

What is output at line 22? Image #5

1100

What is the maximum number of children a binary search tree node may have?

2

What sort most closely resembles the pseudocode description below? set current to the index of the first item in the array while more items in unsorted part of the array "Bubble up" the smallest item in the unsorted part, causing intermediate swaps as needed shrink the unsorted part of the array by incrementing current

Bubble Sort

Folding makes hash collisions impossible.

False

Bubble Sort

Move the smallest unsorted element in the range A(i) through A(N-1) to position A(i) by swapping as needed.

Which of the following statements correctly uses dynamic allocation to create an array of ten integers and stores the base address of this array into the pointer variable called newarray on line 14?

Newarray = new int[10];

Are the following two implementations of the overloaded add function allowed to both be used in the same program? Image #4

No

Throw

Signals that an exception has occurred.

Metric based testing allows an engineer to measure how complete the testing performed is. True/False

True

Direct Recursion

When a function calls itself.

Try

contains statements that may cause an exception.

In the above image, the edges have no direction. This is an example of what type of graph? Graph #1

undirected graph

Copy constructors must

utilize a class's constructor with parameter pointing to the object to be copied.

When inserting an item into a sorted linked list

walk through the list nodes until the insertion location is found.

Recursive Call

A function call in which the function being called is the same as the one making the call.

The sequential implementation of a list is based on a(n)

Array

Which is not a real option for handling program errors?

Assume errors will not occur

Which step typically catches more bugs?

Compile

A tree node may have more than one parent node. True/False

False

Agile process is scrum. True/False

False

ReheapDown is used when the leaf node is out of order

False

Which feature of a list allows stepping through the list item by item?

Iterator

What abstract data type is used to conduct a breadth-first traversal of a graph?

Queue

Selection Sort

Repeatedly move the smallest unsorted element to the front of the unsorted elements.

The _____________ abstract data type has a Last In First Out (LIFO) data flow property?

Stack

Catch

Statements that handle what was thrown.

The height of a tree abstract data type is

The maximum level in a tree

A Memory Leak is the loss of available memory space that occurs when memory is allocated but not deallocated. True/False

True

A collision result is when two or more keys produce the same hash location.

True

Hashing uses (key, value) pairs for ordering and accessing list elements which can permit O(1)("constant") searching.

True

In Object Oriented Analysis and Design (OOAD), a use case model captures the functional requirements.

True

Which item below correctly declares two pointer variables with names A and B that can point to variables of type int?

int *A, *B;

Which of the following statements correctly declares an uninitialized pointer variable called newarray that will eventually point to an array of integers on line 10?

int* newarray;

Insertion into a linked implementation of a list abstract data type requires ____________ position pointers.

previous and current

ReheapUp is used when the root node is out of order

False

Which ADT's is sorted (necessarily ordered in *some* way)

Heap

Which type of code review should follow a formal process?

Inspections

In Object Oriented Analysis and Design (OOAD), which describes the names, class relations (e.g. Circle is a subclass of Shape), operations, and properties of the main objects?

Object Model

Which implementation correctly implements the factorial function using direct recursion? //Option 1 //Option 2 //Option 3 Image #1

Option 1

A function template is a C++ construct that allows the compiler to generate multiple versions of a function by allowing parameterized types.

True

Assume the list above is to be sorted with Quicksort. Split the list into left and right groups. Image #6

(17,11,6,10,2), (21,60,33) | (17,33,6,10), (2,21,60,11) | (17,33,6,10,2), (21,60,11) | (2,11,6,10,17), (21,60,33)

Which abstract data types is (necessarily) sorted?

Binary Search Tree

Which data structure is the fastest for searching for a specific item?

Binary Search Tree

Which is true about deep copies?

Copy each element of a object into new memory.

Metric based testing allows an engineer to measure how much testing has been performed. True/False

False

Which properties are true about the linked implementation of a list?

Nodes may not be consecutive in memory, inserting into a sorted list is easier, Easy to resize the size of the list.

Consider the code below. void Print(NodePtr head) { if (head != NULL) { Print(head->next); cout << head->info << ","; } } If the variable headPtr points to a linked list with the contents shown below. Where the numbers shown are the info element in the node and the next pointer is implied to point to the next node as illustrated. headPtr -> 45 -> 78 -> 1066 -> 1492 -> NULL What is the expected output of the call below? Print(headPtr);

1492,1066,78,45

Consider the graph above. If a Depth-First-Search is being performed to find the shortest path from A to G, what is the distance of the first path to be processed assuming the algorithm always takes the shortest edge not previously visited? Graph #2

16

Use Radix sort to sort the following list of numbers using base 10. What is the list order after the first pass? 346, 22, 31, 212, 157, 102, 568, 435, 8, 14, 5

31, 22, 212, 102, 14, 435, 5, 346, 157, 568, 8

Consider the graph above. If a Depth-First-Search is being performed to find the shortest path from A to G, what are the first two paths considered? For each traversal, assume the algorithm always takes the shortest edge not previously visited. Graph #2 ABDG, ABJG ABDEG, ACFKJG ABDEG, ABDHIG ABDEG, ABDG

ABDEG, ABDG

When building a list(collection) of vertices, which function(s) listed is/are necessary? (Assuming the functions do what their name says)

AddVertex()

When inserting a new data value into an Unsorted Linked List, where is the most efficient position to add the new data value?

Before the first element currently stored in the container

Which is faster binary or linear search?

Binary

Which graph traversal algorithm looks at all possible paths of the same depth before going to a deeper level?

Breath First Search

A complete binary tree is.

Either full(left and right nodes populated) or full through the next-to-last level, with the leaves on the last level as far to the left as possible.

A heap is the same as a binary search tree. True/False

False

An O(N^2) implementation is faster than a O(Nlog2N) algorithm.

False

An advantage of the array-based implementation of stacks is that the stack size is easily changed to accommodate additional data. True/False

False

In Object Oriented Analysis and Design (OOAD), a use case model captures non- functional requirements.

False

Consider the declaration of a Queue class below. Image #7 If the following three operations were executed on queue Q, which below best describes the state of the queue afterwards? Q.add(12); Q.add(7); Q.add(18);

Front { 12, 7, 18 } Rear

Consider the declaration of a Queue class below. If the following four operations were executed on queue Q, which below best describes the state of the queue afterwards? Q.add(12); Q.add(7); Q.add(18); x = Q.remove();

Front { 7, 18 } Rear

Which line of code correctly allocates memory for a LinkedList object and assigns the new address to the pointer head?

Head = new LinkedList();

Which of the following sorting algorithms does not require O(N2) steps in the worst case?

Heap Sort

What is the correct definition of the binary search tree property?

Key value of a node is greater than that in any node of its left subtree and less than that in any node of its right subtree

Assuming that the Queue contains N data values, the complexity of code to count the items in the queue by walking the linked list from front to rear is best described as which of the following?

O(N)

Which is the correct usage of a class template. //Option 1 //Option 2 //Option 3 //Option 4 Image #3

Option 1

Which of the three options shown below correctly overloads the == operator for the Time class? Image #2

Option 2

Which properties are true about the sequential implementation of a list?

Resizing is inefficient, searching for an item is cost bounded, insert and delete functions are efficient.

What sort most closely resembles the pseudocode description below? while more items in unsorted part of the array find the index of the smallest unsorted item swap the current item with the smallest unsorted one shrink the unsorted part of the array by incrementing current

Selection Sort

A hash function manipulates a value in a collection to identify its proper location in the array.

True

A stack abstract data type may be implemented with a array or linked list.

True

An exception is an unusual event, detectable by software or hardware, that requires special processing.

True

Each activity in the waterfall process produces a document or product that is an input for the next activity. True/False

True

Operator overloading requires use of the operator keyword.

True

Quicksort is recursive.

True

ReheapDown is used when the root node of the heap is out of order. True?False

True

ReheapUp is used when a leaf node is out of order. True/False

True

Scrum is a kind of Agile process. True/False

True

Stack overflow is a condition resulting from trying to push an element on a full.

True

The root of a heap is always the greatest value in the heap. True/False

True

Typically, a sorting algorithm which requires more memory requires less time to sort.

True

Function overloading allows one function name to refer to multiple functions so long as the parameter lists are distinct

True.

When finding the short path through a graph, which best represents a greedy implementation?

Visiting adjacent nodes with lowest weight edge first.

Given a pointer variable with name A that can point to a variable of type int, which statement below will output the value of the int variable pointed to by A?

cout << *A << endl;

Which exception is thrown by the new command when the program is out of memory?

std::bad_alloc


संबंधित स्टडी सेट्स

Chapter 22 Head and Spinal Cord Injuries EAQ

View Set

APUSH REVIEW - [PERIOD and COURSE OUTLINE]

View Set