CSC 202 Final (Made with Parkinson's Quiz questions)

Ace your homework & exams now with Quizwiz!

True/False A hashing function that maps each key to a unique position in the table is said to be a perfect hashing function.

True

Identify the Big-O time complexity for the stated operation. Build a Binary Heap by repeated insertion (enqueue) of keys O(n log(n)) O(1) O(n2) O(n) O(log(n))

O(n log(n))

Identify the Big-O time complexity for the stated operation. Perform Heap Sort on random set of data O(n2) O(n) O(log(n)) O(1) O(n log(n))

O(n log(n))

Choose the Big O description that best describes adding n elements to a hash table as presented or implemented in this class, assuming a low load factor and efficient hash function. O(log n) O(n) O(n log n) O(1) None of these

O(n)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information" Estimate for the worst case of finding the minimum key in a Binary Search Tree O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(n)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information" Search a linked list for an item (assume items are unordered) O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(n)

The following recursive function takes one string input parameter: in1 def mystery(in1: str) -> bool: if len(in1) <= 1: return False elif in1[0] == in1[1]: return True else: return mystery(in1[1:]) What will be returned by the function call: mystery("Giraffe") ? True or False

True

True/False For a hash table of size 11, the following is a valid hash function: hash(key) = ((key % 11) // 11) + 3

True

True/False It is possible to implement an ADT in more than one way, the implementation just needs to support the correct operations.

True

True/False Linked lists and binary trees can be viewed as a graphs.

True

True/False A set of course pre-requisite requirements can be represented as a directed acyclic graph

True

Ture/False The dictionary in Python is implemented using a hash table

True

If elements are competing for the same slot in the hash table, what is it called? Replication Duplication Collision Diffusion

Collision

A Queue's behavior in regard to adding and removing items can be described as: FIFO LIFO Unpredictable FIDO

FIFO

For Merge Sort, if we have two arrays, each of size n/2 (assume n is even), what is the greatest number of comparisons that could be made during the merge operation (in terms of n)? n-1 n/2 n2 2n None of these

n-1

For Merge Sort, if we have two arrays, each of size n/2 (assume n is even), what is the fewest number of comparisons that could be made during the merge operation (in terms of n)? n-1 n/2 n2 2n None of these

n/2

The load factor in a hash table with separate chaining must be: none of these < 0.7 < 1.0 < 2.0 < 0.5

none of these

Assuming a hash table with a size that is a prime number, in order to guarantee finding an open slot when using quadratic probing, the load factor (λ) must be less than: 2/3 1 0.5 elements // table size

0.5

Given the hash table T on the whiteboard, the load factor λ for T is ____ 10 6 0.6 None of these 0.3

0.6

An algorithm takes 200 ms to process 1000 items. Estimate how many items the algorithm can process in 1800 ms, if the algorithm is O(log(n)) 1000^9 9^1000 9 * log(1000) 9000 None of these 1000 * log(9)

1000^9

Given two vertices in an undirected graph, c and f, which of the two traversals (BFS and DFS) can be used to find if there is path from c to f? Both BFS and DFS Only DFS Only BFS Neither BFS and DFS

Both BFS and DFS

Which of the following sequences for the insertion of keys (ordered from first insertion to last insertion) will result in the BST on the board: 49, 32, 21, 63, 52, 41, 72, 55, 37, 77, 47 21, 32, 37, 41, 47, 49, 52, 55, 63, 72, 77 41, 37, 47, 32, 21, 52, 55, 72, 77, 63, 49 49, 63, 32, 21, 41, 77, 72, 52, 55, 37, 47 37, 47, 55, 77, 21, 41, 52, 72, 32, 63, 49

49, 32, 21, 63, 52, 41, 72, 55, 37, 77, 47

For the BST on the board, a level-order traversal will result in what order of keys as each node is "processed" (e.g. key is added to a Python List) 49, 32, 21, 63, 52, 41, 72, 55, 37, 77, 47 49, 32, 63, 21, 41, 52, 72, 37, 47, 55, 77 41, 37, 47, 32, 21, 52, 55, 72, 77, 63, 49 49, 63, 32, 21, 41, 77, 72, 52, 55, 37, 47 37, 47, 55, 77, 21, 41, 52, 72, 32, 63, 49

49, 32, 63, 21, 41, 52, 72, 37, 47, 55, 77

Which is the most appropriate definition for recursion? An in-built method that is automatically called. A function that calls another execution instance of the same function. A class method that calls another class method. A function that calls another function.

A function that calls another execution instance of the same function.

Which of the following are examples of applications that can use graphs to represent objects (vertices) and the connections (edges) between those objects? Google maps uses graphs for building transportation systems, where intersection of two(or more) roads are considered to be a vertex and the road connecting two vertices is considered to be an edge In Facebook, users are considered to be the vertices and if they are friends then there is an edge running between them In World Wide Web, web pages are considered to be the vertices. There is an edge from a page u to other page v if there is a link of page v on page u All of these

All of these

The "List" in Python (for example, myList = [1,2,3]) is implemented using which of the following: Linked List Node List Array Stack Queue

Array

The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k mod 10 and linear probing (step=1). Which of the hash tables on the whiteboard represent the result after these insertions? D A C B None of these

C

The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using separate chaining with hash function h(k) = k mod 10. Which of the hash tables on the whiteboard represent the result after these insertions? D C None of these A B

D

True/False For a hash table of size 11, if using double hashing, the following is a suitable second hash function to determine the step for finding an empty slot: hash2(key) = key % 7

False

True/False In Python, when we assign a reference to equal another reference, for example: loc2 = loc1 a copy of the object is created.

False

True/False It is necessary to know how an ADT is implemented in order to use it.

False

True/False Recursion is always the most efficient approach for the implementation of an algorithm.

False

True/False When using separate chaining for each index, the number of items that can be stored in a hash table is limited by the number of "slots or buckets" of the hash table.

False

True/False If we do not not specify a return value for a Python function, an exception is raised

False

Which of the following sorting algorithms requires additional memory, equivalent to the size of the array that is to be sorted? Merge Sort Insertion Sort Quick Sort Selection Sort Bubble Sort

Merge Sort

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information" Push "n" items on to a Stack that is implemented using an array O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

None of these / Not enough information

Choose the Big O time complexity that provides the best description for the following operation's running time. If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information "dequeue() in the circular array implementation of a Queue done in lab. Recall the lab used a list of fixed size but enqueued and dequeued using modular arithmetic.(n represents the number of items in the queue.) O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(1)

Choose the Big O time complexity that provides the best description for the following operation's running time. If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information "Delete the first (head) node from a doubly linked list, assuming a sentinel node implementation O(n2) O(log(n)) O(1) None of these / Not enough information O(n)

O(1)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information"Delete the first (head) node from a doubly linked list, assuming a sentinel node implementation O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(1)

Identify the Big-O time complexity for the stated operation. Build a Binary Heap by repeated insertion (enqueue) of keys O(1) O(log(n)) O(n) O(n log(n)) O(n2)

O(n log(n))

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information"Given an index, replace the item in an array at that index (just replacing the item, not deleting old item and inserting new item) O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(1)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information"Pop an item from a stack, assuming a NodeList implementation as in Lab #2 O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(1)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information"enqueue() in the Node List implementation of a Queue done in lab.Recall the lab used two Node Lists - one for the "rear" of the Queue, and another for the "front" of the Queue.(n represents the number of items in the queue.) O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(1)

Identify the Big-O time complexity for the stated operation. Find (but do not remove/dequeue) the minimum key in a Min Binary Heap O(n log(n)) O(n2) O(n) O(1) O(log(n))

O(1)

Identify the Big-O time complexity for the stated operation. Find a key in a hash table (typical case, low load factor) O(n log(n)) O(n) O(1) O(log(n)) O(n2)

O(1)

Identify the Big-O time complexity for the stated operation. Given a key, remove the key/value pair from a hash table (typical case, efficient hash table, low load factor) O(n2) O(1) O(n log(n)) O(log(n)) O(n)

O(1)

Identify the Big-O time complexity for the stated operation. Given a key, retrieve the key/value pair in a hash table (typical case, efficient hash function, low load factor) O(n) O(log(n)) O(1) O(n log(n)) O(n2)

O(1)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information" Finding the maximum key in a balanced Binary Search Tree O(1) O(log n) O(n) O(n log n) None of these

O(log n)

Choose the Big O time complexity that provides the best description for the following operation's running time. Find a key in a well-balanced Binary Search Tree O(1) O(log(n)) O(n) O(n log(n)) O(n^2)

O(log(n))

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information"Find a key in a well-balanced Binary Search Tree O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(log(n))

Identify the Big-O time complexity for the stated operation. Remove (dequeue and restore heap) the maximum key from a Maximum Binary Heap O(log(n)) O(1) O(n) O(n2) O(n log(n))

O(log(n))

Identify the Big-O time complexity for the stated operation. Remove (dequeue) the maximum key from a Maximum Binary Heap, and restore the heap order. O(log(n)) O(1) O(n) O(n2) O(n log(n))

O(log(n))

Choose the big O description that provides the tightest accurate running time bound for dequeueing n items from a binary heap (average case) as presented or implemented in this class. O(1) O(log n) O(n) O(n log n) None of these

O(n log n)

Choose the Big O time complexity that provides the best description for the following operation's running time.Best general case achievable time complexity for a comparison based sorting algorithm, starting with a random and unordered set of "n" integers O(1) O(log(n)) O(n) O(n log(n)) O(n^2)

O(n log(n))

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information" For a balanced BST with a Node definition that has key, item, left and right attributes: Searching the BST to determine if a certain item (not key) is in the BST O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(n)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information" Level order traversal of a binary tree O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(n)

Choose the Big O time complexity that provides the best description for the following operation's running time.If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information"The make_list function: def make_list(n): # n is a positive integerthe_list = [] # start with empty Python listfor i in range(n): the_list.insert(max(0,len(the_list)-3),i)return the_list O(1) O(log(n)) O(n) O(n2) None of these / Not enough information

O(n)

Choose the big O description that provides the tightest accurate running time bound to adding n elements to a hash table as presented or implemented in this class, assuming a low load factor and efficient hash function. O(n) O(log n) O(n log n) O(1) None of these

O(n)

Identify the Big-O time complexity for the stated operation. Breadth First Search of a graph. (where "n" is the total number of edges plus vertices) O(log(n)) O(n) O(1) O(n2) O(n log(n))

O(n)

Identify the Big-O time complexity for the stated operation. Build a Binary Heap using the Bottom Up method O(1) O(log(n)) O(n) O(n log(n)) O(n2)

O(n)

Identify the Big-O time complexity for the stated operation. Build a Binary Heap using the Bottom Up method O(n) O(log(n)) O(n2) O(1) O(n log(n))

O(n)

Identify the Big-O time complexity for the stated operation. Depth First Search of a graph. (where "n" is the total number of edges plus vertices) O(1) O(log(n)) O(n2) O(n) (n log(n))

O(n)

Identify the Big-O time complexity for the stated operation. Resize a hash table (e.g. growing hash table as in Project 4, when load factor > .5) O(log(n)) O(1) O(n2) O(n) O(n log(n))

O(n)

Choose the Big O time complexity that provides the best description for the following operation's running time. If the correct answer is not an option or there is not enough information to answer, select "None of these / Not enough information" Create a list by inserting "n" items, one at a time, at index 0 of a Python List (overall time complexity of creating the list of n items) O(1) O(log(n)) O(n) O(n^2) None of these / Not enough information

O(n^2)

Choose the Big O time complexity that provides the best description for the following operation's running time.Insertion sort on an unsorted random set of "n" integers O(1) O(log(n)) O(n) O(n log(n)) O(n^2)

O(n^2)

Choose the Big O time complexity that provides the best description for the following operation's running time.Perform Bubble sort on random set of data O(1) O(log(n)) O(n) O(n log(n)) O(n^2)

O(n^2)

Choose the Big O time complexity that provides the best description for the following operation's running time.Run Quick Sort on an unsorted array of random integers, using the first index as the pivot.Run Quick Sort again on the result from above, again using the first index as the pivot. O(1) O(n) O(n^2) O(n log(n)) O(log(n))

O(n^2)

You are given an unsorted set of integers in an array, and must determine the largest value in the set (once and only once). From a time complexity standpoint, which of the following would be the most efficient way of accomplishing this task? Perform a linear search on the array for the maximum value Perform a binary search on the array for the maximum value Sort the list using selection sort, then take the value at the last index Sort the list using quick sort, then take the value at the last index

Perform a linear search on the array for the maximum value

Which ADT is used for a Breadth First Search of a graph? Linked List Priority Queue Queue Python List (Array) Stack

Queue

Which ADT is used for a Depth First Search of a graph? Linked List Priority Queue Python List (Array) Stack Queue

Stack

Which of the following is an important benefit of writing test cases early Test cases force you to think about what the function should do before you start writing the function. You will not have to write the test cases later In industry you will be forced to write test cases before any implementation None of these

Test cases force you to think about what the function should do before you start writing the function.

Select the answer that represents the state of mylist after the following code executes: def add_to_list(list,x): list.append(x) mylist = [] add_to_list(mylist,10) add_to_list(mylist,20) [20] [10] [10,20] []

[10,20]

For a Doubly Linked List using a sentinel node, assuming that the reference "cur" is pointing to a node that is to be deleted, which of the following is the correct set of statements to complete the delete operation? cur.next.prev = cur.prev cur.prev.next = cur.next cur.next.next = cur.next cur.prev.prev = cur.prev cur.next.prev = cur.next cur.prev.next = cur.prev cur.next. = cur.prev.next cur.prev = cur.next.prev None of these

cur.next.prev = cur.prev cur.prev.next = cur.next

In a binary heap, what is the location of a parent node for any arbitrary node located at index i ? (i + 1) // 2 i // 2 2 * i i - 1

i // 2

What does the following function return if argument is "axmp" def mystery(arg): if (len(arg) == 1):return arg[0]else:return arg[len(arg)-1]+mystery(arg[:len(arg)-1]) pmxa axmp 4 out of bounds error

pmxa

When this code is executed: def f(x): print(x) return x + 1 def g(y): return f(y) + 1 a = g(f(1)) The output is: 1 2 When the value of 2 is printed out, the call stack looks like: top -> f(2) -> g(2) top -> f(2) top -> g(1) -> f(2) You Answered top -> f(2) -> g(2) -> f(1)

top -> f(2) -> g(2)


Related study sets

skabidi toilet only in ohio kai cenat baby gronk w grimace shake rizz skibidi ohio rizzler gyattt ohio rizzler baby gronk skibidi toilet ohio rizz

View Set

PAD 4144 Intro to Non Profit FINAL

View Set

CIS 330 Chapter 9, 10, 11 (Final Exam)

View Set

W1SQ: The Declaration of Independence

View Set

Microbiology Chapter 3 HW, Microbiology Chapter 4 Part 2 HW, Microbiology Chapter 4 Part 1 HW

View Set

Exam 3 Study Guide (Ch. 9, 13, 14, 16)

View Set

Anatomy- Chapter 7 Quizlet (actual test questions)

View Set

U.S. History chapter 4-9. Unit quiz 2

View Set