Time efficiencies

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

The efficiency of the operation "getEntry" with respect to binary search trees

O(h)

The efficiency of the operation "remove" with respect to binary search trees

O(h)

If a bucket hash structure is holding n elements and the size of the largest bucket is k, then what is the worst-case time complexity to retrieve an item from the hash structure?

O(k)

In the worst case, searching a full binary search tree is an ________ operation

O(log n)

If n elements are inserted into a binary search tree resulting in a complete binary tree, what is the worst-case time complexity to look up an element?

O(log(n))

Simple counting loop

O(n)

Space Complexity for all data structures - worst case

O(n)

True or False: the time complexity to search for an element in a list implemented as a sorted chain is O(log(n)).

False

Doubly-linked list access/search/insertion/deletion

AVERAGE Access:O(n) Search:O(n) Insertion:O(1) Deletion:O(1) WORST Access:O(n) Search:O(n) Insertion:O(1) Deletion:O(1)

Singly-linked list search/insertion/deletion

AVERAGE Access:O(n) Search:O(n) Insertion:O(1) Deletion:O(1) WORST Access:O(n) Search:O(n) Insertion:O(1) Deletion:O(1)

Array based vs linked sorted list worst case efficiency for "getEntry(givenPosition)"

Array= O(1) Linked= O(n)

Which of the following describes the best-case time complexity for inserting an element into a sorted list of size n implemented as a linked chain? A O(n2) B O(1) C O(n) D O(nlog(n))

B O(1)

What O(?) case describes the average-case time complexity for inserting an element into a sorted list of size n implemented as a linked chain?

O(n)

Worst-case time complexity for inserting an element into a sorted list of size n implemented as a linked chain

O(n)

Quick Sort

Average: O(n log n) Worst: O(n^2)

Divide by 2 loop

log2n

What O(?) case describes the best-case time complexity for inserting an element into a sorted list of size n implemented as a linked chain?

O(1)

What is the worst-case time complexity for inserting a new element into a bag implemented with linked allocation?

O(1)

Worst case for "getLength()" of linked sorted list

O(1)

The time efficiency of quick sort

Quick sort is O(n log n) in the average case but O(n^2) in the worst case.

Mergesort Algorithm best/average/worst/space

Time Best:O(n log(n)) Average:O(n log(n)) Worst:O(n log(n)) Space Worst:O(n)

Adding to an array-based list is a O(?) operation

Adding to the beginning of an array-based list is an O(n) operation. Adding to the end is O(1) if the underlying array is not resized; otherwise it is O(n). The time required to add at other positions depends on the position. As the position number increases, the time needed for an addition decreases.

Linked List Unsorted insert/delete/merge

Insert:O(n) Delete:O(1) Merge:O(1)

Linked List Sorted insert/delete/merge

Insert:O(n) Delete:O(1) Merge:O(m+n)

The time efficiency of insertion sort

Insertion sort is at best O(n) and at worst O(n2). The closer an array is to sorted order, the less work an insertion sort does

Merge sort efficiency

Merge sort is O(n log n) in all cases

Big-O for adding an element to a sorted list

O(n)

Which of the following are true about Quicksort? 1. The worst-case time complexity of Quicksort is O(nlog(n)) 2. The worst-case time complexity of Quicksort is O(n2) 3. The average-case time complexity of Quicksort is O(nlog(n)) 4. The average-case time complexity of Quicksort is O(n2)

2. The worst-case time complexity of Quicksort is O(n2) 3. The average-case time complexity of Quicksort is O(nlog(n))

Time complexity to search for an element in a list implemented as a sorted array is

O(log(n))

When two efficiencies are nested do this to get total efficiency

multiply them

Quicksort Algorithm best/average/worst/space

Time Best:O(n log(n)) Average:O(n log(n)) Worst:O(n^2) Space Worst:O(log(n))

Bubble Sort Algorithm best/average/worst/space

Time Best:O(n) Average:O(n^2) Worst:O(n^2) Space Worst:O(1)

The time efficiency of a binary search of an array (best, worst and average)

Best case: O(1) Worst case: O(log n) Average case: O(log n)

The time efficiency of a sequential search of a chain of linked nodes

Best case: O(1) Worst case: O(n) Average case: O(n)

Radix Sort Algorithm best/average/worst/space

Best:O(nk) Average:O(nk) Worst:O(nk) *O(n) for fixed number of buckets Space Worst:O(n+k)

Which of the following describes the worst-case time complexity for inserting an element into a sorted list of size n implemented as a linked chain? A O(n2) B O(1) C O(n) D O(nlog(n))

C O(n)

selectionSort operations are O(?)

A selectionSort loop executes a total of (n - 1) + (n - 2) + . . . + 1 times. This sum is n (n - 1)/2. Since the operations in the loop are O(1), the selection sort is O(n²).

Hash Table access/search/insertion/deletion

AVERAGE Access:- Search:O(1) Insertion:O(1) Deletion:O(1) WORST Access:- Search:O(n) Insertion:O(n) Deletion:O(n)

Array access/search/insertion/deletion

AVERAGE Access:O(1) Search:O(n) Insertion:O(n) Deletion:O(n) WORST Access:O(1) Search:O(n) Insertion:O(n) Deletion:O(n)

Binary Search Tree access/search/insertion/deletion

AVERAGE Access:O(log(n)) Search:O(log(n)) Insertion:O(log(n)) Deletion:O(log(n)) WORST Access:O(n) Search:O(n) Insertion:O(n) Deletion:O(n)

The time efficiency of a sequential search of an array

Best case O(1) Worst case: O(n) Average case: O(n)

Which of the following is true for sorting a collection of n elements? A the average-case time complexity of selection sort is O(n) B the best-case time complexity of selection sort is O(n) C the worst-case time complexity of selection sort is O(n) D the time complexity of selection sort is O(n^2) for all cases

D the time complexity of selection sort is O(n^2) for all cases

Bucket Sort Algorithm best/average/worst/space

Time Best:O(n+k) Average:O(n+k) Worst:O(n^2) Space Worst:O(n)

Selection Sort Algorithm best/average/worst/space

Time Best:O(n^2) Average:O(n^2) Worst:O(n^2) Space Worst:O(1)

Stack access/search/insertion/deletion

AVERAGE Access:O(n) Search:O(n) Insertion:O(1) Deletion:O(1) WORST Access:O(n) Search:O(n) Insertion:O(1) Deletion:O(1)

If n elements are inserted into a binary search tree, what is the worst-case time complexity to look up an element?

O(n)

Insertion Sort Algorithm best/average/worst/space

Time Best:O(n) Average:O(n^2) Worst:O(n^2) Space Worst:O(1)


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

Alternative Investments, Risk Management, and the Application of Derivatives

View Set

PSY 2012 - Chapter 5 Quiz, Psych exam 4, PSYCH Final, Psychology Chapter 7 Quiz, exam 1

View Set

Social Media Marketing Midterms Chapter 5 out of 5

View Set

SOCIOLOGY FINAL EXAM: The American Dream and the Power of Wealth

View Set