Re: "Sorting" assignment
- From: "Bartc" <bc@xxxxxxxxxx>
- Date: Fri, 08 Feb 2008 11:31:47 GMT
spinoza1111 wrote:
On Feb 7, 7:17 pm, "Clive D. W. Feather" <cl...@on-the-
train.demon.co.uk> wrote:
bool bubble;
do
{
bubble = false;
for (int i = 0; i < arraySize - 1; i++)
if (array [i] > array [j])
{
exchange (i, j);
bubble = true;
}}
while (bubble);
(2) The last value for i is the arraySize minus one but this is wrong
insofar as I can determine your intent from bug number 3. Because of
zero-origin indexing that should be arraySize minus two.
(3) You failed to compute j at all.
No, the last value for i is arraySize-2 in the above loop.
--
Bart
.
- Follow-Ups:
- Re: "Sorting" assignment
- From: spinoza1111
- Re: "Sorting" assignment
- From: Malcolm McLean
- Re: "Sorting" assignment
- References:
- "Sorting" assignment
- From: Ivica
- Re: "Sorting" assignment
- From: spinoza1111
- Re: "Sorting" assignment
- From: Clive D. W. Feather
- Re: "Sorting" assignment
- From: spinoza1111
- Re: "Sorting" assignment
- From: Clive D. W. Feather
- Re: "Sorting" assignment
- From: spinoza1111
- "Sorting" assignment
- Prev by Date: Re: Message from spinoza1111
- Next by Date: Re: printf() function
- Previous by thread: Re: "Sorting" assignment
- Next by thread: Re: "Sorting" assignment
- Index(es):
Relevant Pages
|