CSCI 211 Chapter 7-10 Questions

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

True

A stack overflow occurs when the stack frame for a method call extends past the end of the stack's memory.

True

Merge sort is a fast sorting algorithm.

True

A recursive method can have two base cases, such as N == 0 returning 0, and N == 1 returning 1.

true

A recursive method with parameter N counts up from any negative number to 0. An appropriate base case would be N == 0.

True

All integers from an array could be placed into the same bucket, even if the array has no duplicates.

false

All iterators provide a remove function to remove an element from a collection.

true

An iterator is in essence a loop to step through (iterate through) a collection

0

Assume a trie is built by executing the following code. trieRoot = new TrieNode() TrieInsert(trieRoot, "cat") TrieInsert(trieRoot, "cow") TrieInsert(trieRoot, "crow") If TrieInsert(trieRoot, "cow") is called a second time, _____ new nodes are created.

4

Assume a trie is built by executing the following code. trieRoot = new TrieNode() TrieInsert(trieRoot, "cat") TrieInsert(trieRoot, "cow") TrieInsert(trieRoot, "crow") When inserting "cat", _____ new nodes are created.

4

Assume a trie is built by executing the following code. trieRoot = new TrieNode() TrieInsert(trieRoot, "cat") TrieInsert(trieRoot, "cow") TrieInsert(trieRoot, "crow") When inserting "crow", _____ new nodes are created.

3

Assume insertion sort's goal is to sort in ascending order. Given list (1, 9, 17, 18, 2), how many swaps will occur during the outer loop execution (i = 4)?

1

Assume insertion sort's goal is to sort in ascending order. Given list (10, 11, 12, 13, 14, 15), how many comparisons will be made during the third outer loop execution (i = 3)

5

Assume insertion sort's goal is to sort in ascending order. Given list (10, 11, 12, 13, 14, 7), how many comparisons will be made during the final outer loop execution (i = 5)?

6,10,20,14,7

Assume insertion sort's goal is to sort in ascending order. Given list (10, 20, 6, 14, 7), what will be the list after completing the second outer loop iteration (i = 2)? Type answer as: 1, 2, 3

7

Assume insertion sort's goal is to sort in ascending order. Given list (18, 23, 34, 75, 3), how many total comparisons will insertion sort require?

14

Assume insertion sort's goal is to sort in ascending order. 1) Given list (20, 14, 85, 3, 9), what value will be in the 0th element after the first pass over the outer loop (i = 1)?

10

Assume quicksort always chooses a pivot that divides the elements into two equal parts. How many partitioning "levels" are required for a list of 1024 elements?

3

Assume quicksort always chooses a pivot that divides the elements into two equal parts. How many partitioning levels are required for a list of 8 elements?

10240

Assume quicksort always chooses a pivot that divides the elements into two equal parts. How many total comparisons are required to sort a list of 1024 elements?

2

Assume quicksort always chooses the smallest element as the pivot. Given numbers = (7, 4, 2, 25, 19), i = 0, and k = 4, what are the contents of the low partition? Type answer as: 1, 2, 3

1023

Assume quicksort always chooses the smallest element as the pivot. How many partitioning "levels" are required for a list of 1024 elements?

4

Assume quicksort always chooses the smallest element as the pivot. How many partitioning "levels" are required for a list of 5 elements?

1047552

Assume quicksort always chooses the smallest element as the pivot. How many total comparisons are required to sort a list of 1024 elements?

5,6,8,7,9

Assume selection sort's goal is to sort in ascending order. Given list (5, 9, 8, 7, 6) and i = 1, what will be the list after completing the second outer loop iteration? Type answer as: 1, 2, 3

1

Assume selection sort's goal is to sort in ascending order. iven list (9, 8, 7, 6, 5), how many swaps will occur during the first pass of the outer loop (i = 0)?

5

Assume selection sort's goal is to sort in ascending order. 1) Given list (9, 8, 7, 6, 5), what value will be in the 0th element after the first pass over the outer loop (i = 0)?

True

BSP can be used in 3-D graphics as well as 2-D.

