simple sorting algorithm.
only check two numbers at a time.
if the number in the lower array index is higher than the number in the higher array index.
>switch numbers
>spot the mistake
>>56214265
>Help me with minor assignment #1
>spot the mistake
OP
>>56214265
The mistake you are using bubble sorting that's the mistake
>>56214265
The mistake is trivial and is left as an exercise to the reader
>niggersort
>that break; means you will swap only one element in the array.
>C++
>>56214265
At least have the decence of begging for someone to do your homework...
>>56214347
>image
Fuck quantum physics
>>56214265
The inner loop is initialized to 1. This is bad, because you basically end up not sorting the array at all, at best only rearranging them.
I'll leave it up to you to figure out what you want to initialize k as, however.
Oh btw, there's another mistake in the outer loops' declaration as well. Not a mistake per-se, but a pointless extra loop that doesn't need to be there.
>>56214265
break
also if you are checking i = 0, k = 1, then you need also i < AMOUNT - 1, and k < AMOUNT
use fucking gdb
>>56214265
>using bubble sort
>not using superior sleep sort.
Why are you over-complicating things?
>>56214265
why are u using C++, i see no OOP
use C
bubble sort is very unintuitive to me
>>56214539
>you basically end up not sorting the array at all, at best only rearranging them.
This is correct. I was thinking we were looking at a bubblesort with some mistakes like the break, but bubblesort swaps adjacent entries only. It's not insertion sort or selection sort either.
>>56214265
>Not creating a min heap to sort
I bet more than half of you wouldn't even be able to roll your own quicksort without consulting google
>>56214265
Okay.