New answers tagged

0

Heap is an almost complete binary tree. So if you're planning to construct the tree you can just start by filling the values in the tree from top to down and left to right ie, proceed by filling nodes levelwise. Arraylist or linked list doesn't matter here because both stored the level order traversal of the tree. Ex. list.add(0), list.add(1), list.add(1), ...


0

If I understand correctly, that you denote $n$=list.length and are calculating amount of "list[i] +=" operation. Then of course, as it is triple loop, then for $n$ times fixed "i" from first loop you take $n$ times "j" from second loop and $n$ times "k" from most inner, third, loop. So operation "list[i] +=&...


Top 50 recent answers are included