True

Because trees are non-linear, a linked list is a valid and obvious choice for trees.

true

Bubble sort only swaps adjacent elements.

false Bubble sort uses 2 loops, the second of which is nested inside the first.

Bubble sort uses a single loop to sort the list.

true

Bubble sort's best and worst runtime complexity is O(N2).

set(1,10.6)

Given the following code that creates and initializes a LinkedList: LinkedList<Double> accelerometerValues = new LinkedList<Double>(); accelerometerValues.add(9.8); accelerometerValues.add(10.2); accelerometerValues.add(15.4); Complete the statement to update the element at index 1 to 10.6. accelerometerValues. ;

remove(0)

Given the following code that creates and initializes a LinkedList: LinkedList<Double> accelerometerValues = new LinkedList<Double>(); accelerometerValues.add(9.8); accelerometerValues.add(10.2); accelerometerValues.add(15.4); Write a statement to remove the value 9.8 from the list. accelerometerValues. ;

5

Given the following code that creates and initializes a LinkedList: LinkedList<String> wordsFromFile = new LinkedList<String>(); wordsFromFile.add("The"); wordsFromFile.add("fowl"); wordsFromFile.add("is"); wordsFromFile.add("the"); wordsFromFile.add("term"); At what index does the following statement insert the word "end"? Enter a number. wordsFromFile.add("end");

False

A fast sorting algorithm's worst case runtime complexity must be O(NlogN) or better.

findMatch(0,2)

A list has 5 elements numbered 0 to 4, with these letter values: 0: A, 1: B, 2: D, 3: E, 4: F. To search for item C, the first call is findMatch(0, 4). What is the second call to findMatch()?

Recursive call: findMatch(2,2)

A list has 5 elements numbered 0 to 4, with these letter values: 0: A, 1: B, 2: D, 3: E, 4: F. In searching for item C, findMatch(0, 2) is called. What happens next?

false

A memory's stack region can store at most one stack frame.

True

When sorting an array of n 3-digit integers, RadixSort's worst-case time complexity is O(n).

True

When sorting an array with n elements, the maximum number of elements that RadixSort may put in a bucket is n.

false

Which are recursive definitions/algorithms? Driving to the store: Go 1 mile.Turn left on Main Street.Go 1/2 mile.

True

Which are recursive definitions/algorithms? 1) Helping N people:If N is 1, help that person.Else, help the first N/2 people, then help the second N/2 people.

Quicksort

Which fast sorting algorithm's worst case runtime complexity is worse than O(NlogN)?

isNext

Which of the following is NOT a method of the iterator interface

false

You can modify a collection while an iterator is active.

5

Given list: ( 4, 11, 17, 18, 25, 45, 63, 77, 89, 114 ). Given an array with 32 elements, how many list elements will be checked if the key is less than all elements in the list, using binary search?

3

Given list: ( 4, 11, 17, 18, 25, 45, 63, 77, 89, 114 ). How many list elements will be checked to find the value 17 using binary search?

2

Given list: ( 4, 11, 17, 18, 25, 45, 63, 77, 89, 114 ). How many list elements will be checked to find the value 77 using binary search?

get(2)

Given the following code that creates and initializes a LinkedList: LinkedList<Double> accelerometerValues = new LinkedList<Double>(); accelerometerValues.add(9.8); accelerometerValues.add(10.2); accelerometerValues.add(15.4); Complete the statement to assign currentValue with the element at index 2. currentValue = accelerometerValues. ;

get(0)

Given the following code that creates and initializes a LinkedList: LinkedList<Double> accelerometerValues = new LinkedList<Double>(); accelerometerValues.add(9.8); accelerometerValues.add(10.2); accelerometerValues.add(15.4); Complete the statement to print the first list element. System.out.println(accelerometerValues. );

True

Radix sort is a fast sorting algorithm.

false

RadixSort can be used to sort an array of strings.

false

RadixSort has a space complexity of O(1).

false

Recursive methods can be accomplished in one step, namely repeated calls to itself.

True

