Please work out using PSEUDOCODE to answer Thanks For Short
Please work out using PSEUDOCODE to answer! Thanks!
For Short Answer Question refer to the following array: Write a program segment to sort the given array in alphabetical order using the bubble sort method.Solution
//PSEUDOCODE to sort items using bubbleSort
procedure bubbleSort( A : list of sortable items )
n = length(A)
repeat
swapped = false
for i = 1 to n-1 inclusive do
if A[i-1] > A[i] then
swap(A[i-1], A[i])
swapped = true
end if
end for
n = n - 1
until not swapped
end procedure
//c function for bubbleSort
void SortNames(char** ppchNames, int iCount)
{
int i,j;
for (j = 0; j < iCount -1; j++) {
for (i = 0; i < iCount -1; i++) {
if (0 < strcmp(ppchNames[i], ppchNames[i +1])) {
char* pchTemp = ppchNames[i];
ppchNames[i] = ppchNames[i +1];
ppchNames[i +1] = pchTemp;
}
}
}
}
