|
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!
|
|
|
|
|
But the same theme:
Have always really rated your pick of two tea-eating ruffians - to start with, anyway! (5, 6)
Real CCC at usual time ...
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!
|
|
|
|
|
|
So close!: "Dotty ..."
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!
|
|
|
|
|
I really thought I was onto something...
|
|
|
|
|
Or was it "Hairy ..."? I'm getting all confused.
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!
|
|
|
|
|
Ah, that's the one character that I've actually heard of!
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
That's why I didn't use it as the "official CCC"
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!
|
|
|
|
|
Griff - you're a wizard at these things...
This space for rent.
|
|
|
|
|
Nemesea - Sayonara[^]
Deciding on this week's SOTW was hard!
I had a few contestants and the Dutch Nemesea was one of them.
I've been listening their latest album on repeat, which is pretty rare for an entire album!
So I went for Nemesea, but then I had to pick one song.
All songs on the album are good.
I even like the soft songs, like Lion.
I went for Sayonara because it's rather catchy, but I can recommend looking up the entire album on Spotify.
Nemesea started out as gothic metal which fitted perfectly in the Dutch tradition of After Forever, Within Temptation and Epica.
They've strayed from the metal path and have adopted a more poppy melodic rock sound.
The new singer on this album, Sanne Mieloo, also plays in musicals.
Enjoy
|
|
|
|
|
Nemesea sounds great …
but I had only 37 seconds time to listen because someone
opened Pandora's box at my work to please me I suppose,
so I bookmark Nemesea for the weekend …
and my other bookmarks are
- new AILD with TL …
- new Agonist (had no chance to check them yet …)
Cheers,
|
|
|
|
|
I don't really know As I Lay Dying, only by name.
New stuff sounds good though.
|
|
|
|
|
"Your basic 'Prime Instant' service includes a 99% discount on everything Amazon sells ! And:
1 a monthly delivery by courier of twenty foil-packed sets of red and blue gel capsules.
2 a special set of bluetooth-enabled glasses (batteries not included).
Purchase and Check-out:
Select the items you want, go to check-out, approve the order:
1 Put on the glasses, wait until the check-out screen verifies the blue-tooth connection is enabled, and your credit card approves the purchase.
2 When the red background screen is flashing, take one red capsule. Keep your eyes on the screen for thirty seconds until the red screen stops flashing.
3 When the blue screen starts flashing, take one blue capsule. Keep your eyes on the screen for thirty seconds until the blue screen stops flashing.
When the order is complete you may feel a moment of dizziness: do not worry, this is normal.
Now, enjoy the memories of your new, instantly delivered, items being virtually present, and your happy times using them, forever !
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Take a red pill.
There's just one fly in your ointment. Given that Kindle books sell for anything up to 100% of the price of the dead tree edition (you only save on the shipping), why should Amazon give 99% discounts on other virtual items?
Now take the blue pill.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Got a new job. And also a serious case of déjà vu.
- Hey, I've cloned a repo and managed to compile the project. Just wondering... where are tests?
- Well, look for it...
(...)
- So, the client didn't want to pay us for tests.
- And for last three months you've been doing nothing but bug-fixing?
- Pretty much. Look, we all know what you mean, but in the end of the day it's up to the financial department. They pay me for my time. If I'm wasting it on doing shish because of their bad decisions, it's not my problem.
I just... gave up. It's all the same everywhere.
|
|
|
|
|
Yeah, pretty much.
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.
|
|
|
|
|
well of course the finance people will have to report the cost of bugfixing,
but they will also report on the amount saved not testing the not-broken bits
... and seeing as that figure is not actually measured (coz even measuring would take time/expense) they get to make up their own figure estimate expert opinion *
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eleifend, eros sit amet tempus aliquam, metus enim lobortis velit, vel rutrum eros sapien vel nisl. Mauris id enim at massa elementum iaculis sit amet eu enim. Proin non lacus ullamcorper, pellentesque orci id, varius purus. Integer accumsan feugiat risus, vel efficitur tortor bibendum et. Mauris molestie dui nec tempor ornare. Phasellus viverra diam ligula, * with a tiny little disclaimer buried somewhere else+... quis egestas risus cursus sed. Etiam pulvinar, lorem at aliquet luctus, lorem quam facilisis urna, quis aliquet lacus diam eu sem. Mauris tincidunt magna ut elementum interdum. Donec imperdiet luctus congue. Ut hendrerit elit vel lorem suscipit, vel volutpat erat consequat. Nam fringilla consectetur mi non consectetur. Duis dictum, mi non rhoncus hendrerit, ligula ipsum maximus nisi, nec lobortis + signed by the CEO who inasmuch assumes all responsibility diam mi pharetra ante. Nunc convallis faucibus bibendum. Morbi consectetur quam eget lectus mattis ultricies.
|
|
|
|
|
I've worked with some fantastic exceptions (I have found that working for software houses the processes are far more strict). One of these was a small software house, but their processes were exceptional. I've also worked for a large national corporation (one of the biggest IT outsourcers in the UK) and found that their processes were practically non existent.
It comes down to culture, and how much that culture fosters quality.
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
These are testing times
|
|
|
|