|
Yes, but since your test has an even spread that should not be the case.
Did you notice any difference between even spread and random spread?
|
|
|
|
|
that's only for the sequential tests. Since the keys are random in the random test, the spread is random.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Now you feel the power of the Dark Side. Many never even took a look at it. Not because they are so good and noble, but because they are lazy and happily believe in the myth that the classes in this or that framework are the last word in each and every case.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
well, in fairness it's not often people have to search and sort 100000 items without using a database
The b-tree is a bit heavy handed, but it works pretty well even with 100 items so it was worth having.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: well, in fairness it's not often people have to search and sort 100000 items without using a database Really. My first love was computer graphics and there you have to solve such problems all the time without resorting to a slowpoky database. On top of that, the problem can quickly be three or four dimensional. How else would you like to do something like this[^] in real time. Just think about how to handle the different levels of detail when zooming in or out. And forget about fancy graphics processors. The whole octree stuff is about figuring out what to feed to the graphics processor in the first place. No more and no less.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I hear you, but graphics programming is kind of specialized and i wouldn't be doing near RT stuff in C# anyway.
I've tried playing a midi file without using MCI and just reading the MIDI data in C# and then sending the individual notes.
Even with the super hi res timer (native, better than stopwatch, and new with win7+ i think) it still skipped.
I'd never want to try anything like what you're talking about.
At most, I've written an NES emulator in C#. These days you could probably do SNES or certain MAME games. but that isn't about moving polys.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
So you still underestimate the power of the Dark Side.
Look what I made.[^]. All home made except the .Net framework itself, including the server components, the UI and the graphics engine.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
maybe i do, but that doesn't look like a lot of polygons, or hit testing. just sayin. C# is great for a lot of things, but GC systems just aren't real time enough.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
wonderful.
|
|
|
|
|
I think you are giving a fresh rounds of life-pulses to the Lounge. I've always loved to see casual technical discussions here.
It works like this in Lounge: All the great grand tech dinosaurs roam around here eating leaves (Discussing non-technical, trivial topics) pretending to be less muscular ones.
But the moment you tie a meaty goat(a worthy technical topic) and attract them into the treat, you could see all snarling up and showing fangs and morphing into huge godzillas and T-rex'. hehe
Then I would simply pick up my popcorn and watch all the muscle power show-offs. That's where a lot of learning really happens. At times I feel it's more educative than a well planned, scripted ARTICLE.
|
|
|
|
|
Thanks!
It's good to hear. Some of my discussions have gotten reported (not that they ended up being flagged) because they're "too technical for the lounge" so I'm glad to hear someone who appreciates my posts say so.
I spend a lot of my time thinking about how to solve problems of a technical nature, hence technical problems and solutions are a part of my life, ergo appropriate for the lounge, IMO.
I try to keep the actual articles to the articles, and this more casual, but the line is sometimes fuzzy.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Thanks! Please keep up the great work.
The unspoken truth about CP forums. We do have several forums for technical discussions. But the number people lurking around the lounge is far greater than in other forums.
So it's natural to see more replies/conversations here than in other forums.
While a serious technical question might break the rules of the lounge, A discussion on what we have done, some findings and looking for feedback for the same, I feel it's completely legit for the Lounge.
We should have a variety of discussions happening here. The mix is what makes it more lively.
Please keep sharing your technical findings. You could expect more dinos to come out from the cave and roar. Will be looking for it.
|
|
|
|
|
Interesting, I was under the impression that without recursion you can't really work with trees.
modified 20-Oct-19 21:02pm.
|
|
|
|
|
you just need a stack
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
A stack? A stack is the definition of recursion
No?
Edit: ok looked it up.
So you traverse one million items with nested loops. in the worst case csenario that's million times million loops.
modified 20-Oct-19 21:02pm.
|
|
|
|
|
well recursion uses a stack, but not the other way around
in fact, right now, i need to retool a function in my SortedSplayTreeDictionary to use a stack instead of full recursion to do what it's doing, because otherwise my dictionary can only hold between 5k and 10k items
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
As far as I know the only recursive limitation is the call stack, with a balanced tree (binary as a worst case scenario) the number of nodes is 2^depth of tree. 16K elements is 14 calls as far as I remember?
In C# you can do this:
var stackSize = 10000;
Thread thread = new Thread(new ThreadStart(BigRecursion), stackSize);
Thread Class (System.Threading) | Microsoft Docs
modified 20-Oct-19 21:02pm.
|
|
|
|
|
This is a splay tree. Worst case is different because it's doing tree rotations.
Yes, I could increase the stack size but that's not really the proper way to do this - that's like cleaning your carpet with a blowtorch - i mean sure, it gets rid of the filth, but...
but i am tempted. THis is the function i need to make non-recursive:
_Node _Splay(_Node root, TKey key)
{
int c;
if (null==root || 0==(c = _comparer.Compare(root.Key, key)))
return root;
if (0<c)
{
if (null==root.Left)
return root;
c = _comparer.Compare(root.Left.Key, key);
if (0<c)
{
root.Left.Left = _Splay(root.Left.Left, key);
root = _Ror(root);
}
else if (0>c)
{
root.Left.Right = _Splay(root.Left.Right, key);
if (null!=root.Left.Right)
root.Left = _Rol(root.Left);
}
return (null==root.Left) ? root : _Ror(root);
}
else
{
if (null==root.Right)
return root;
c = _comparer.Compare(root.Right.Key, key);
if (0<c)
{
root.Right.Left = _Splay(root.Right.Left, key);
if (null!=root.Right.Left)
root.Right = _Ror(root.Right);
}
else if (0>c)
{
root.Right.Right = _Splay(root.Right.Right, key);
root = _Rol(root);
}
return (null==root.Right ) ? root : _Rol(root);
}
}
=( =( =(
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
You will end up with nested while loops. It will be vastly less efficient:
Inorder Tree Traversal without Recursion - GeeksforGeeks
void inOrder(struct Node *root)
{
stack<Node *> s;
Node *curr = root;
<pre>
while (curr != NULL || s.empty() == false)
{
/* Reach the left most Node of the
curr Node /
while (curr != NULL)
{
/ place pointer to a tree node on
the stack before traversing
the node's left subtree */
s.push(curr);
curr = curr->left;
}
/* Current must be NULL at this point */
curr = s.top();
s.pop();
cout << curr->data << " ";
/* we have visited the node and its
left subtree. Now, it's right
subtree's turn */
curr = curr->right;
} /* end of while */
}
modified 20-Oct-19 21:02pm.
|
|
|
|
|
I'm not so sure that will work because I need to go right left right right left like that.
your solution looks like once it decided on the left path it would stay on the left path.
(Never mind the above, I read the code wrong. Whoops)
Unfortunately what I think i need is a state machine inside a single while loop, which is rough
While loops inside while loops aren't necessarily performance killers. It depends on how much the while loop is executed and in this case it doesn't matter because for every iteration it was making a function call anyway.
No matter what you do, the correct non-recursive implementation will be at least as, or more likely, more efficient than this version.
The reason is you're using less stack overall and doing the exact same number of pass throughs.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
modified 13-Sep-19 14:31pm.
|
|
|
|
|
|
Message Removed
modified 13-Sep-19 9:26am.
|
|
|
|
|
Pique - the French breath is yellow and black! (10)
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hufflepuff?
One of the school houses (I think)
Pique = huff The French = le Breath = puff
Guessing the house colours are yellow and black ...
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
Is the correct answer - you are up Monday.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|