|
That's the conclusion I made too, but what I understand from various sources is that we go through n iterations, where the lowest value for that iteration is swapped with the element at position n and the next iterations starts at element n+1. So when we have {2, 3, 1} we swap 1 and 2 in the first iteration, start at 3 in the second iteration (and swap it with 2) and start at 3 in the last iteration (do nothing) and we're done.
And that makes sense, because why would you want to check elements that you know are sorted?
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
So the actual number of steps is n(n - 1)/2 (the sum of all integers from 1 to n - 1 ).
Since Big-O notation only cares about the term with the largest growth rate, that becomes O(N<sup>2</sup>) .
http://en.wikipedia.org/wiki/Selection_sort#Analysis[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oh yeah, it's about growth... So now maybe I get the big O, but now I don't know how to interpret n^2
I guess I'll dive into some mathy stuff
Really, math is the only thing where I think I get it until I get to the next problem and find I didn't get any of it... And math just keeps coming back too
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
I read a story about O once - but I don't remember there being much maths in it
|
|
|
|
|
Fluent XML Parsing using C#'s Dynamic Object[^]
Now, granted, probably dog slow compared to other forms, but for simple stuff where performance isn't critical, the XML structure is known, it's a good edition to the toolchest of useful stuff!
Marc
|
|
|
|
|
Yeah, poor performance. Also, it might work for reading, but probably not for adding.
As long as you already have to know the structure/schema of the XML you might as well write specific classes to do that faster and safer.
|
|
|
|
|
PIEBALDconsult wrote: Also, it might work for reading, but probably not for adding.
His part 2 covers writing.
PIEBALDconsult wrote: As long as you already have to know the structure/schema of the XML you might as well write specific classes to do that faster and safer.
I just hate backing classes that are nothing more than "mostly bags of water". But the dynamic code approach is too hard-wired for my tastes. Ugh, I guess there's no good answer, especially since I'm translating XML into DB transactions, and the XML schema and the database schema have really no similarities.
Marc
|
|
|
|
|
Marc Clifton wrote: Ugh, I guess there's no good answer, especially since I'm translating XML into DB transactions, and the XML schema and the database schema have really no similarities.
Haha, leaving infamous morsels of talking for a while of yapping away.
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
|
|
|
|
|
|
Whoa! didn't hear about that. All the best to my man Bruce.
Up the Irons!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
'Cause if you're gonna die die with your boots on!
Geek code v 3.12
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
|
|
|
|
|
|
This smoking thing really sucks
|
|
|
|
|
Why does Spongebob Wearpants?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Because its Squarepants !
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
He was forced to wear them by the censor board to hide a few pores.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Cuz frying krabby patties with no pants just seems wrong.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Well, duh!
Sponges float! He keeps rocks in his pockets!
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
To hide his boner from Sandy.
There is only one Vera Farmiga and Salma Hayek is her prophet!
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
OriginalGriff wrote: Why does Spongebob Wearpants?
There's a thought I don't even want to contemplate.
Marc
|
|
|
|
|
To stop from absorbing everything.
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
He doesn't want people to be jealous.
Wout
|
|
|
|
|
OriginalGriff wrote: Why does Spongebob Wearpants
Because his dick is obscene?
|
|
|
|
|
Here[^]
I found it quite tough actually, and question 6 I just couldn't fathom the logic of.
Anyway, 90% was my score.
|
|
|
|
|
80% - I notice there is far less Latin and English History in it these days...
|
|
|
|