|
it's not different. that's what i'm talking about. I didn't say it was a new idea. I've used a similar approach in C for other data structures but not binary trees.
I've built a little dictionary class on it so i can perf test against my other binary tree implementation.
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.
|
|
|
|
|
for static or constant trees, this is more efficient, but if the trees change (additions, deletions, change parents, etc) during their life time, the OP's method has an additional level of indirection so that it's more flexible and easier to manage ...
modified 2-Jan-20 15:57pm.
|
|
|
|
|
With a balanced tree, the 2*I, 2*i+1method is better. With a sparse or an unbalanced tree, having pointers is more efficient.
This idea simply replaces pointers with indexes in an array.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Long time ago, in my student days, I was engaged as a TA for the freshman "101 Programming" course, with a little above 1000 students. This was in the transition from Fortran to Pascal as the primary programming language. Ssome of the faculties at the Tech U was very conservative: Real Engineers program in Fortran! Pascal is for sisses!
So the course came in two varieties: Students of Chemistry and Construction Engineering learned Fortran, most others learned Pascal programming. The topics were the same, and three out of four homework assignments were identical. For the last one, the Pascal students were to create a linked list and define some operations on it. The Fortran student did something else, I don't remember what.
I was approached by this chemistry girl, good-looking and friendly, but she was a little crossed: She had heard that those Pascal students were learning something that she didn't learn in the Fortran course. Why not? Why couldn't they all learn it? Well... Fortran doensn't have pointers, so it isn't possible. But what are pointers? I gave her a very simple explanation - it is not a value, but it tells you where to find the value. Like this list, you have the three data fields in each record, and a fourth one that tells where the next record is.
I may have said something like "think of memory as large array, and that fourth value is the array index of the next record". I must have, because a week later, this young lady was back, telling that she had obtained a copy of the Pascal homework assignment. Now she had programmed it in Fortran, using array indexes as pointers. It appearently worked, but if I would take a look at it, she would be happy...
That lady certaily neither looked like nor behaved as the stereotype of a top rate engineer, but I have a gut feeling that she had the qualities required (not for "stereotype" but for "top rate" )! I never saw her after that 101 Programming course, so I can't tell for sure, but I am quite sure she has had a successful career.
I guess it is quite obvious why I came to think of this old memory when reading your post.
|
|
|
|
|
uptick for sweetness.
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.
|
|
|
|
|
I came to the office this morning and my project solution was still open with a few files loaded.
I forgot what I last did, so I hit ctrl-z to see the last changes I made to the files.
I'd rather be phishing!
|
|
|
|
|
I also like that approach, sometimes I will live a compilation error on the bit of code I am working on so it's even easier to find!
|
|
|
|
|
In VS, just add a comment:
It has a "To Do" list it populates from such comments automatically.
I use it to make "fill in the blanks" function and file headers included in my project templates.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
And that would be fine if my To Do list wasn't already full of "things to do later"
We are still in early stages of a new project, I (wishfully) expect them to be gone by release.
|
|
|
|
|
Except i use that to mark sections of my code that need improvement.
For me it wouldn't work because my todo list is already in use.
But that is a neat feature of VS. I *think* you can add your own though. So maybe I should look into that.
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.
|
|
|
|
|
"Tools ... Options ... Environment ... Task List"
Add a name, set the priority, and press "Add".
As many different ones as you need ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
aha, thanks
I figured it was buried in the options somewhere. I hadn't looked, but this saves me the trouble. =)
Now I could add // REMINDER
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.
|
|
|
|
|
I take it you pressed ctrl-y immediately afterwards to get the changes back?
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
yup
I'd rather be phishing!
|
|
|
|
|
I worked at home for a bit yesterday. It was a little shocking to see files dated as 1/1/2020. (looks too much like 2000 with slightly blurry vision)
"Go forth into the source" - Neal Morse
|
|
|
|
|
The most impressive thing in this post is that your system has apparently not spontaneously rebooted in...how many days?
You can't possibly be running Windows 10...
|
|
|
|
|
yup, uptime 14 days, 22 hours and change.
uptime (safe for work image).
I'd rather be phishing!
|
|
|
|
|
Interesting
Maximilien wrote: (safe for work image) with the text in the right column (Most Viral Images)
But I never wave bye bye
|
|
|
|
|
I usually leave with comments on the screen telling me what i did / need to do
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.
|
|
|
|
|
The best bit is where you Ctrl+V to see what the last thing you copied was.
Sometimes scary.
cheers
Chris Maunder
|
|
|
|
|
Yes, I tend to use ctrl+z a lot.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
|
Many moons is right!
The Z80 is still a thing?
Well MOV over Ryzen!
|
|
|
|
|
I believe you can still buy them, in the form of the Z180 - an enhanced version with MMU and suchlike and a 32MHz clock speed.
It's a surprisingly good little processor - I've written a heck of a lot of software for it (in Assembler and C) over the years.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
32Mhz!! Great Scott!
I would have killed for that kind of speed.
|
|
|
|