f



Need Coding

Hi,

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



0
iqrakbutt
12/22/2016 6:58:24 AM
comp.lang.c++ 49423 articles. 7 followers. Post Follow

4 Replies
506 Views

Similar Articles

[PageSpeed] 43

On 22.12.2016 07:58, iqrakbutt@gmail.com wrote:
> [homework assignment redacted]

http://www.dietmar-kuehl.de/mirror/c++-faq/how-to-post.html#faq-5.2

Cheers & hth.!,

- ALf


0
Alf
12/22/2016 7:26:20 AM
On Thursday, December 22, 2016 at 9:26:39 AM UTC+2, Alf P. Steinbach wrote:
> On 22.12.2016 07:58, iqrakbutt@gmail.com wrote:
> > [homework assignment redacted]
> 
> http://www.dietmar-kuehl.de/mirror/c++-faq/how-to-post.html#faq-5.2
> 
> Cheers & hth.!,
> 
> - ALf

https://youtu.be/Al9bmstjUjc?t=2s
0
Sal
12/22/2016 3:05:16 PM
iqrakbutt@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!
0
Tim
12/23/2016 6:48:52 AM
On Friday, December 23, 2016 at 12:48:59 AM UTC-6, Tim Rentsch wrote:
> 
> 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!

Happy Chanukah also.


Brian
Ebenezer Enterprises - "If someone curses their father or mother,
their lamp will be snuffed out in pitch darkness."  Proverbs 20:20

http://webEbenezer.net
0
woodbrian77
12/23/2016 4:14:46 PM
Reply: