How to do this problem?
Posted by
Li, Yi 27 Sep 2001 19:35
Re: How to do this problem?
>
Sort using "basket" !
mailto : trungduck@yahoo.com
Re: How to do this problem?
Posted by
Li, Yi 28 Sep 2001 14:59
I'm afraid I can't understand.
Say more, OK?
> >
> Sort using "basket" !
> mailto : trungduck@yahoo.com
Re: How to do this problem?
There is no need to use sorting. (I don't know what
is "basket" - maybe the same as I mean.) You can just read
all the teams` info and remember every team in the dynamic
array [1..100] some way. Then u can from n downto 1 print
all the teams.
I'm realising this algorythm but still have mistakes. ;)
> I'm afraid I can't understand.
> Say more, OK?
>
> > >
> > Sort using "basket" !
>
> > mailto : trungduck@yahoo.com
Re: How to do this problem?
How do you remember every team in dynamic array[1..100] ?
It haven't got enough memory. I needn't remember that, I
just remember id and score of each team and go from 100
downto 0 to print all team at that score. It's sorting
using basket.
mailto : trungduck@yahoo.com
> There is no need to use sorting. (I don't know what
> is "basket" - maybe the same as I mean.) You can just
read
> all the teams` info and remember every team in the
dynamic
> array [1..100] some way. Then u can from n downto 1 print
> all the teams.
> I'm realising this algorythm but still have mistakes. ;)
>
> > I'm afraid I can't understand.
> > Say more, OK?
> >
> > > >
> > > Sort using "basket" !
> >
> > > mailto : trungduck@yahoo.com
>
u can use bubble sort or quicksort
with the array B[i] of longint defined that
B[i] = M[i] * 10000000 + ID[i] - 1
then sort the B[i]
for i = 1 to N
print (B[i] mod 10000000 + 1) ' ' B[i] div 10000000
QH@
Re: How to do this problem?
> Yeah, you're right. Array[0..100]... and we save the
teams' ID-s and after that from 100 to 0 print all teams
and scores. I just didn't know the name of this algorythm -
it was just what appeared in my mind first.
How do you remember every team in dynamic array[1..100] ?
> It haven't got enough memory. I needn't remember that, I
> just remember id and score of each team and go from 100
> downto 0 to print all team at that score. It's sorting
> using basket.
> mailto : trungduck@yahoo.com
>
> > There is no need to use sorting. (I don't know what
> > is "basket" - maybe the same as I mean.) You can just
> read
> > all the teams` info and remember every team in the
> dynamic
> > array [1..100] some way. Then u can from n downto 1
print
> > all the teams.
> > I'm realising this algorythm but still have mistakes. ;)
> >
> > > I'm afraid I can't understand.
> > > Say more, OK?
> > >
> > > > >
> > > > Sort using "basket" !
> > >
> > > > mailto : trungduck@yahoo.com
> >
You method is absolutely wrong.
> with the array B[i] of longint defined that
> B[i] = M[i] * 10000000 + ID[i] - 1
> then sort the B[i]
> for i = 1 to N
> print (B[i] mod 10000000 + 1) ' ' B[i] div 10000000
>
> QH@
Wrong!For the problem didn't request that when two teams
have the same M value,the team with the larger ID must be
put to forward.The problem means if two teams have the same
M value,the position of them must according to their
original position before bubble sort is performed.
Re: How to do this problem?
> How do you remember every team in dynamic array[1..100] ?
My idea is using linked list. But you'll get memory limit exceed anyway
due to memory comsumpion of the additional pointers , "if you don't
think more".