procedure equivalence input the equivalence pairs and output

procedure equivalence input the equivalence pairs and output the equivalence classes) type pointer = triode node = record data 1..n link : pointer end; var seq array [I..n] of pointer out : array [I..n] of boolean; i integer xy.top : pointer; done: boolean; begin finitialize seq and out) for i = l to n do begin seq(f] := nil, our (Phase I: input equivalence pairs while not eo input) do begin true: end: readin(i,) new(x): (add j to list seqt]) x1.data :=j: x1.link := seqseq[f] := x; new(x); (add i to list seqUl xl data := i; xt.link := seqsed1 := x; end; (Phase 2: output the equivalence classes for i := 1 to n do if out [ (needs to be output) then begin writeln(A new class:\' ou[]false; x = seq(top := nil; (init stack} done := false; repeat [find rest of class) while x nil do (process the list) begin j := xt data; if out U then begin

Solution

The above code given is in pascal , as there will be procedures in pascal along with I/O features like writeln , var to declare variables, keywords like bgin end to begin and stop the loop .

Code in c++ to find equivalence classes :

enum boolean{FALSE,TRUE};

class listnode{

friend void equivalence()

praivate:

int data;

Listnode *link;

ListNode(int);

};

Typedef lisnode ListNode*;

ListNode::ListNode(int d)

{

data=d;

link=0;

}

void equivalence()

{

ifstream infile(\"eqiv.in\" ios::in);

if(!infile)

{

cerr<<\"cannot open iput file\"<<endl;

return;

}

int i,j,n;

inFile>>n;

infile>>i>>j;

 procedure equivalence input the equivalence pairs and output the equivalence classes) type pointer = triode node = record data 1..n link : pointer end; var seq
 procedure equivalence input the equivalence pairs and output the equivalence classes) type pointer = triode node = record data 1..n link : pointer end; var seq

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site