- 2

Can you teach me how to solve this problem? It is about nodes and link list.

Objective: To create a singly-linked list of integers, delete a given integer from the above-link list. Display the contents of the above list after deletion. Program Logic: Create a node using a structure dynamically allocate memory to node. Create and add nodes to a linked list.

10th Oct 2021, 3:33 AM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
13 odpowiedzi
+ 1
Then how to code that using programming language? Sorry I don't know what to do , I'm just a beginner
10th Oct 2021, 6:26 AM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
+ 1
Thank you
10th Oct 2021, 8:03 AM
Mirasol Sontousidad
Mirasol Sontousidad - avatar
+ 1
Good luck! 👍
10th Oct 2021, 8:04 AM
Ipang
+ 1
Martin, Unfortunately it was the first one I found in Code Playground which seems to be related to the OP's question (delete a node from linked list). Though there are many codes about linked list, that was the one covering how to "delete" a node. I'm not gonna comment on the LinkedList class though, having seen how many colleges' students still being asked to try and make a self implementation like that, in the name of "educational purposes" of course. P.S. I also found various examples of linked list implementation, written in multiple languages, in SoloLearn's Learn section.
10th Oct 2021, 3:45 PM
Ipang
+ 1
Martin Taylor The same question as usual..(java speed) You have to answer it every day. ROFL😅. Who defamed Java? Old fanatic C/C++ programmers. 😅
11th Oct 2021, 11:54 PM
Mehran
Mehran - avatar
0
Suppose you have 5 nodes Node1 value: 10 next: Node2 Node2 value: 20 next: Node3 Node3 value: 30 next: Node4 Node4 value: 40 next: Node5 Node5 value: 50 next: null If you want to delete Node3 for example, you change Node2.next to point to Node4 (previously Node2.next points to Node3). As Java uses Garbage Collector, you don't need to worry about deallocation of the removed Node object, it's automatic.
10th Oct 2021, 5:09 AM
Ipang
0
You need to understand how that structure works before you go with implementation. https://www.sololearn.com/learn/634/?ref=app As for code examples and/or inspirations, Code Playground is the place to go. We can search for examples and inspirations there using its search feature. I found this one just now ... https://code.sololearn.com/c2WQ2h2643bc/?ref=app
10th Oct 2021, 7:42 AM
Ipang
0
I saw your message, but I can only read, not reply, it's a bug maybe. Try to post a comment in that code I passed to ask the author about how it works, it's not mine. You can post another question with link to that code too, to ask the entire community.
10th Oct 2021, 8:28 AM
Ipang
0
Martin, I don't have any idea either, but looking at some of those students came here with such queries (and the number doesn't decrease), I guess it's still ongoing. I don't know if I could say modern software is so bad though I agree ...
10th Oct 2021, 5:28 PM
Ipang