CPE 202 Final Time Complexity Review

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

Choose the Big O time complexity description for inserting an element in the middle of a Python list (array) as presented or implemented in this class: None of these O(log n) O(n log n) O(1) O(n)

O(n)

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(n^2)

O(n log(n))

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(n^2)?

3,000

An algorithm takes 150 milliseconds to process 300 items. Estimate how long (in milliseconds) it will take to process 100 items, if the algorithm is O(n)

50

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(n^2) None of these / Not enough information

O(log(n))

For the following code: def my_function(n): x = 0 i = n while i >= 1: x += i i = i//2 return x The Big O time complexity is: O(1) O(n) O(n2) O(log(n))

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(1) O(log(n)) O(n^2) O(n log(n)) O(n)

O(log(n))

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

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(n log(n)) O(n2) O(n) O(1)

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)

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

O(n log(n))

Choose the Big O time complexity description for removing an element at the beginning of a Python List (array) as presented or implemented in this class. O(n log n) O(1) None of these O(n) O(log n)

O(n)

An algorithm takes 100 milliseconds to process 300 items. Estimate how long (in milliseconds) it will take to process 900 items, if the algorithm is O(n^2)

900

An algorithm takes 200 ms to process a set of input data consisting of 2000 items. For an O(log(n)) algorithm, compute an estimate of how many items could be processed in 600 ms. Assume that there are no lower-order terms, thus the time complexity of the algorithm is directly proportional to log(n), and doesn't have any linear or constant terms. 4000 2000^3 6000 18,000

2,000^3

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 n^2 2n None of these

n-1

An algorithm displays the following behavior based on varying the input size, n: n time (sec) 10 0.30 20 1.20 40 4.80 80 19.20 The Big O time complexity for this algorithm would be: O(log(n)) O(n) O(n^2) O(1)

0(n^2)

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

To dequeue an item from a queue (do not assume an implementation), the Big O time complexity is: O(n) O(1) O(log n) Not enough information to know O(n log n)

Not enough information to know

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(n) None of these / Not enough information O(n^2) 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(n2) O(log(n)) O(1) O(n)

O(1)

For the evens_only() function in the previous question, where "n" is the length of the list, the Big O time complexity is: O(log(n)) O(n^2) None of these O(1) O(n)

O(n)

Big O analysis is concerned with the behavior of algorithms as the size of the input, n, grows and gets very large. True False

True

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.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

Assuming a NodeList implementation of a Queue (as in Lab #3), the enqueue operation time complexity is: O(n^2) O(n) O(n log n) O(log n) O(1)

O(1)

An algorithm takes 5 seconds to process a set of input data consisting of 10,000 items. For an O(n^2) algorithm, compute an estimate of how many items could be processed in 2 minutes and 5 seconds. Assume that there are no lower-order terms, thus the algorithm is directly proportional to n^2, and doesn't have any linear or constant terms. Which best represents the approximate number of items that can be processed? 10,000 20,000 50,000 125,000 1,250,000

50,000

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(n^2) None of these / Not enough information

O(n)

An algorithm takes 20 ms to process a set of input data consisting of 300 items. Compute an estimate of how long it would take the algorithm to process 3,000 items for if the algorithm is O(n^2) ? Assume that there are no lower-order terms, such as linear or constant terms and the algorithm's performance is directly proportional to n^2 20 ms 2 sec 40 sec 40 ms 200 ms

2 sec

An O(1) algorithm takes 80 ms to process a set of input data consisting of 5000 items. What is the approximate length of time this algorithm will take to process a set of input data consisting of 2500 items? 40 ms 20 ms 80 ms 400 ms 160 ms

40ms

Assuming a circular array implementation for a Queue as in Lab 3, the dequeue() operation is: O(n log n) O(n^2) O(n) O(1) O(log n)

O(1)

Choose the Big O time complexity description for appending an element at the end of a Python List (array) as presented or implemented in this class. None of these O(log(n)) O(n) O(n^2) O(1)

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" Given an index, replace the item in an array at that index (just replacing the item, not deleting old item and inserting new item) For example, replace item at index 4 with 49: myList[4] = 49 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(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(n^2) 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"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(n^2) 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(n^2) None of these / Not enough information

O(1)

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(n log n) None of these O(log n) O(1)

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(log(n)) O(1) O(n^2) O(n) O(n log(n))

O(1)

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

O(1)

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

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(n^2) O(log(n)) O(n log(n)) O(n) O(1)

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.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))

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

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(1) O(n log n) None of these O(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" Estimate for the worst case of finding the minimum key in a Binary Search Tree O(1) O(log(n)) O(n) O(n^2) 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(n^2) 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(n^2) 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 integer the_list = [] # start with empty Python list for 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(n^2) 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.Search for a specific data item in a well-balanced Binary Search Tree without knowing the associated key.(Recall the key is used to place the Node in the BST, while the data is the "payload" that rides along) O(1) O(log(n)) O(n) O(n log(n)) O(n2)

O(n)

For the following code: def my_function(n): x = 0 for i in range(n*2): x += i x += n return x The Big O time complexity is: O(n) O(1) O(n^2) O(log(n))

O(n)

For the following, assume each individual pop operation is O(1), and the each individual queue operation is O(1) Pop all "n" items from a stack and enqueue them to a Queue - overall time complexity is: O(n^2) O(1) O(n log n) O(n) O(log n)

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(1) O(n) O(log(n)) O(n^2) 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(n^2)

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(n log(n)) O(1) O(n^2)

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(n) O(log(n)) O(1) O(n2) O(n log(n))

O(n)

Identify the Big-O time complexity for the stated operation. Find the minimum key in a Max Binary Heap O(1) O(log(n)) O(n) O(n log(n)) O(n^2)

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(n) O(n^2) O(1) 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.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(n^2) O(n log(n)) O(n) O(1) O(log(n))

O(n^2)

Choose the Big O time complexity that provides the best description for the following operation's running time.Selection 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)

For a particular algorithm, if the number of operations as a function of n is determined be 5n^2 + 3n + 12, the Big O time complexity for that algorithm is said to be: O(n) O(5n^2) O(n^2) O(1) O(5n^2 + 3n + 12)

O(n^2)

Which of the following best describes the time complexity of the following function? def sum_list(py_list): # py_list is Python List of length n x = 0 for i in range(len(py_list)): x += py_list.pop(0) return x O(log n) O(n^2) O(n) O(n log n) O(1)

O(n^2)

A sequential (linear) search of an array for a specific item exhibits a Big O time complexity of O(n) True False

True

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 n^2 2n None of these

n/2


Set pelajaran terkait

Nature and the environment, Карп'юк, 9 клас

View Set

Chapter 25 Care of Patient with Skin Problems

View Set

CHAPTER 1 SOCIAL PSYCHOLOGY: THE SCIENCE OF THE SOCIAL SIDE OF LIFE {test bank}

View Set

SEHS Topic 11.2: Notation and analysis

View Set

Business Communications Learning: Ch 06: Completing Business Messages

View Set

Erikson's Eight Stages of Psychosocial Development

View Set

Chapter 7: Auditing, Testing, and Monitoring

View Set