Computers and Technology, 03.09.2020 03:01 cocoapop
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);}}}
Answers: 3
Computers and Technology, 22.06.2019 12:30
Which of the choices sean are not true when considering virus behavior
Answers: 1
Computers and Technology, 23.06.2019 15:30
Write a program in plp assembly that counts up by one starting from zero (or one) inside a loop and writes this value to the leds every time the value is increased. the memory address of the leds is 0xf0200000. the table below shows the meaning and an example usage of the instructions covered in the video, plp instructions for project 1. instruction example usage meaning load immediate li $t0, 8 register $t0 is set to the value, 8. store word sw $t2, 0($t1) the value in register $t1 is used as the memory address. the value in register $t2 is copied into this memory address. add addiu $t4, $t3, 29 register $t4 is assigned the sum of 29 and the value in register $t3. jump j your_label_name the program jumps to the line following the label, "your_label_name: ". label your label name: defines a label called "your_label_name: " that can be jumped to
Answers: 2
Computers and Technology, 24.06.2019 10:20
Identify the publisher in this citation: carter,alan.a guide to entrepreneurship.new york: river’2008.print.
Answers: 3
Computers and Technology, 24.06.2019 15:00
Who introduced the concept of combining artificial and natural light in the studio
Answers: 1
This is an in-place heap-tree and I got some problem with finish the methods. I hope you could help...
Advanced Placement (AP), 07.12.2020 16:30
History, 07.12.2020 16:30
Mathematics, 07.12.2020 16:30
Biology, 07.12.2020 16:30
Mathematics, 07.12.2020 16:30
Mathematics, 07.12.2020 16:30
English, 07.12.2020 16:30
History, 07.12.2020 16:30
Mathematics, 07.12.2020 16:30
Mathematics, 07.12.2020 16:30