


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Worst case Selection sort - correct answer O(n^2) worst case bubble sort - correct answer Bubble sort has a worst-case and average complexity of О(n2) Reccurence relation for merge - correct answer T(0) = T(1) = c T(n) = 2T(n/2) + O(n) (for n > 1) best case Finding the maximum value in an unsorted linked list of n elements - correct answer O(n) best case Inserting an item into a binary search tree of n elements - correct answer O(1) best case Inserting an item into a binary heap of n elements - correct answer O(1) best case Sorting an array of n elements using Merge Sort - correct answer O (nlgn) best case Deleting an element from a circular linked list of n elements - correct answer O(1) worst case Deleting an item from an AVL tree of n elements - correct answer O(lg n) worst case Deleting the minimum item from a binary min heap of n elements - correct answer O(lg n) worst case Inserting an item into a binary search tree of n elements - correct answer O(n) worst case Sorting an array of n elements using Heap Sort - correct answer O(nlgn)
worst case Deleting an element from a doubly linked list of n elements - correct answer O(n) Merging a sorted array of size m with a sorted array of size n into one sorted array. - correct answer O(m+n) Creating a heap out of n unsorted integers - correct answer O(n) Worst case run-time of running a Quick Sort on n integers. - correct answer O(n2 ) Inserting an element to the front of a linked list with n elements - correct answer O(1) Deleting m items, one by one, from an AVL tree which originally contains n items (n ≥ m) - correct answer O(m lg n) A sequence of p push operations onto a stack that originally had n elements on it. - correct answer O(p) Average case run time of an insertion sort on n unsorted integers. - correct answer O(n^2 ) Calculating a b mod c, using fast modular exponentiation, assuming that each multiply and each mod operation take O(1) time. - correct answer O(lg b) Pre-order traversal of a binary tree with height h and n nodes. - correct answer O(n) Worst case run-time for searching for an element in a binary search tree with n nodes. - correct answer O(n) Permutation questions - correct answer input parameters(n, perm Array, used Array, k/ mostly start k at
some logic in the if statement like !used[i]
Average Case Printing out each permutation of the integers 1, 2, 3, ..., n. (Note: printing a single integer takes O(1) time.) - correct answer O(n*n!) Worst Case Insertion of a single node into a binary search tree with n nodes. - correct answer O(n) Average Case Insertion of a single node into a binary search tree with n nodes. - correct answer O(lg n) Worst Case Deletion of a single node of an AVL tree with n nodes. - correct answer O(lg n) Average Case Deletion of a single node of an AVL tree with n nodes. - correct answer O(lg n) Worst Case Merging a sorted array of size P with another sorted array of size Q, producing a newly allocated sorted array of P+Q elements. - correct answer O(P+Q) Average Case Merging a sorted array of size P with another sorted array of size Q, producing a newly allocated sorted array of P+Q elements. - correct answer O(P+Q) Circular Queue front update logic - correct answer q->front = (q->front + 1) % q->capacity; Numbits On recursive - correct answer if (n == 0) return 0; return (n&1) + numBits On(n>>1);