jeudi 14 mars 2019

How to draw a Control Flow graph for this quicksort code

How to draw a control flow graph for this quicksort example.I am able to draw some part of it but got lost when I tried to do the do while loops and nested loops. If someone can explain the process of that would be very helpful Thanks

void quicksort(element list[], int left, int right)
{ int pivot, i, j;
element temp;
if (left < right)
{ i = left; j = right+1;
pivot = list[left].key;
do
{ do i++; while (list[i].key < pivot);
do j--; while (list[j].key > pivot);
if (i < j) SWAP(list[i], list[j], temp);
} while (i < j);
SWAP(list[left], list[j], temp);
quicksort(list, left, j-1);
quicksort(list, j+1, right);
}
}

Aucun commentaire:

Enregistrer un commentaire