In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the meaning of the Java linked list, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Head plug:
1. If the data to be inserted does not have a node, first load it into a node Node node=new Node ()
Node.value=0
two。 Let the original first node become the next node node.next=head of the new node
3. Update the latest first node to the new node head=node
Tail insertion
1. If it is not in the node, install it in the node first
1.5 let the next=null of the new node
Node node=new Node (val); has been allowed in the constructor. Next=null.
two。 Find the penultimate node (sub-problem) find the node of .next = null
Node last=head
While (last.nextframes null) {last=last.next;}
Last is the last node.
3. Let the next node of the penultimate node be the new node
Last.next=node
Discuss the situation of tail insertion 1. The case of an empty linked list is to make the new node the first node.
two。 Non-empty (above)
Header deletion: directly point head to head.next and return head
Tail deletion: (case by case)
If head is empty, the empty linked list cannot be deleted
If head.next is empty, point head directly to null (only one)
At least two: 1. Find the penultimate node
LastSecond.next.next==null;// is the penultimate node.
two。 Let the next=null; of the penultimate node (the penultimate node becomes the penultimate node, so that the last node can be deleted)
3. It turns out that the last node is recycled because there is no reference point.
Reverse the linked list:
1. Constantly take the node from the original linked list and insert the head into a new linked list
two。 A new linked list is required and is empty
Reference to the first node of the new Node result=null;//result linked list
3. Traverse the original linked list
Node cur=head
While (curvilinear null) {
Cur=cur.next
}
4. Put each traversed node (cur). Insert the header into the new linked list (represented by result)
11. There are already nodes.
12.cur.next=result
13. Update the latest first node result=cur
Thank you for reading this article carefully. I hope the article "what is the meaning of Java linked list" shared by the editor will be helpful to everyone? at the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.