explanation of this algorithm

function equivalence(m,n)
//n variables,m equivalence relations
//bit is a boolean array
//seq is an array of pointers each one is pointing to the list of elements called equivalence elements
for i = i to n do seq(i)<-bit(i)<-0;
for k=1 to m do
[read-next pair(i,j)
getnode(x);
data(x)<-j;
link(x)<-seq(i);
seq(i)<-x;
getnode(x);
data(x)<-i;
link(x)<-seq(j);
seq(j)<-x;
]
index<-1
repeat
if bit(index)=0 then
[
print ("new equivalence class",index)
bit(index)<- 1;
ptr<-seq(index);
top<- 0
loop
while ptr(!= 0)
do
[j<-data(ptr)
if bit(j)= 0 then
[print(j);
bit(j)<-1
t<-link(ptr)
link(ptr)<- top
top<-ptr
ptr<-t;]
else
ptr<-link(ptr)
]//end while
ptr<-seq(data(top))
top<-link(top)
forever]
if bit(index)=0
index<-index + 1;
until index>w
end
TrustyTony commented: Don't dump homework without own effort! -3

It is your homework. Who would know better than you do about what you are talking about this somewhat pseudo code?

Also, there are many unknown variables in the code...
1)Is "seq" a global variable? Because it just pops up in the function without declaration.
2)Where does "x" come from? All the sudden it is being used in getnode(x);
3)You need to explain the implication of value "0" in the code. It seems to represent both "false" and "null" values?
4)What is data?
5)What is link?
6)What does getnode() do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.