diff --git a/PA02-0913/PA02_Main b/PA02-0913/PA02_Main index 1a577e4..1de6908 100755 Binary files a/PA02-0913/PA02_Main and b/PA02-0913/PA02_Main differ diff --git a/PA02-0913/PA02_Main.c b/PA02-0913/PA02_Main.c index ec390c5..929535b 100644 --- a/PA02-0913/PA02_Main.c +++ b/PA02-0913/PA02_Main.c @@ -72,7 +72,7 @@ int main() // display original list displayData( wkgArray, wkgNumStates, "Original data after state removal" ); - /* + // bubble sort // function: runBubbleSort runBubbleSortByName( sortingArray, sortingNumStates ); @@ -80,7 +80,7 @@ int main() // display bubble-sorted list displayData( sortingArray, sortingNumStates, "Full list sorted by name using bubble sort" ); - + /* // insertion sort // function: runInsertionSort runInsertionSortByPopulation( sortingArray, sortingNumStates ); diff --git a/PA02-0913/StateUtilities.c b/PA02-0913/StateUtilities.c index 316c8ce..b26c386 100644 --- a/PA02-0913/StateUtilities.c +++ b/PA02-0913/StateUtilities.c @@ -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 }