(a)
To finds the correct values in the extracted array of sequence
(a)
Explanation of Solution
The EXTRACT-MIN
The INSERT algorithm is used to insert the value after the minimum value in the off-line minimum problem.
The algorithm takes the sequence of number and generates the corresponding values. The correct values in the extracted array are given in table below:
INDEX | VALUE |
1 | 4 |
2 | 3 |
3 | 2 |
4 | 6 |
5 | 8 |
6 | 1 |
The algorithm picks the minimum from the sequence by considering the sequence and then it remove that value then add to the extracted array and the remaining keys are added to the old sequence by using insert algorithm.
(b)
To argue the array extracted returned by OFF-LINE-MINIMUM is correct.
(b)
Explanation of Solution
The OFF-LINE-MINIMUM algorithm find the minimum number from the available sequence by using the extract min and then it add the remaining number to the sequence using insert operation.
The algorithm pick the smallest element from the available element then removed it from the sequence then it checks that the extracted value is minimum or not and combine the set of elements that needs to inserted in the sequence that is remaining elements other than min is combined to the original sequence.
Every iteration of the algorithm is extracted the minimum one by one and added to the extracted array until the last is extracted and stored to the array.
Therefore, the output returns from the algorithm is correct and have finite sequence.
(c)
To describe the implementation of OFF-LINE-MINIMUM algorithm for disjoint set data structure and also gives a tight bound of the implementation.
(c)
Explanation of Solution
The algorithm pick the smallest element from the available element then removed it from the sequence then it checks that the extracted value is minimum or not and combine the set of elements that needs to inserted in the sequence that is remaining elements other than min is combined to the original sequence.
The implementation of the disjoint set of data structure through OFF-LINE-MINIMUM algorithm is given below:
Step 1: Select the disjoint sets.
Step 2: Check that
Step 3: Then add all the values of
Step 4: Find the appropriate value of
Step 5: For every
After removing
For the every value of
Therefore, the total running time of the implementation of algorithm for disjoint set is
Want to see more full solutions like this?
- Title: Comparison of Exhaustive, Greedy, and Dynamic Programming approaches for the Partition problem.Description: In this assignment, we are given a set S containing n integers and we are expected to output a partition with two subsets such that they have the minimumdifference in their sums. For this purpose, we can use the simple exhaustive approach, which takes every subset A of S and compare the difference d of the sums: d =sum(A)-sum(S-A). The greedy approach is to use the numbers in S in pairs in descending order as described in class (you can also see the Wikipedia entry for thepartition problem). The dynamic programming algorithm that we covered in class is also to be implemented.We are also asked to compare the three algorithms in their runtime (in msecs) and difference found (d) for various values of k=log2(n). Your program will produce theseperformance measures, and then using any utility such as Excel, draw the plots of their runtimes versus k and d versus k (use…arrow_forwardLet x = (x,, X2X,) and y = (y,Y2.-Ym) to be two linked lists. Assume that in each list, the nodes are in non- decreasing order of their data field values. Write an algortihm to merge the two lists together to obtain a new linked list z in which the nodes are also in this order. Following the merge, x and y do not exist as individual lists. Each node initially in x or y is now in z. No additional nodes may be used. What is the time complexity of your algorithm?arrow_forwardBSTarrow_forward
- Interchange Base Points AlgorithmOutput: a base B = [131,132..... 13j-1, 13L.+1, 13j, 13j+2, 13j+3..... 13k] for G; a strong generating set relative to B; procedure interchange(var B: sequence of points; vat S: set of elements; j: 1..k-1);Interchange Base Points AlgorithmInput: a group G; a base [131,132..... 13k] for G and a strong generating set; an integer j between 1 and k-l; Output: a base [131,132..... 13k] for G and a strong generating set.arrow_forward7. For a Proof of Termination of your own implementation of the BST delete() algorithm, you would need to: (select all that apply) Group of answer choices: A. Show the algorithm terminates. B. Show the algorithm touches each node at most once. C. Show if a key/value pair exists, the algorithm will find it. D. Show the algorithm is faster or as fast as another delete algorithm.arrow_forwardFor Exercises 1–7, show the threaded BST that results from right-threading the binary search tree. Exercises 6 and 7 ask you to write functions for right-threaded BSTs. You should also test your functions with driver programs as instructed in Programming Problems 28 and 29 at the end of this chapter. Write a function to implement the inorder traversal algorithm for a right-threaded BST given in the text.arrow_forward
- 1. The performance of hash table O A Related to the method of handling conflicts, not the length of the table O B It has nothing to do with the method of handling conflicts, but with the length of the table OC It is related to the conflict handling method and table length OD It has nothing to do with conflict handling methods and table length 2 When using binary search, the linear list must be A Store in Sequential List B Store in linked List OC Store in Sequential List, and the list is ordered by keywords OD Store in linked List, and the list is ordered by keywordsarrow_forwardAssume that we are utilizing a doubly linked list of unsorted data. What would be the asymptotic running time of the data structure for the following functions? Search() Insert() Delete() Minimum() Maximum() Successor() Predecessor()arrow_forwardA sparse matrix can be represented as simply linked list, in which the nodes of the list contain information about the position and the value of the elements of the sparse matrix. An example of how sparse matrix can be represented as simply linked list is: head 4. Define a node of the above Simply Linked List with proper constructor. 10 O123marrow_forward
- determine if each following statement is True or Falsearrow_forward2 - final question Suppose we have a hash set that uses the standard "mod" hash function shown in the lectures (hash(i) → abs (i) % length) and uses linear probing for collision resolution. The starting hash table length is 11, and the table does not rehash during this problem. If we begin with an empty set, what will be the final state of the hash table after the following elements are added and removed? Write “X" in any index in which an element is removed and not replaced by another element. set.add(4); set.add(52); set.add(50); set.add(39); set.add(29); set.remove(4); set.remove(52); set.add(70); set.add(82); set.add(15); set.add(18); set.add(47); а. 47 15 70 50 39 82 29 18 b. 47 70 82 50 39 15 29 18 c. 47 15 82 50 39 70 29 18 d. 47 82 50 39 X 29 18arrow_forwardThe wait-for graph scheme is not applicable to a resource-allocation system with multiple instances of eachresource type. We need a deadlock detection algorithm that is applicable to such a system. The algorithm employsseveral time-varying data structure that are similar to those used in the banker’s algorithm. Available. A vector of length ? indicates the number of available resources of each type. Allocation: An ? × ? matrix defines the number of resources of each type currently allocated to eachthread Request: An ? × ? matrix indicates the current request of each thread. If Request[i][ j] equals ?, thenthread ?i is requesting ? more instances of resource type ?jThe ≤ relation between two vectors denotes as follows:Let ? and ? be vectors of length ?. We say that ? ≤ ? if and only if ?[?] ≤ ?[?] for all ? = 1,2, . . , ?. For example,if ? = (1,7,3,2) and ? = (0,3,2,1), then ? ≤ ?. In addition, ? < ? if ? ≤ ? and ? ≠ ?. We can treat each row in the matrices ?????????? and ??????? as…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education