Does anyone know what the concept of "the worst possible values" means? I need to create/explain a program in C/Python demonstrating them
Does anyone know what the concept of "the worst possible values" means? I need to create/explain a program in C/Python demonstrating them
Last edited by n4rush0; 08-22-2010 at 10:55 AM.
In the C language? Haven't heard of it.
Does your particular problem have a "worst possible values" factor to it?
For instance, if you're program solved the Rubik's Cube, the worst possible values would be values that took the most turns to solve the cube.
Yeah, it sounds like the concept of input that results in a worst case performance for an algorithm. Writing the program in C would mainly be a matter of implementing the algorithm, possibly with some code for tracing number of operations, time taken, etc; you would reason out a possible set of input to trigger a worst case scenario and then just run the program with the input, perhaps contrasting the performance with input that results in average and best cases.
If you can choose the algorithm, one common example would be that of quicksort, where you can contrast O(n**2) worst case with O(n log n) average case.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
That's what I was thinking also, laserlight.
Of course the question was wrong in that case, as the thing you'd be looking for is the worst possible ordering (of values).
The easiest way to demonstrate it is to have a function that constructs a binary search tree (no balancing), and you simply provide the items in sequenctial order. That's a braindead way of doing it though.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
Funny!
The worst possible *starting* configuration values of the Cube.
More simply, say you had to find the smallest possible value for a signed integer. If you started with an initial value that was the greatest possible value for a signed integer, you would have the worst possible value, for that search.
It would take you the longest time or most iterations, to find the answer.
FYI: They've very recently proved that every possible starting combination of a rubic cube can be solved in 20 moves.
Given the computing power it required to do so, you won't be working out the worst possible starting point yourself any time soon.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
The only way I could solve those damn things was to pull the stickers off and put them where they belong! I never had the patience to sit there for hours turning & twisting it...
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
I believe Rubik's Cube solving is like Algebra, Geometry, or lots of other "puzzling" things. You have to work with them for awhile, barely getting any "speed" up, in understanding, at first. After a certain amount of study, the light bulb goes off, and *wham!*, you're on your way at flank speed.