The article directories

  • Java Data Structures — Single linked Surfaces
  • Remove list elements
    • 1
    • 2. Idea realization
    • 3. Code implementation
  • Reverse linked lists
    • 1
    • 2. Idea realization
    • 3. Code implementation
  • Find the middle node of the list
    • 1
    • 2. Idea realization
    • 3. Code implementation
  • To be continued….

\

Java Data Structures — Single linked Surfaces

\

This content introduces the outline

\

\

Move on to Java — singly linked lists of data structures

\

In the last article, we introduced the implementation of various methods of single linked lists. This time, we will use simple single linked surface questions (mainly linked list questions from Niuke and Leetcode) to understand the knowledge structure of single linked lists.

\

Remove list elements

\

1

\

\

2. Idea realization

\

In our last blog, we had a method to delete the first node with the key keyword. This time we will delete all the nodes with the key keyword.

\

In each of the following lists, we remove the node with keyword 45.

\

A situation

Case 2

Scenario 3

Scenario 4



\

Summary of ideas:

\

3. Code implementation

\



\

Reverse linked lists

\

1

\



\

2. Idea realization

\

\

Achieve the above linked list structure.

\

Idea 1: sequential head insertion method

Idea 2: Use prev, curNext, cur and other variables to transform next



\

3. Code implementation

\

Idea 1 code:

\

\

Idea 2 code:

\

\

Find the middle node of the list

\

1



For example, take the following linked list:

\

2. Idea realization

\

Idea 1:

\

Idea 2:

\

When the length of the list is odd

\



\

When the list length is even

\



\

Also meet the requirements of the topic, so idea 2 is completely correct!!

\

3. Code implementation

\


\

Well, today’s knowledge is shared here, I hope you can practice more, thank you for your appreciation and attention!


\

Thanks for your support!!


\

After the single chain surface test blogger will continue to update, welcome readers to pay great attention to oh!!


\

To be continued…