Posts

Showing posts from April 2, 2019

Program to check if heap order is correct or not

Image
up vote 0 down vote favorite There is a Java program to check if a Heap (Min) is in the correct order. Heap Order means the parent is less than both left child and right child. package testers; import heap.Heap; import java.util.List; public class HeapTester { public static void main(String args) { Heap<Integer> heap = new Heap <>(); heap.add(50); heap.add(25); heap.add(26); heap.add(15); heap.add(10); heap.add(16); heap.add(3); heap.add(7); heap.add(10); heap.add(12); heap.add(2); System.out.println(heap); System.out.println(hasHeapOrder(heap.copy())); } private static <T extends Comparable<T>> boolean hasHeapOrder(List<T> list) { if(li

Matrix with no negative elements = Positive Semi Definite?

Image
up vote 0 down vote favorite A matrix $A$ is positive semi-definite IFF $x^TAxgeq 0$ for all non-zero $xinmathbb{R}^d$ . If all elements of $A$ are non-negative, does this guarantee that $A$ is positive semi-definite? positive-semidefinite share | cite | improve this question asked Oct 31 at 2:18 Iamanon 115 7 add a comment  |  up vote 0 down vote favo