Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is my analysis correct?  RSS feed

 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In terms if big-O, I calculate the following to be O(n^2). Am I correct?

 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is it supposed to do? Is it selection sort? That does run in n² time, yes.
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:What is it supposed to do? Is it selection sort? That does run in n² time, yes.


Yes sir, it's a selection sort 😀
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In school, we were always asked to show our solutions. It was not enough to just say what we thought the answer was, we had to give the details for how we arrived at the answer. Can you explain how you came up with O(n^2)?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!