Click here to Skip to main content
15,913,289 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 0:02
Munchies_Matt24-Feb-15 0:02 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 3:54
professionalAlbert Holguin24-Feb-15 3:54 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 4:02
Munchies_Matt24-Feb-15 4:02 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 4:06
professionalAlbert Holguin24-Feb-15 4:06 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 4:13
Munchies_Matt24-Feb-15 4:13 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 4:16
professionalAlbert Holguin24-Feb-15 4:16 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 5:13
Munchies_Matt24-Feb-15 5:13 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt23-Feb-15 22:25
Munchies_Matt23-Feb-15 22:25 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 4:00
professionalAlbert Holguin24-Feb-15 4:00 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 4:12
Munchies_Matt24-Feb-15 4:12 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Frankie-C24-Feb-15 5:19
Frankie-C24-Feb-15 5:19 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 6:46
Munchies_Matt24-Feb-15 6:46 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Frankie-C24-Feb-15 21:46
Frankie-C24-Feb-15 21:46 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 22:12
Munchies_Matt24-Feb-15 22:12 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Frankie-C24-Feb-15 22:49
Frankie-C24-Feb-15 22:49 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 22:57
Munchies_Matt24-Feb-15 22:57 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Frankie-C24-Feb-15 23:02
Frankie-C24-Feb-15 23:02 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 23:06
Munchies_Matt24-Feb-15 23:06 
QuestionDeviceIoControl for drive information Pin
john563223-Feb-15 3:20
john563223-Feb-15 3:20 
QuestionQuicksort slower than mergesort... Pin
gautgaut20-Feb-15 13:22
gautgaut20-Feb-15 13:22 
I try to implement classical sorting algorithm, I do not understand why my quicksort is slower than my mergesort. I spend a lot of time trying to understand why. Do you have any idea ?

For both :
#define ARRAY_INDEX(tab, i) ((void*)((char*)(tab) + (i) * type_size))


My mergesort :
void merge(void *tab, void *aux, int a, int b)
{
	int		i, j, k, mid;

	ft_copy_tab(tab, aux, a, b);
	mid = (a + b) / 2;
	i = a;
	j = mid + 1;
	k = a;
	while (k <= b)
	{
		if (i > mid)
			ft_copy_index(tab, aux, k, j++);
		else if (j > b)
			ft_copy_index(tab, aux, k, i++);
		else if (f_cmp(ARRAY_INDEX(aux, i), ARRAY_INDEX(aux, j)) > 0)
			ft_copy_index(tab, aux, k, j++);
		else
			ft_copy_index(tab, aux, k, i++);
		k++;
	}
	return ;
}


My quicksort :

void ft_quicksort(void *tab, int a, int b)
{
	int i, lower, upper;

	if (a >= b)
		return ;
	lower = a;
	upper = b;
	i = a;
	while (i <= upper)
	{
		if (f_cmp(ARRAY_INDEX(tab, lower), ARRAY_INDEX(tab, i)) > 0)
		{
			ft_swap(tab, lower, i, type_size);
			lower++;
			i++;
		}
		else if (f_cmp(ARRAY_INDEX(tab, lower), ARRAY_INDEX(tab, i)) < 0)
		{
			ft_swap(tab, i, upper, type_size);
			upper--;
		}
		else
			++i;
	}
	ft_sort(tab, a, lower - 1);
	ft_sort(tab, upper + 1, b);
}

AnswerRe: Quicksort slower than mergesort... Pin
David Crow20-Feb-15 15:43
David Crow20-Feb-15 15:43 
GeneralRe: Quicksort slower than mergesort... Pin
gautgaut21-Feb-15 0:56
gautgaut21-Feb-15 0:56 
GeneralRe: Quicksort slower than mergesort... Pin
Stefan_Lang23-Feb-15 20:50
Stefan_Lang23-Feb-15 20:50 
GeneralRe: Quicksort slower than mergesort... Pin
gautgaut26-Feb-15 6:46
gautgaut26-Feb-15 6:46 
Questiondecision tree Pin
Member 1146482519-Feb-15 7:21
Member 1146482519-Feb-15 7:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.