Selection sort can be used to sort an array of strings.

True

ShellSort will properly sort an array using any collection of gap values, provided the collection contains 1.

false

Since a for-each loop is cleaner, it should be the go to iterator at all times.

True

Sorting envelopes by zipcode: If N is 1, done.Else, find the middle zipcode. Put all zipcodes less than the middle zipcode on the left, all greater ones on the right. Then sort the left, then sort the right.

1024 elements

Suppose a list of 1024 elements is searched with linear search. How many distinct list elements are compared against a search key that is less than all elements in the list?

10 elements

Suppose a sorted list of 1024 elements is searched with binary search. How many distinct list elements are compared against a search key that is less than all elements in the list?

true

The Iterable interface creates an Iterator that can be iterated through.

false

The String variable line, will contain all of the data from the text file at the end of loop.

True

The are tree implementations using an array to store the nodes.

True

The fastest average runtime complexity of a comparison sorting algorithm is O(NlogN).

true

The following recursive method will result in a stack overflow. int recAdder(int inValue) { return recAdder(inValue + 1); }

false

The hasNextLine method of the Scanner class, moves the pointer to the next line in the text file.

false

The list is sorted into ascending order:(3, 9, 44, 18, 76)

True

The list is sorted into ascending order:(chopsticks, forks, knives, spork)

True

The list is sorted into ascending order:(great, greater, greatest)

True

The list is sorted into descending order:(20, 15, 10, 5, 0)

true

The list is sorted into descending order:(99.87, 99.02, 67.93, 44.10)

true

The list is sorted into descending order:(F, D, C, B, A)

True

The operations to add and remove nodes from a tree are not known until the purpose and organization of the tree is known.

True

The root is the top node of a tree

True

The simulated link strategy does have a drawback of increased overhead for deleting elements in a tree

false

The size of the stack is unlimited.

True

A file in a file system tree is always a leaf node.

True

A BSP implementation could choose to split regions in arbitrary locations, instead of right down the middle.

numbers = (55, 7, 81, 26, 0, 34, 68, 125), i = 3, k = 7 pivot =

34

True

A directory containing 1 or more files or directories is an internal node, but an empty directory is a leaf node.

numbers = (55, 7, 81, 26, 0, 34, 68, 125), i = 3, k = 7 midpoint =

5

False

Calling ShellSort with gap array (7, 3, 1) vs. (3, 7, 1) produces the same result with no difference in efficiency.

False

Consider integers X and Y, such that X < Y. X will always be in a lower bucket than Y.

unsorted

Determine if each of the following lists is unsorted, sorted, or nearly sorted. Assume ascending order. (15, 19, 21, 24, 2, 3, 6, 11)

nearly sorted

Determine if each of the following lists is unsorted, sorted, or nearly sorted. Assume ascending order. (23, 24, 36, 48, 19, 50, 101)

sorted

Determine if each of the following lists is unsorted, sorted, or nearly sorted. Assume ascending order. (6, 14, 85, 102, 102, 151)

1,2,3

Determine the index j and the left and right partitions. numbers = (1, 2, 3, 4, 5), i = 0, k = 4 Left partition =

4,5

Determine the index j and the left and right partitions. numbers = (1, 2, 3, 4, 5), i = 0, k = 4 Right partition =

23,8

Determine the index j and the left and right partitions. numbers = (34, 78, 14, 23, 8, 35), i = 3, k = 5 Left partition =

4

Determine the index j and the left and right partitions. numbers = (34, 78, 14, 23, 8, 35), i = 3, k = 5 j =

2

Determine the index j and the left and right partitions. 1) numbers = (1, 2, 3, 4, 5), i = 0, k = 4 j =

35

Determine the index j and the left and right partitions. numbers = (34, 78, 14, 23, 8, 35), i = 3, k = 5 Right partition =

2

Determine the midpoint and pivot values. numbers = (1, 2, 3, 4, 5), i = 0, k = 4 midpoint =

6

