MindMap Gallery data structure linear table
Data Structure Chapter 2 Linear Table Mind Map: 1. The definition and basic operations of a linear table. A linear table is a finite sequence of n data elements with the same data type. , 2. Sequential representation of linear lists (sequential lists), 3. Chained representation of linear lists, etc.
Edited at 2022-03-31 18:41:13This article discusses the Easter eggs and homages in Zootopia 2 that you may have discovered. The main content includes: character and archetype Easter eggs, cinematic universe crossover Easter eggs, animal ecology and behavior references, symbol and metaphor Easter eggs, social satire and brand allusions, and emotional storylines and sequel foreshadowing.
[Zootopia Character Relationship Chart] The idealistic rabbit police officer Judy and the cynical fox conman Nick form a charmingly contrasting duo, rising from street hustlers to become Zootopia police officers!
This is a mind map about Deep Analysis of Character Relationships in Zootopia 2, Main content: 1、 Multi-layer network of relationships: interweaving of main lines, branch lines, and hidden interactions, 2、 Motivation for Character Behavior: Active Promoter and Hidden Intendant, 3、 Key points of interaction: logic of conflict, collaboration, and covert support, 4、 Fun Easter eggs: metaphorical details hidden in interactions.
This article discusses the Easter eggs and homages in Zootopia 2 that you may have discovered. The main content includes: character and archetype Easter eggs, cinematic universe crossover Easter eggs, animal ecology and behavior references, symbol and metaphor Easter eggs, social satire and brand allusions, and emotional storylines and sequel foreshadowing.
[Zootopia Character Relationship Chart] The idealistic rabbit police officer Judy and the cynical fox conman Nick form a charmingly contrasting duo, rising from street hustlers to become Zootopia police officers!
This is a mind map about Deep Analysis of Character Relationships in Zootopia 2, Main content: 1、 Multi-layer network of relationships: interweaving of main lines, branch lines, and hidden interactions, 2、 Motivation for Character Behavior: Active Promoter and Hidden Intendant, 3、 Key points of interaction: logic of conflict, collaboration, and covert support, 4、 Fun Easter eggs: metaphorical details hidden in interactions.
Chapter 2 Linear Table
1. Definition and basic operations of linear tables
Definition of linear table
A linear table is a finite sequence of n data elements of the same data type.
Concept: header element, tail element, direct predecessor, direct successor.
Basic operations of linear tables
Establishing InitList(&L) is to initialize and destroy DestroyList(&L) Add ListInsert(&L,i,e) to insert DeleteListDelete(&L,i,e) CheckLocateElem(L,e),GetElem(L,e) Length(L) table length, PrintList(L) output, Empty (empty judgment)
2. Sequential representation of linear tables (sequential tables)
Definition of sequence table
Implement linear tables using sequential storage; Sequential storage: Store logically adjacent elements in storage units that are also physically adjacent. The relationship is reflected by the adjacency relationship of storage units.
Implementation of sequence table
static allocation
//Static allocation defines the sequence table. The storage space is static and the size is fixed from the beginning. #define MaxSize 10//Define the maximum length typedef struct{ ElemType data[MaxSize]; //Use static "array" to store data elements int length; //Current length of sequence table }SqList; //Type definition of sequence list (static allocation method) ElemType refers to the data type defined by yourself, such as int, double //Initialization sequence table #include<stdio.h> #define MaxSize10 typedef struct{ int data[MaxSize]; int length; }SqList; void InitList(SqList &L){ for(int i=0;i<MaxSize;i) L.data[i]=0; //Set all data elements to default initial values L.length=0; //Set the initial length of the sequence table to 0 } int main(){ SqList L; //Declare a sequence list InitList(L): //Initialization sequence list ... return 0; } //Dynamic allocation implementation sequence table, the size can be changed #include<stiod.h> #define InitSize 10 //Default maximum length typedef struct{ int *data; //Pointer indicating dynamically allocated array int MaxSize; //Maximum capacity of sequence table int length; //Current length of sequence table }SeqList; //Definition of sequence list int main(){ SeqList L; //Declare a sequence list InitList(L): //Insert several elements randomly into the network sequence table IncreaseSize(L,5); return 0; } void InitList(SeqList &L){ //Use the malloc function to apply for a continuous storage space L.data(int *)malloc(InitSize*sizeof(int)); L.length=0; L.MaxSize=InitSize; } //Increase the length of dynamic array void IncreaseSize(SeqList &L,int len){ int *p=L.data; L.data(int *)malloc((L.MaxSize len)*sizeof(int)): for(int i=0;i<L.length;i ){ L.data[i]=p[i]; //Copy data to new area } L.MaxSize=L.MaxSize len; //The maximum length of the sequence table increases by len free(p); //Release the original memory space }
dynamic allocation
L.data=(ElemType *)malloc(sizeof ElemType *InitSize) The malloc function returns a pointer, which needs to be cast to a pointer to the data element type you defined.
Characteristics of sequence tables: ① Random access ②High storage density ③It is inconvenient to expand the capacity ④ Insertion and deletion operations are inconvenient and require moving a large number of elements
Insertion and deletion of sequence table
Insertion into sequence table
ListInsert(&L,I,e), inserts the specified element e at the i-th position
//Sequential table element insertion #define MaxSize 10 typedef struct{ ElemType data[MaxSize]; int length; }SqList; void ListInsert(SqList &L,int I,int e){ for(int j=L.length;j>I;j--){ //Move the i-th element and subsequent elements backward L.data[j]=L.data[j-1]; } L.data[i-1]=e; //Put e at the i-th position L.length; //Length 1 } int main(){ SqList L; InitList(L): //Omitted here, you can insert a series of elements ListInsert(L,3,3); return 0; } //In order to avoid inserting elements without feedback, for example, if the memory is full, the Insert function must be modified to have a return value. bool ListInsert(SqList &L,int I,int e){ if(i<1 || i>L.length 1) return false; if(L.length>=MaxSize) return false; for(int j=L.length;j>i;j--) L.data[j]=L.data[j-1]; L.data[i-1]=e; L.length; return false; }
Time complexity of insertion: best O(1), worst O(n), average O(n)
Deletion of sequence table
ListDelete(SqList &L,int i,int &e), deletes the element at position i in table L and returns the value of the element
//Delete sequence table bool ListDelete(SqList &L,int i,int &e){ if(i<1 || i>L.length 1) //Determine whether the range of i is valid return false; e=L.data[i-1]; for(int j=1;j<L.length;j) L.data[j-1]=L.data[j]; L.length--; return true; } int main(){ SqList L; InitList(L); int e=-1; if(ListDelete(L,3,e)) printf("Delete the 3rd element, the deleted element value is =%d/n",e); else pprintf("The bit order i is illegal, deletion failed "); return 0; }
Time complexity of deletion: O(1) at best, O(n) at worst, O(n) on average
Sequence table search
Bitwise search
GetElem(L,i), gets the value of the element at the i-th position in table L
//Search by bit //Static allocation #define MaxSize typedef struct{ ElemType data[MaxSize]; //Use static "array" to store data elements int length; //Current length of sequence table }SqList; //Type definition of sequence list (static allocation method) ElemType GetElem(SqList L,int i){ return L.data[i-1]; //Call the GetElem() function to return the value of the i-th element } //Dynamic allocation #defineInitSize typedef struct{ ElemType *data; int MaxSize; int length; }SeqList; ElemType GetElem(SeqList L,int i){ return L.data[i-1]; }
Find by value
LocateElem(L,e), finds the element with the given keyword value in table L
//Search by value #defineInitSize 10 typedef struct{ ElemType *data; int MaxSize; int length; }SeqList; //Find the element whose first element value is equal to e in the sequence list L and return its bit order int LocateElem(SeqList L,ElemType e){ for(int i=0;i<L.length,i) if(int i=0;o<L.length;i) return i 1; //The value of the element marked i in the array is equal to e, and its bit order is returned i 1 return 0; //Exit the loop, indicating that the search failed }
Time complexity: best O(1), worst O(n), average O(n)
Structure type comparison
3. Chain representation of linear table
Single list
Definition of singly linked list
In addition to storing data elements, each node also stores a pointer to the next node.
Single linked list code representation
struct LNode{ ElemType data; //Define single linked list node type struct LNode *next;//Each node stores a data element } struct LNode *p=(struct LNode *)malloc(sizeof(struct LNode)); //Every time a new node is added, apply for a node space in the memory and use the pointer p to point to this node You can also use typedef struct LNode LNode; instead of LNode *p=(LNode *)maloc(sizeof(LNode)); In this case, you don’t need struct LNode to add nodes.
//Textbook, define a singly linked list typedef struct LNode{} //Define single linked list node type ElemType data; //data field struct LNode *next; //Pointer field LNode,*LinkList; //LNode is renamed, *LinkList is the pointer to this node Use LNode * to emphasize that this is a node Use LinkList to emphasize that this is a singly linked list
Two implementations
Leading node
//Singly linked list with head node typedef struct LNode{ ElemType data; strut LNode *next; }LNode,*LinkLst; //Initialize an empty singly linked list bool InitList(LinkList &L){ L=NULL; //Empty table, place dirty data return true; } void test(){ LinkList L; //Declare a pointer to a singly linked list //Initialize an empty table InitList(L); //....Subsequent code } //Determine whether the singly linked list is empty bool Empty(LinkList L){ return (L=NULL); }
No leading node
//Singly linked list without head node typedef struct LNode{ ElemType data; struct LNode *next; }LNode,*LinkList; //Initialize a singly linked list with header nodes bool InitList(LinkList &L){ L=(LNode *)malloc(sizeof(LNode));//Allocate a head node if(L==NULL) return false; L->next=NULL; return true; } void test(){ LinkList L; //Declare a pointer to a singly linked list //Initialize an empty table InitList(L); //...Following code } //Determine whether the singly linked list is empty (with header) bool Empty(LinkList L){ if(L->next==NULL) return true; else return false; }
Insertion and deletion of singly linked list
insert
Insert in bit order
//Insert element e (head node) at the i-th position in bit order ListInsert(&L,int i,ElemType e){ if(i<1) return false; LNode *p; //Pointer p points to the currently scanned node int j=0; //Which node is the current p pointing to? p=L; //L points to the head node, which is the 0th node (no data stored) while(p!=NULL&&j<i-1){ //Loop to find the i-1th node p=p->next; j; } if(p=NULL) //The value of i is illegal return false; LNode *s =(LNode *)malloc(sizeof(LNode));//Apply for a new node space to store new elements s->data=e; //The data field of the new node stores the new element content s->next=p->next; //The next pointer of the new node points to the next pointer pointed to by the i-1 node, which is called the i-th element p->next=s; //The previous node next of the new node points to the new node return true; } typedef struct LNode{ ElemType data; struct LNode *next; }LNode,*LinkList;
////Insert element e at the i-th position in bit order (without the head node) bool ListInsert(LinkList &L,int i,ElemType e){ if(i<1) return false; if(i==1){ //The operation of inserting at the first node is different from the operation of other nodes LNode *s=(LNode *)malloc(sizeof(LNode)); s->data=e; s->next=L; L=s; //The head pointer points to the new node return true; } LNode *p; int j=1; p=L; while(p!=NULL && j<i-1){ p=p->next; j; } if(p==NULL) return false; s->data=e; s->next=p->next; p->next=s; return true; //Insertion successful } typedef struct LNode{ ElemType data; struct LNode *next; }LNode,*LinkList;
Post-insert operation of specified node
//Post-insert operation, insert element e after node p bool InsertNextNode(LNode *p,ElemType e){ if(p==NULL) LNode *s=(LNode *)malloc(sizeof(LNode)); if(s==NULL) //Insufficient memory allocation return false; s->data=e; //Use node s to save data element e s->next=p->next; p->next=s; //Connect node s to after p return true; } typedef struct LNode{ ElemType data; struct LNode *next; }LNode,*LinkList;
Forward insertion operation of specified node
InsertPriorNode(LinkList L,LNode *p,ElemType e), given the head node, then traverse the entire table to find the previous node of p. For convenience, directly copy this node and change the content of this node, which makes the time complicated. The degree is O(n)
//Forward insert operation, insert node s before node p bool InsertPriorNode(LNode *p,LNode *s){ if(p==NULL || s==NULL) return false; s->next=p->next; p->next=s; ElemType temp=p->data; p->data=s->data; s->data=temp; return true; }
delete
Delete in bit order
ListDelete(&L,i,&e): Delete operation. Delete the element at position i in table L and use e to return the value of the deleted element.
//Singly linked list is deleted in bit order bool ListDelete(LinkList &L,int I,ElemType &s){ if(i<1) return false; LNode *p; //Pointer p points to the currently scanned node int j=0; //j indicates which node p currently points to p=L; //L points to the head node, which is the 0th node (no data stored) while(p!=NULL&&j<j-1){ //Loop to find the i-1th node p=p->next; j; } if(p==NULL) //i value is illegal return false; if(p->next==NULL) //There are no other nodes after the i-1th node return false; LNode *q=p->next; //Let q point to the deleted node e=q->data; //Use e to return the value of the element p->next=q->next; //"Disconnect" the *q node from the chain free(q); //Release the storage space of the node return true; //Delete successfully } typedef struct LNode{ ElemType data; struct LNode *next; }LNode,*LinkList;
Deletion of specified node
DeleteNode(LNode *p), delete pointer p
//Delete the specified node p from the singly linked list bool DeleteNode (LNode *p){ if(p==NULL) return false; LNode *q=p->next; //Let q point to the successor node of *p p->data=p->next->data; //Exchange data fields with subsequent nodes p->next=q->next; //"Disconnect" the *q node from the chain free(q); //Release the storage space of subsequent nodes return true; }
Search in singly linked list
Bitwise search
//Singly linked list bitwise search LNode *GetElem(LinkList L,int i){ if(i<0) return NULL; LNode *p; int j=0; p=L; while(p!=NULL&&j<1){ p=p->next; j; } return p; }
Find by value
LocateElem(LinkList L,ElemType e), finds the location of the node with data field e
//Search by value in a singly linked list and find the node whose data field returns ==e LNode *LocateElem(LinkList L,ElemType e){ LNode *p = L->next; //Start from the first node to find the node with data field e while(p != NULL&&p->data!=e) p=p->next; return p; //Return the node pointer after finding it, otherwise return NULL }
Find the length of the table
//Find table length int length(LinkList L){ int len=0; LNode *p=L; while(p->next != NULL){ p=p->next; len ; } return len; }
Creation of singly linked list
step1: Initialize a singly linked list step2: Remove one data element at a time and insert it into the head/foot of the table
tail insertion method
Initialize a singly linked list, set the variable length to record the length of the linked list, set the end pointer of the list, and insert one data element at a time into the end of the list.
//Tail insertion method to create a singly linked list LinkList List_TailInsert(LinkList &L){ //Forwardly create a singly linked list int x; //Set ElemType to integer L=(LinkList)malloc(sizeof(LNode)); //Create the head node LNode *s,*r=L; //r is the end pointer of the table scanf(“%d”,&x); //Input the value of the node while(x!9999){ //Enter 9999 to indicate the end s=(LNode *)malloc(sizeof(LNode)); s->data=x; r->next=s; r=s; //r points to the new table end pointer scanf(“%d”,&x); } r->next=NULL; //Set the tail node pointer to null return L; }
Head insertion method
//Head insertion method creates a singly linked list LinkList List_HeadInsert(LinkList &L){ //Reversely create a singly linked list LNode *s; int x; L=(LinkList)malloc(sizeof(LNode)); //Create the head node L->next=NULL; //Initially empty linked list scanf(“%d”,&x); //Input the value of the node while(x!=9999){ //Enter 9999 to indicate the end s=(LNode*)malloc(sizeof(LNode)); //Create a new node s->data=x; s->next=L->next; L->next=s; //Insert the new node into the table, L is the head pointer scanf(“%d”,&x); } return L; }
Double linked list
Initialization of doubly linked list
Singly linked list: A singly linked list cannot be retrieved in reverse, which is sometimes inconvenient. Double linked list: can advance and retreat, lower storage density
//Initialization of double linked list (lead node) bool InitDLinkList(DLinklist &L){ L=(DNode *)malloc(sizeof(DNode)); if(L==NULL) return flase; L->prior=NULL; L->next=NULL; return true; } void testDLinkList(){ //Initialize double linked list DLinklist L; InitDLinkList(L); //...Following code } typedef struct DNode{ ElemType data; struct DNode *prior,*next; }DNode,*DLinklist; //Determine whether the double linked list is empty (lead node) bool Empty(DLinklist L){ if(L->next==NULL) return true; else return false; }
Insertion into double linked list
//Insertion into double linked list bool InsertNextDNode(DNode *p,DNode *s){ s->next=p->next; //Insert node *s after node *p p->next->prior=s; s->prior=p; p->next=s; }
Deletion of doubly linked list
//Delete double linked list bool DeleteNextDNode(DNode *p){ if(p==NULL) return flase; DNode *q=p->next; //Find the successor node q of p if(q==NULL) return false; //p has no successor node p->next=q->next; if(q->next!=NULL) //The q node is not the last node q->next->prior=p; free(q); //Release node space return true; } void DestoryList(DLinklist &L){ //Loop to release each data node while(L->next!=NULL) DeleteNextDNode(L); free(L); //Release the head node L=NULL; //Head pointer points to NULL }
Traversal of doubly linked list
//Traversal of double linked list while(p!=NULL){ //Backward traversal //Do corresponding processing for node p p=p->next; } while(p!=NULL){ //Forward traversal p=p->prioe; } while(p->prioe!=NULL){ //Forward traversal, skip the head node p=p->prior; }
circular linked list
Circular singly linked list
Singly linked list: Starting from one node, only subsequent nodes can be found, but the previous nodes are unknown. Circular singly linked list: Starting from one node, you can find any other node.
//Define circular singly linked list typedef struct LNode{ //Define single linked list node type ElemType data; //Each node stores a data element struct LNode *next; //data points to the next node }LNode,*LinkList; //Initialize a circular singly linked list bool InitList(LinkList &L){ L=(LNode *)malloc(sizeof(LNode)); //Allocate a head node if(L==NULL) //Insufficient memory, allocation failed return false; L->next = L; //The head node Next points to the head node return true; } //Determine whether the circular singly linked list is empty bool Empty(LinkList L){ if(L->next==L) return true; else return flase; } //Determine whether node p is the end node of a circular singly linked list bool isTail(LinkList L,LNode *p){ if(p->next==L) return true; else return false; }
Circular doubly linked list
//Initialize empty circular double linked list bool InitDLinkList(DLinklist &L){ L=(DNode *)malloc(sizeof(DNode)); //Allocate a head node if(L==NULL) //Insufficient memory, allocation failed return false; L->prior=L; //The priority of the head node points to the head node L->next=L; //next of the head node points to the head node return true; } void testDLinkList(){ //Initialize circular double linked list DLinklist L; InitDLinkList(L); //...Following code } //Determine whether the circular double linked list is empty bool Empty(DLinklist){ if(L->next==L) return true; else return false; } //Determine whether node p is the end node of the circular doubly linked list bool isTail(DLinklist L,DNode *p){ if(p->next==L) return true; else return false; } typedef struct DNode{ ElemType data; struct DNode *prior,*next; }DNode,*DLinklist;
static linked list
definition
Singly linked list: Each node is randomly allocated in memory. Static linked list: Allocate a whole piece of continuous memory space, and each node is placed centrally.
code representation
//Define static linked list #define MaxSize 10 typedef sreuct{} ElemType data; int next; } void testSLinkList(){ struct Node a[MaxSize]; //...Following code } //You can also create a static linked list with the following code #define MaxSize 10 //Maximum length of static linked list typedef struct{ //Definition of static linked list structure type ElemType data; //Storage data elements int next; //array subscript of the next element } SLinkList[MaxSize]; void testSLinkLst(){} SLinkList a; //...Following code }
Implementation of basic operations
Implementation of sequence lists and linked lists
logical structure
They are all linear tables and linear structures.
Physical structure/storage results
Advantages of sequence tables: support random access and high storage density. Disadvantages: It is inconvenient to allocate large areas of continuous space, and it is inconvenient to change the capacity. Advantages of linked lists: Discrete small spaces are easy to allocate and the capacity is easy to change. Disadvantages: No random access, low storage density.
Data operations/basic operations
Sequence table creation: A large contiguous space needs to be pre-allocated. If the allocated space is too small, it will be inconvenient to expand the capacity later; if the allocated space is too large, memory resources will be wasted. Static allocation: static array, immutable capacity Dynamic allocation: dynamic array (malloc, free), the capacity can be changed, but it requires moving a large number of elements, which is time-consuming. Destruction: Modify length=0, statically allocated space will be automatically reclaimed, dynamically allocated malloc application needs to be manually freed Inserting/deleting elements requires moving subsequent elements back/forward. The time complexity is O(n), and the time overhead mainly comes from moving elements. If the moving element is large, the moving time cost is high. Search: Bitwise search: O(1). Search by value: O(n). If the elements in the table are ordered, they can be found in O(log2n) time.
Linked list creation: You only need to allocate a head node (you can also omit the head node and only declare a head pointer), which can be easily expanded later. Destroy: Delete each node in turn (free) Inserting/deleting elements only requires modifying the pointer. The time complexity is O(n), and the time overhead mainly comes from finding the target element. The time cost of finding elements is lower. Search: Bitwise search: O(n). Find by value: O(n).
Use a sequential list or a linked list: The length of the list is difficult to estimate, and elements often need to be added, subtracted/deleted, so use a linked list. The table length can be estimated and there are many query (search) operations, so use a sequential table. Question: Please describe the sequence list and the linked list...Which is better to use the sequence list or the linked list? The logical structures of sequence lists and linked lists are linear results and both belong to linear lists. However, the storage structures of the two are different. The sequence table uses sequential storage... (features, advantages and disadvantages); the linked list uses chain storage... (advantages and disadvantages). Due to the use of different storage methods, the implementation efficiency of basic operations is also different. When initializing...when inserting a data element...when deleting a data element...when searching for a data element...
Appendix
Sequence table
storage structure
Data elements that are logically adjacent are also physically adjacent
Method to realize
static allocation
Implemented using "static array"
Once the size is determined, it cannot be changed
dynamic allocation
Implemented using "dynamic array"
L.data=(ElemType *)malloc (sizeof(El;emType)* size)
When the sequence table is full, malloc can be used to dynamically expand the maximum throughput of the sequence table.
Pay attention to malloc and free functions
It is necessary to copy the data elements to a new storage area and use the free function to release the original area.
Features
random access
Can find the i-th element in O(1) time
High storage density
Expanding capacity is inconvenient
Inserting and deleting data elements is inconvenient
linear table
logical structure
Basic calculations/operations
Storage/Physical Structure
Sequence table (sequential storage)
Definition (how to implement it in code)
Implementation of basic operations
Linked list (linked storage)
Single list
Definition (how to implement it in code)
Implementation of basic operations
Double linked list
circular linked list
static linked list
Insertion and deletion of sequence table
insert
ListInsert(&L,i,e)
Insert element e into the i-th position of L
Elements after the insertion position must be moved back, and the length of the table is increased by 1
time complexity
Best O(1), worst O(n), average O(n)
delete
ListDelete(&L,i,&e)
Delete the i-th element of L and return it with e
Elements after the deleted position must be moved forward, and the table length is reduced by 1
time complexity
Best O(1), worst O(n), average O(n)
Code points
Note the difference between bit order i and array subscript
The algorithm must be robust and determine the legality of i
Pay attention to whether the moved element starts from the front element or the tail element.
Analyze why there is '&'
Sequence table search
Bitwise search
GetElem(L,i)
Get the value of the element at position i in table L
Use the array subscript to get the i-th element L.data[i-1]
Time complexity analysis
The best/worst/average time complexity is O(1)
Find by value
LocateElem(L,e)
Find the element whose first element value is equal to e in the sequence list L and return its bit order
Search starting from the first element and going backward
Time complexity analysis
The best time complexity is O(1)
Worst time complexity O(n)
Average time complexity O(n)
Definition of singly linked list
What is a singly linked list
Using "chain storage" (storage structure) realizes "linear structure" (logical structure)
A node stores a data element
The sequence relationship between each node is represented by a pointer
Define a singly linked list using code
typedef struct LNode{ //Define single linked list node type ElemType data; //data field struct LNode *next; //Pointer field }LNode,*LinkList;
Two implementations
Leading node
Empty table judgment: L==NULL
Easy to write code
No leading node
Empty table judgment: L->next==NULL;
Writing code is inconvenient
Other points to note
How to use the typedef keyword
LinkList is equivalent to LNode LinkList emphasizes a linked list; LNode emphasizes a node
Single linked list insertion and deletion
insert
Insert in bit order
Leading node
No leading node
Post-insert operation of specified node
Forward insertion operation of specified node
delete
Delete in bit order
Deletion of specified node
Search in singly linked list
Bitwise search
Note the comparison with the "sequence table"
A singly linked list does not have the characteristic of "random access" and can only be scanned sequentially.
Find by value
Find the length of singly linked list
Key
The time complexity of the three basic operations is O(n)
How to write code logic that loops through each node
Pay attention to the processing of boundary conditions
Creation of singly linked list
step1: Initialize a singly linked list step2: Take one data element at a time and insert it into the head/foot of the table
tail insertion method
Head insertion method
Double linked list
initialization
The priority and next of the head node both point to NULL.
Insert (rear insert)
Pay attention to the pointer modifications of newly inserted nodes, predecessor nodes, and successor nodes.
Boundary case: the newly inserted node is at the last position and requires special treatment
Delete (post-delete)
Pay attention to the modification of the pointers of the predecessor node and successor node of the deleted node.
Boundary case: If the deleted node is the last data node, special processing is required
Traverse
Starting from a given node, the implementation of backward traversal and forward traversal (termination condition of the loop)
Linked lists do not have random access characteristics, and search operations can only be achieved through sequential traversal.
circular linked list
Circular singly linked list
Empty table
non-empty table
Circular doubly linked list
Empty table
non-empty table
code problem
How to judge short
How to determine whether node p is the head/foot node of the table
circular linked list
What is a static linked list
Centrally allocate an entire contiguous address to store data elements
How to define a static linked list
Briefly describe the implementation of basic operations