jan
jan
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
would swapping elements of a span propagate to the original array though?
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
yeah I get it now, it actually looks very logically correct when you think about it
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
out of curiosity, what's simpler in a span? I haven't worked with it yet, got no idea how they work, and although they might be faster/more optimal, I think array is just fine here because it exhausts the needs of this algorithm just right, without making code unreadable/complicated
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
:EZ:
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
I've implemented swapCount and callCount and confirmed that middle pivot does ~2-8x more swaps than the rightmost pivot
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
MEANWHILE when we choose middle element in an A shaped array, we get ~array.Length swaps
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
because pivotValue == 1
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
when we choose righmost pivot, the if-statement in Partition:
if (array[currentIndex] <= pivotValue)
{
Swap(array, currentIndex, lastSmallerElementIndex);
lastSmallerElementIndex++;
}
if (array[currentIndex] <= pivotValue)
{
Swap(array, currentIndex, lastSmallerElementIndex);
lastSmallerElementIndex++;
}
is true only for 1 element (at least on a [1 2 3 4 5 4 3 2 1] array), therefore it executes 1 swap
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
rightmost vs middle pivot points have similar amount of calls but not SWAPS
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
guys omg
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
I FOUND IT
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
im just gonna do that in python tbh im tired of this
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
exactly, mirror version of the right-recursive right?
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
idk tbh im getting mad at this
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
it returns only if it's given an array of size 1, then everything is being put back altogether
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
okay but when you apply same logic to the partitions from 1st iteration, we also get 2 partitions with 1 being empty and the other one being full
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
so it's just mirrored no?
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
and the rightmost pivot on first iteration gives you pivot being the smaller nubmer which ends up with first partition empty and the second one full
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
middle pivot in first iteration gives you pivot being the largest number in the array, so you will end up with first partition full of numbers and the second one empty, because there's no elements larger than the pivot
66 replies
CC#
Created by jan on 4/26/2025 in #help
Coursework analysis of quicksort results in (very) unexpected behaviour
look
66 replies