Given the following code that creates and initializes a LinkedList: LinkedList<String> wordsFromFile = new LinkedList<String>(); wordsFromFile.add("The"); wordsFromFile.add("fowl"); wordsFromFile.add("is"); wordsFromFile.add("the"); wordsFromFile.add("term"); Given the original list initialization above, how many elements does wordsFromFile contain after the following statement? Enter a number. wordsFromFile.add(4, "big");

3, "not"

Given the following code that creates and initializes a LinkedList: LinkedList<String> wordsFromFile = new LinkedList<String>(); wordsFromFile.add("The"); wordsFromFile.add("fowl"); wordsFromFile.add("is"); wordsFromFile.add("the"); wordsFromFile.add("term"); Write a statement to insert the word "not" between the elements "is" and "the". wordsFromFile.add( );

500

How many elements will the temporary merge list have for merging two partitions with 250 elements each?

11

How many recursive partitioning levels are required for a list of 2048 elements?

3

How many recursive partitioning levels are required for a list of 8 elements?

13

How many times is InsertionSortInterleaved called if ShellSort is called with gap array (10, 2, 1)?

4

How many times longer will sorting a list of 20 elements take compared to sorting a list of 10 elements?

100

How many times longer will sorting a list of 500 elements take compared to a list of 50 elements?

45µs

In the worst case, assuming each comparison takes 1 µs, how long will insertion sort algorithm take to sort a list of 10 elements?

false

Insertion sort is a fast sorting algorithm.

false

Integers will be placed into buckets based on the 1's digit. More buckets are needed for an array with one thousand integers than for an array with one hundred integers.

set(newDigit)

LinkedList<Integer> numbersList = new LinkedList<Integer>(); ListIterator<Integer> numberIterator; numbersList.add(3); numbersList.add(1); numbersList.add(4); numberIterator = numbersList.listIterator(); Complete the code to replace the next list element with newDigit. numberIterator.next(); // Necessary! numberIterator. ;

1

LinkedList<Integer> numbersList = new LinkedList<Integer>(); ListIterator<Integer> numberIterator; numbersList.add(3); numbersList.add(1); numbersList.add(4); numberIterator = numbersList.listIterator(); Given the original list initialization above, what is the value of numVal after executing the following statements? numberIterator.next(); numVal = numberIterator.next();

true

LinkedList<Integer> numbersList = new LinkedList<Integer>(); ListIterator<Integer> numberIterator; numbersList.add(3); numbersList.add(1); numbersList.add(4); numberIterator = numbersList.listIterator(); What does numberIterator.hasNext() return the first time?

false

LinkedList<Integer> numbersList = new LinkedList<Integer>(); ListIterator<Integer> numberIterator; numbersList.add(3); numbersList.add(1); numbersList.add(4); numberIterator = numbersList.listIterator(); What value does numberIterator.hasNext() return after three calls to numberIterator.next().

False

N factorial (N!) is commonly implemented as a recursive method due to being easier to understand and executing faster than a loop implementation.

True

Using a tree data structure to implement a file system requires that each directory node support a variable number of children.

4

Using the Big O runtime complexity, how many times longer will sorting a list of 20 elements take compared to sorting a list of 10 elements?

True

Wasted memory space is a drawback of the computational strategy.

When both inputs to the method are equal

What is the base case for the GCD algorithm?

49

When sorting a list with 50 elements, indexSmallest will be assigned to a minimum of _____ times.

3

numbers = (1, 2, 3, 4, 5), i = 0, k = 4 pivot =

1

numbers = (200, 11, 38, 9), i = 0, k = 3 midpoint =

11

numbers = (200, 11, 38, 9), i = 0, k = 3 pivot =


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

chapter 4, 5 & 6 quizzes combined

View Set

Chapter 9.4 (U.S History) "Progressivism Under Taft"

View Set

BTS 147 Ch 7 - Presentations Using Tables and Pie Charts

View Set

Mr. Dye Period 5 AP classroom questions and Khan questions

View Set

p. 55 ex. 1 - Mise en pratique - Les Invites

View Set

Ch.15 Professional Practice Models, Leadership Exam #3

View Set