Suppose that you are asked to select a data structure D that can support all of the following functions: 1. Search(D, x): Search for x in D, return true if x is present in D and false otherwise. 2. Insert(D, x): Insert x into the data structure D and update the data structure accordingly. 3. Delete(D, x): Delete x from the data structure D, given its address; and update the data structure accordingly. 4. Extract-Max(D): Delete and return the largest element in D; update the data structure accordingly. Assume that the candidate data structures are (i) Binary search tree (BST), (ii) Max-heap (HEAP), and (iii) Red-black tree (RBT). Note that a Max-heap is an array object, hence supports Search and Delete as well. Answer the following questions using the most accurate big-O asymptotic notation. (a11) The worst-case time complexity for Search in a HEAP with n elements is [a11] (a12) The worst-case time complexity for Search in a BST with n elements is [a12] (a13) The worst-case time complexity for Search in a RBT with n elements is [a13] (a21) The worst-case time complexity for Insert in a HEAP with n elements is [a21] (a22) The worst-case time complexity for Insert in a BST with n elements is [a22] (a23) The worst-case time complexity for Insert in a RBT with n elements is [a23] (a31) The worst-case time complexity for Delete in a HEAP with n elements is [a31] (a32) The worst-case time complexity for Delete in a BST with n elements is [a32] (a33) The worst-case time complexity for Delete in a RBT with n elements is [a33] (a41) The worst-case time complexity for Extract-Max in a HEAP with n elements is [a41] (a42) The worst-case time complexity for Extract-Max in a BST with n elements is [a42] (a43) The worst-case time complexity for Extract-Max in a RBT with n elements is [a43]
Blog
Given an unsorted array A of n distinct integers and an inte…
Given an unsorted array A of n distinct integers and an integer k, you need to return the k smallest integers in the array in sorted order, where k may be any integer between 1 and n. Suppose that you have the following three algorithms to solve this problem. A1: Sort the array in increasing order, then list the first k integers after sorting. A2: Build a min-heap from these n integers, then call Extract-Min k times. A3: Use the linear time selection algorithm to find the k-th smallest integer in the array, then partition the array about that number to obtain the k smallest numbers in the array, and finally sort the k smallest numbers. Assume that you are using mergesort as your sorting algorithm, and use the linear time build-heap algorithm to build the heap. Let T1(n, k) denote the worst-case running time of Algorithm A1. Let T2(n, k) denote the worst-case running time of Algorithm A2. Let T3(n, k) denote the worst-case running time of Algorithm A3. Analyze the worst-case running times of the algorithms. What is the asymptotic notation for T2(n, k)? Use the most accurate big-O notation in your answer. Note that k is between 1 and n. Hence k is nominated by n.
Match the following scenarios to the correct way the speaker…
Match the following scenarios to the correct way the speaker is trying to appeal to the audiences.
Look at the works-cited or bibliography below. What would th…
Look at the works-cited or bibliography below. What would the in-text citation look like in MLA? James, Ken and Sue Apple. ( July 2020). ” The Ten Ways to Help Your Coworkers.” International Today. www.internationaltoday.com/10ways-to-help-your-coworker
Match each thesis statement to its description: bad in what…
Match each thesis statement to its description: bad in what way or good.
This paragraph would be included in what type of essay?
This paragraph would be included in what type of essay?
Looking at this paragraph, what type of essay would this par…
Looking at this paragraph, what type of essay would this paragraph be included in?
Why is water a good solvent for organic chemistry and life o…
Why is water a good solvent for organic chemistry and life on Earth? **Note: No partial credit – no exceptions**
Which of the following best describes musical life in the Cl…
Which of the following best describes musical life in the Classical era?
The deliberate upsetting of the normal pattern of accents is…
The deliberate upsetting of the normal pattern of accents is called