Replies: 5 comments 2 replies
-
|
I think the AI is not very accurate, if you read about what a doubly-linked list is and watch some videos about it, then it eventually it will make sense. For inserting, we have to find the node that we want the new one to go before/after. Then we attach the next or prev pointer of the existing node to the new node and vice-versa (which way depends on whether in-front or behind existing node). It depends on what you're trying to do, but you can compare to this which works: or the generic version: |
Beta Was this translation helpful? Give feedback.
-
|
For a circular doubly-linked list example, see below (note, the prints will go on forever since it's cyclic): |
Beta Was this translation helpful? Give feedback.
-
|
I fixed the code and it's running fine now: By running fine, I mean it can now print the expected results. I don't know whether there are other issues. As you can see, my code is ugly. I used a weird and not very elegant |
Beta Was this translation helpful? Give feedback.
-
|
This is my code for AVL Tree (w/ the help of AI): |
Beta Was this translation helpful? Give feedback.
-
|
Nice, Yes |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It’s been ages since I wrote Adept code, so yeah, definite brain rot here. The code was generated by AI for C, but I ported it to Adept. I’m sorry, but I’m too incompetent—even as a hobbyist coder—to write it myself.
Beta Was this translation helpful? Give feedback.
All reactions