News for hackers. Stuff that matters.
Re:They don't even know the fundamentals by gameswithgo on Monday November 01, 2021 @09:13AM (#29066257)
People who make this comment, I generally don't believe you, or don't believe you have done any programming. If I put a gun to your head and give you an hour, you can't make a node that points to two other nodes of the same type?

If you really can't, you should get familiar with how data can point to other data, it is fundamental and done all the time.

Re:They don't even know the fundamentals by what_is_orcas on Monday November 01, 2021 @11:33AM (#29068086)
> If I put a gun to your head and give you an hour, you can't make a node that points to two other nodes of the same type?

It's easy to make an imbalanced binary tree.

I once decided that building a binary tree based only on a friend's explanation of how they worked; it seemed like it would be a good learning exercise for myself (I don't have a CS degree). It was like 10 minutes of coding to get it minimally working & tested, but then I had to work out all of the different rotations to make it a balanced binary tree (I don't know that an imbalanced binary tree is ever actually useful, as it could just work out to be a slower linked-list in the worst case scenario).

I did it once, took me a little while, but I don't know that I could do it again without having to reexamine all of the different cases that result in imbalance and the rotations that respond to each.

Re:They don't even know the fundamentals by humen99 on Monday November 01, 2021 @05:46PM (#29073592)
Binary search tree is more difficult than a binary tree. A BST is a BT but a BT is not a BST. So making a normal BT is just pointing nodes.
Re:They don't even know the fundamentals by what_is_orcas on Wednesday November 03, 2021 @09:23AM (#29094221)
Huh... TIL, as they say.
Re:They don't even know the fundamentals by jb1991 on Monday November 01, 2021 @09:15AM (#29066269)
There’s more than making a node the points to other nodes. That’s not what makes a binary tree a binary tree.
Re:They don't even know the fundamentals by nostrebored on Monday November 01, 2021 @11:33AM (#29068073)
I mean… it literally is all there is to it
Re:They don't even know the fundamentals by jb1991 on Monday November 01, 2021 @02:18PM (#29070693)
Well, the requirements I faced were to implement the tree such that nodes were inserted with the standard ordering you would expect. Walking the tree to find the best place to insert them, etc.
Re:They don't even know the fundamentals by maximus-decimus on Tuesday November 02, 2021 @07:55PM (#29089219)
Again, that's stupidly easy. Right is bigger, left is smaller.

If the current node is a leaf, insert left if smaller and right if bigger.

If not a leaf nods, run the method recursively on the left it it's smaller, on the right if it's bigger.

If they asked you to write a self-balancing binary tree it's one thing, but there's nothing tricky about writing a normal ordered binary tree.

Re:They don't even know the fundamentals by derivagral on Monday November 01, 2021 @10:03AM (#29066714)
It isnt the knowledge itself, it is making sure it works and is tested, etc, all in <45m. It serves as a worse fizzbuzz imo.
Re:They don't even know the fundamentals by kayodelycaon on Monday November 01, 2021 @09:36AM (#29066485)
Do you want me to show you a single-linked list or a double-linked one?

    [data, *next] [data, *next] [data, *next] [data, *next] 
If next is null (0), it's the end of the list.