Java quiz need help :Add the following numbers in the order given to a (min) heap using the heap add algorithm (with trickle-up).
23 - 57 - 12 - 85 - 72 - 55 - 8 - 49 - 88 - 62 - 11 - 94
Ans:
Java quiz need help :Add the following numbers in the order given to a (min) heap...
JAVA (Heap operations) A. Add a node with value 3 to the following min heap. Show the upheap swap process needed to restore the heap-order property. You will need at least three diagrams. B. Remove the root node from the following heap. You will need to downheap swap to restore the heap-order property. Use diagrams to show the state of the heap at each step. You will need at least three diagrams.
Write a Java program, In this project, you are going to build a max-heap using array representation. In particular, your program should: • Implement two methods of building a max-heap. o Using sequential insertions (its time complexity: ?(?????), by successively applying the regular add method). o Using the optimal method (its time complexity: ?(?), the “smart” way we learned in class). For both methods, your implementations need to keep track of how many swaps (swapping parent and child) are required...
Java class quiz question If you add ten nodes into a heap what would be the maximum height of the tree generated? A. 10 B. 5 C. 4 D. 3 E. 2
This question is about the min-heap. A min-heap with 10 elements is given in the following array format. The following three sub-questions all refer to this min-heap i 1 2 3 4 5 6 7 8 9 10 A[i] 11 22 33 44 55 66 77 88 99 100 Show the result after applying heap-decrease-key(A, 6, 12) to the min-heap at the top of this page: i 1 2 3 4 5 6 7 8 9 10 A[i] Show the...
Please finish all the questions,Thanks Following is Appendix assume the definition of Java class Heap given in the Appendix For this question, a. (2 marks Consider the following heap 30 12 20 19 6 10 18 Given the array representation of a heap discussed in class, what is the array that corre sponds to this heap? b. (5 marks) Successively insert into the heap of part (a.) 22, 35 and 11, in that order. Use the standard heap insertion algorithm....
[Heap] Create a min-binary heap using following numbers (appearing/inserting in the given order): 5, 22, 19, 56, 50, 25, 1, 3, 10, 6, 32, 12, 11 [Hint: you can put the items in sequence in a binary tree and then use the buildHeap() method.] [Hashing] Consider a hash table where the hash function h is defined as the modulo 10 operation i.e., for any integer k, h(k) = k % 10 (the ‘modulo 10’ operator returns the remainder when k...
Written in Java Your job is to produce a program that sorts a list of numbers in ascending order. Your program will need to read-in, from a file, a list of integers – at which point you should allow the user an option to choose to sort the numbers in ascending order via one of the three Sorting algorithms that we have explored. Your program should use the concept of Polymorphism to provide this sorting feature. As output, you will...
I need it in JAVA Write a program that randomly populates an array of size 100, sorts it, and then finds the median. The random numbers must be from 0-99 and all integer values. Also since there is an even set of numbers the median is found by taking the mean of the two middle numbers (In other words the 50th and 51st). You have to code your own sorting method. You may not use a built in java sorter....
need full solution of this question plz help me Question 1 (CLO-4, PLo-3) Figure 1 show an input tree T. 1. Analyze the tree and mention weather the tree is a heap or not by checking heap's property. If yes, justify your answer. If no, make it a heap by adjusting the node's location 2. Alter the value of T[l1] to 100 using alter-heap algorithm. Analyze the tree again and state whether i. The tree is still a heap or...
The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random numbers from 1 to 100. – It asks the user for an index value between 0 and 99. – Prints the element at that position. – If a number > 99 is entered by the user, the class will abort with an ArrayIndexOutOfBoundsException • Modify the ExceptionLab: – Add a try-catch clause which intercepts the ArrayIndexOutOfBounds and prints the message: Index value cannot be...