subject

This is an in-place heap-tree and I got some problem with finish the methods. I hope you could help me to finish it or just write a new one. The program includes insert() and remove()Please try to insert(5, A), insert(4, B), insert(7, F), insert(1, D), remove(Min) and show the result by screenshot. public class HeapTree {private int[] data;private int heapSize;public BinaryMinHeap(int size) {data = new int[size];heapSize = 0;}public int getMinimum() {if (isEmpty())throw new HeapException("Heap is empty");elsereturn data[0];}public boolean isEmpty() {return (heapSize == 0);}…private int getLeftChildIndex(int nodeIndex) {return 2 * nodeIndex + 1;}private int getRightChildIndex(int nodeIndex) {return 2 * nodeIndex + 2;}private int getParentIndex(int nodeIndex) {return (nodeIndex - 1) / 2;}public class HeapException extends RuntimeException {public HeapException(String message) {super(message);} public void removeMin() {if (isEmpty())throw new HeapException("Heap is empty");else {data[0] = data[heapSize - 1];heapSize--;if (heapSize > 0)siftDown(0);}}public void insert(int value) {if (heapSize == data. length)throw new HeapException("Heap's underlying storage is overflow");else {heapSize++;data[heapSize - 1] = value;siftUp(heapSize - 1);}}private void siftDown(int nodeIndex) {int leftChildIndex, rightChildIndex, minIndex, tmp;leftChildIndex = getLeftChildIndex(nodeIndex);rightC hildIndex = getRightChildIndex(nodeIndex);if (rightChildIndex >= heapSize) {if (leftChildIndex >= heapSize)return;elseminIndex = leftChildIndex;} else {if (data[leftChildIndex] <= data[rightChildIndex])minIndex = leftChildIndex;elseminIndex = rightChildIndex;}if (data[nodeIndex] > data[minIndex]) {tmp = data[minIndex];data[minIndex] = data[nodeIndex];data[nodeIndex] = tmp;siftDown(minIndex);}}}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:40
For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. after converting to the postfix expression, the program should evaluate the expression from the postfix and display the result. what should you submit? write all the code in a single file and upload the .c file. compliance with rules: ucf golden rules apply towards this assignment and submission. assignment rules mentioned in syllabus, are also applied in this submission. the ta and instructor can call any students for explaining any part of the code in order to better assess your authorship and for further clarification if needed. problem: we as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). in computer's language, however, it is preferred to have the operators on the right side of the operands, ie. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix write a program that takes an "infix" expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % ( example infix expression: (7-3)/(2+2) postfix expression: 7 3 2 2 result: rubric: 1) if code does not compile in eustis server: 0. 2) checking the balance of the parenthesis: 2 points 3) incorrect postfix expression per test case: -2 points 4) correct postfix but incorrect evaluation per test case: -i points 5) handling single digit inputs: maximum 11 points 6) handling two-digit inputs: 100 percent (if pass all test cases)
Answers: 3
question
Computers and Technology, 22.06.2019 21:30
The salespeople at hyperactive media sales all use laptop computers so they can take data with them on the road. you are a salesperson for superduper lightspeed computers talking to hyperactive media sales about upgrading the laptops to windows 10. explain how network location awareness in windows 10 would make the laptops more secure.
Answers: 3
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
In which of the following ways can using test-taking tips you? a. you can focus on the information that you need to study. b. you will see the answers to the test. c. you will study more. d. you will be less organized.
Answers: 1
You know the right answer?
This is an in-place heap-tree and I got some problem with finish the methods. I hope you could help...
Questions
question
Mathematics, 01.03.2021 19:30
question
Health, 01.03.2021 19:30
Questions on the website: 13722359