Trying to bubble sort

+- PA02_Main
+- PA02_Main.c
+- StateUtilities.c
This commit is contained in:
Charles Descamps 2023-09-12 09:49:07 -07:00
parent a88b49135b
commit f48c96705e
3 changed files with 27 additions and 6 deletions

View file

@ -395,10 +395,31 @@ Dependencies: as needed
*/
void runBubbleSortByName( StateDataType *array, int size )
{
// start iterator at size - 2?
// iterate through iterator
// check the current index vs the next one.
// if current > next, swap.
int bubbleCount;
int arrayCount;
printf("\nArray @ 0: %s\n", array[0].name);
printf("\nArray @ 1: %s\n", array[1].name);
printf("\nArray @ 2: %s\n", array[2].name);
printf("\nArray @ 3: %s\n", array[3].name);
printf("\nArray @ 4: %s\n", array[4].name);
printf("\nArray @ size: %s\n", array[size].name);
// use two for loops to iterate through array
// for(bubbleCount = 0; bubbleCount < size - 1; bubbleCount++)
// {
// for(arrayCount = bubbleCount + 1; arrayCount < size; arrayCount++)
// {
// printf("\nValue of bubbleCount: %d\n", bubbleCount);
// printf("\nValue of arrayCount: %d\n", arrayCount);
// //printf("\nValue of array[arrayCount].name: %s", array[0].name);
// //printf("\nValue of array[arrayCount + 1].name: %s\n", array[1].name);
// // check the current index vs the next one.
// if(strcmp(array[arrayCount].name, array[arrayCount + 1].name) > 0)
// {
// // if current > next, swap. AKA: strcmp(current, next) > 0
// swapElements(array, arrayCount, arrayCount + 1);
// }
// }
// }
// no return, void
}