Skip to content
Snippets Groups Projects
Commit 186c9f84 authored by tanguy.dietrich's avatar tanguy.dietrich
Browse files

Ecriture de .depth() pour le BinaryHeap

parent e1173670
No related branches found
No related tags found
2 merge requests!2Tanguy,!1David
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -35,6 +35,18 @@ final public class BinaryHeap
}
}
public int depth()
{
int index=this.size();
int dptCompteur=1;
while(index!=0)
{
index=this.getParentNodeIndex(index);
dptCompteur++;
}
return dptCompteur;
}
public boolean exist(int k)
{
for(int val:this.lstBinaryHeap)
......
......@@ -35,5 +35,6 @@ class BinaryHeapTest
assertEquals(bHeapRand.isEmpty(),false);
assertEquals(bHeap.exist(7),true);
assertEquals(bHeap.exist(42),false);
assertEquals(bHeap.depth(),4);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment