cs dsa

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

For the growth function 5nlogn, type a value (a positive integer) for which this function is the most efficient of the six. If there is no integer value for which it is most efficient, type "none".

1

For the growth function n!, type a value (a positive integer) for which this function is the most efficient of the six. If there is no integer value for which it is most efficient, type "none".

2

Suppose T is a binary tree with 14 nodes. What is the minimum possible height of T?

3

For the growth function 2^n, type a value (a positive integer) for which this function is the most efficient of the six. If there is no integer value for which it is most efficient, type "none".

4

What is the minimum number of internal nodes in a binary tree with 8 nodes?

4

Suppose that Selection Sort is given an input of 100 records, and it has completed 45 iterations of the main loop. How many records are now guaranteed to be in their final position (never to be moved again by the sort)?

45

For the growth function 10n, type a value (a positive integer) for which this function is the most efficient of the six. If there is no integer value for which it is most efficient, type "none".

6

Suppose that a particular algorithm has time complexity T(n) = 8nT(n)=8n and that executing an implementation of it on a particular machine takes t t seconds for n inputs. Now suppose that we are presented with a machine that is 64 times as fast. How many inputs could we process on the new machine in tt seconds?

64n

What is the minimum number of nodes in a full binary tree with height 3?

7

What is the minimum number of nodes in a complete binary tree with height 3?

8

What is the maximum depth for the series of recursive calls that can be made?

As many as it takes to reach the base case

Why does function preorder2() presented in the Traversal module make only half as many recursive calls as function preorder()?

Because half of the pointers are null

Which statement is false?

Every binary tree has at least one node

The terms "insert" and "delete" are traditionally associated with which data structure(s)?

List

The order of the input records has what impact on the number of comparisons required by Bubble Sort (as presented in this module)?

None

The order of the input records has what impact on the number of comparisons required by Selection Sort (as presented in this module)?

None

Which of these is the best upper bound for a growth rate of 5n + 3?

O(n)

What is the average-case time for Selection Sort to sort an array of n records?

O(n^2)

What is the running time for Bubble Sort when the input array has values that are in reverse sort order?

O(n^2)

What is the running time of Bubble Sort (as the algorithm is presented in this module) when the input is an array that has already been sorted?

O(n^2)

What is the running time of Bubble Sort when the input is an array where all record values are equal?

O(n^2)

What is the worst-case time for Bubble Sort (as the algorithm is presented in this module) to sort an array of nn records?

O(n^2)

Which of these is the best upper bound for a growth rate of 5n + 35n+3?

O(nlogn)

Which data structure allows insertion only at the back, and removing only from the front?

Queue

Which statement best characterizes Selection Sort (as the code is written in this module)? Recall that a stable sorting algorithm maintains the relative order of records with equal keys.

Selection Sort is not stable, but with minor modifications it could be made so

A recursive function causes an infinite recursion (run-time error) if:

The base case is never executed or does not exist.

BST search, insert, and delete operations typically run in time O(d). What is d?

The depth of the relevant node in the tree

On a real computer, what will happen if you make a recursive call that never makes the problem size smaller?

The run-time stack overflows, halting the program

For sequential search, the best case occurs when:

The search target is near the front of the array

When is Bubble Sort a good choice for sorting an array?

There is no situation where Bubble Sort is the best choice over all of the others in this chapter

Visiting each element in a tree is known as:

Traversing

Which of the following is not a linear data structure?

Tree

What is the depth of this tree?

Trees have height -- they do not have depth

Selection sort is simple, but less efficient than the best sorting algorithms.

True

In which cases are the time complexities the same for Bubble Sort (as the algorithm is presented in this module)?

Worst, Average and Best

In which cases are the time complexities the same for Selection Sort?

Worst, Average and Best

Stack A has entries a, b, c (in that order with a on top), while Stack B is initially empty. When an entry is popped out of stack A, it can be printed immediately or pushed to stack B. When an entry is popped out of stack B, it can only be printed. Which of the following permutations of a, b, c is not possible to print?

c a b

It is an error to dequeue data from a(n) _______ queue.

empty

A BST is another name for a binary tree.

false

Every recursive method must have a return value.

false

If you are given the order of the nodes as visited by a preorder traversal and the order of the nodes as visited by a postorder traversal, do you have enough information to reconstruct the original tree? Assume that the nodes all have unique values.

false

In order to do an exact-match search, the key values must define a total order

false

One good general-purpose solution to the problem of getting a key from a record is to define a special method such as ".key()"

false

Selection Sort (as the code is written in this module) is a stable sorting algorithm. Recall that a stable sorting algorithm maintains the relative order of records with equal keys.

false

{Most programming languages will let us re-define "<" and ">" to handle comparison of arbitrary objects| We can generally rely on "<" and ">" to let us compare arbitrary record types}

false

Queue behavior is typically referred to as:

fifo

In the worst case, the total number of swaps done by Selection Sort is closest to:

n

How many times does Selection Sort call the swap function on an array of n records?

n-1

In the worst case, the total number of comparisons for Selection Sort is closest to:

n^2/2

For the growth function 20n, type a value (a positive integer) for which this function is the most efficient of the six. If there is no integer value for which it is most efficient, type "none".

none

For the growth function 2n^2, type a value (a positive integer) for which this function is the most efficient of the six. If there is no integer value for which it is most efficient, type "none".

none

Which boolean expression indicates whether the values for the nodes pointed to by p and q are the same? Assume that neither p nor q is null.

p.element() == q.element()

The term "FIFO" is associated with which data structure?

queue

n the linked implementation of a queue, a new item would be added to the

rear

Which data structure is used for recursion

stack

Defining a record's key field is a property of

the context of the search

Which value of a queue is accessible?

the front

In a recursive function, what is the maximum number of recursive calls allowed?

there is no fixed maximum

Bubble Sort (as the code is written in this module) is a stable sorting algorithm. Recall that a stable sorting algorithm maintains the relative order of records with equal keys.

true

If you are given the order of the nodes as visited by a postorder traversal and the order of the nodes as visited by an inorder traversal, do you have enough information to reconstruct the original tree? Assume that the nodes all have unique values.

true

In order to be able to sort, the key values must define a total order

true

Infinite recursion can occur if some recursive call does not reduce the problem in a manner that allows it to eventually converge into the base case.

true

One good general-purpose solution to the problem of getting a key from a record is to store Key/Value pairs in the search structure

true

Sometimes, using recursion enables you to give a natural, straightforward solution for a program that would otherwise be difficult to solve.

true

The Sequential Search algorithm is in O(n^2)

true

The problem with using a ".key()" method to get the key from a record is that we can't use this same method to get different fields for different searches

true

When you print out the nodes of binary tree, the leaf nodes appear in the same relative order for the preorder, inorder, and postorder traversals.

true

Determine Θ for the following code fragment in the average case. Assume that all variables are of type "int". a= b + c d = a + e

Θ(1)


Set pelajaran terkait

Health Insurance Policy Provisions (6) end questions

View Set

A&P Module 6 - Heart and Vessels Dissection Homework

View Set

Chapter 19- Vital Signs (Part 2)

View Set

54. English Phrasal Verbs in Use Advanced, Unit 54, Technology

View Set

Type of reproduction by which offspring are produced from _________________________ parents.

View Set

Chapter 12: The Postpartum Woman

View Set

Network Layer - The Internet Protocol - part 2 - Slide# 13

View Set

Chapter 1.1-1.5, Chapter 3.1-3.4, 7.1-7.5, Chapter 11.1-11.7 Econ 105 Cypress College

View Set

Chapter 9 - Molecular Diagnostics

View Set