iqra...@gmail.com writes:
> Can anyone do C++ coding for below pseudocode. I will be really
> thankful.
>
> INPUT:Ni, Hopmin ,i,SNi
> OUTPUT:NHi
>
> 1: for(AllnodesinlistNi)do
> 2: ComputeCostij,j2Ni
> 3: endfor
> 4: j=firstelementofNi
> 5: while(NotendoflistNi)do
> 6: if(HOPmin,j+1==HOPmin,i)then
> 7: addjtoSNi
> 8: endif
> 9: j=nextelementofNi
> 10: endwhile
> 11: SortSNi(indescendingorderofCostij)
> 12: NHi=FirstelementofthelistSNi
I'm trying to resist the temptation to post C++ code for this
pseudocode... oh what the heck....
typedef std::vector<int> VI;
void
something( VI Ni, int Hopmin, int i, VI SNi, int *NHi ){
auto Costij = 0;
extern void Compute( int );
auto j2Ni = 0;
for( auto node : Ni ){
Compute( Costij ),j2Ni;
}
auto j = Ni.begin();
while( ! (j == Ni.end()) ){
if( Hopmin, *j+1 == Hopmin, i ){
SNi.push_back( *j );
}
j += 1;
}
extern void SortSNI( int );
SortSNI( Costij );
*NHi = SNi.front();
}
The Compute() and SortSNI() functions need to be supplied, and
there may be a few other details in need of correction. I'm sure
though that these are minor issues now that the pseudocode has
been faithfully translated.
P.S. I hope y'all will forgive my little joke. Merry Christmas!