Hey everyone. I can't seem to figure out the big O notation or the algebraic formula as it applies to this snippet of code.
I'm assuming it is O(n^2)?
Can anyone confirm this or help me out with the algebraic forumla?
e.g. N^2 + 3n
ahhh sorry about the looks of the code. idk how to edit so here it is w/ indents
I'm assuming it is O(n^2)?
Can anyone confirm this or help me out with the algebraic forumla?
e.g. N^2 + 3n
for ( outerLoop = n - 1; outerLoop >= 0; outLoop++) { for (innerLoop = 0; innerLoop < outerLoop; innerLoop++) { if (menuList [ innerLoop ].getMenuName().compareToIgnoreCase(menuList[innerLoop + 1].getMenuName()) > 0) { total = menuList[inner Loop]; menuList[innerLoop] = menuList[innerLoop + 1]; menuList[innerLoop + 1] = total; } } }
ahhh sorry about the looks of the code. idk how to edit so here it is w/ indents
for ( outerLoop = n - 1; outerLoop >= 0; outLoop++) { for (innerLoop = 0; innerLoop < outerLoop; innerLoop++) { if (menuList [ innerLoop ].getMenuName().compareToIgnoreCase(menuList[innerLoop + 1].getMenuName()) > 0) { total = menuList[inner Loop]; menuList[innerLoop] = menuList[innerLoop + 1]; menuList[innerLoop + 1] = total; } } }