Data structure (V) chain

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/real_ilin/article/details/102768556
  • Truly dynamic data structures
  • The most simple dynamic data structures
  • In depth understanding of reference
  • In depth understanding of recursive

Here Insert Picture Description

LinkedList achieve

Internal class Node, and for storing data next;

LinkedList Node has a variable type of pointing head.

  • Add elements in the head List
  • Adding an element in the middle List
  • To delete an element in the specified location List
  • Modify the elements in the specified location List
  • Find specify the location of the element

Note: List here are achieved using a dummy head node dummyHead, dummyHead element value is null, next point to an index of 0 node.

Time complexity analysis

This is the analysis of the list is a single list:

  • increase: O ( n ) O (n) , the head node list element increases time complexity is O ( 1 ) O (1) ;
  • delete: O ( n ) O (n) , the time complexity is deleted element in node list head O ( 1 ) O (1) ;
  • change: O ( n ) O (n)
  • check: O ( n ) O (n)

Achieve stack as a linked list

Having a linked list queue tail pointer

Here Insert Picture Description

Remove elements of the list:

To delete a node first find a node before the node is deleted. If the head node requires separate treatment, because there is no previous node of the head node. Another idea is to add a dummy head node, unified operation.

Guess you like

Origin blog.csdn.net/real_ilin/article/details/102768556