Home
[This page is auto-generated; please prefer to read the article’s PDF Form.]
[Prev] [Up] [Next] Heap’s Algorithm
void brheap_nonrecur()
{
int I[N-1], s;
for(s = 0; s < N-1; s++)
I[s] = 0;
print();
s = N-2;
while(s >= 0)
{
if(I[s] < N-s-1)
{
I[s]++;
/* Setup Block */
if((N-s)%2 != 0)
SWAP(s, N-1)
else
SWAP(s, N-I[s])
print();
s = N-2;
}
else
{
I[s] = 0;
s = s-1;
}
}
}
[Prev] [Up] [Next]
Copyright © 2021 Nitin Verma. All rights reserved.