File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
out/production/Algorithms/ws/codelogic/algorithms/priorityqueue
src/ws/codelogic/algorithms/priorityqueue Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ public BinaryTree(Comparable[] emptyArray){
1717 public void add (Comparable element ){
1818 elements [++indexOfLastElement ] = element ;
1919 swim (indexOfLastElement );
20+ debug ();
2021 }
2122
2223 private void swim (int index ) {
@@ -65,20 +66,11 @@ private boolean hasParent(int index) {
6566 public Comparable remove (){
6667 exchange (0 , indexOfLastElement );
6768 sink (0 );
68- elements [indexOfLastElement ] = 0 ;
6969 return elements [indexOfLastElement --];
7070 }
7171
7272 private void sink (int index ){
73- //DEBUG
74- System .out .println ("debug-BinaryTree: " );
75- for (Comparable c : elements ){
76- System .out .println (c );
77- }
78- System .out .println ("--------------" );
79- System .out .println (index + " " + child1 (index ));
80- //DEBUG
81-
73+ debug ();
8274 child1 = child1 (index );
8375 child2 = child2 (index );
8476
@@ -93,5 +85,15 @@ private int child2(int index){
9385 return child1 (index )-1 ;
9486 }
9587
88+ private void debug (){
89+ //DEBUG
90+ System .out .println ("debug-BinaryTree: " );
91+ for (Comparable c : elements ){
92+ System .out .println (c );
93+ }
94+ System .out .println ("--------------" );
95+ //DEBUG
96+ }
97+
9698
9799}
You can’t perform that action at this time.
0 commit comments