In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to understand the chain storage structure of linear table in C language data structure, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. What is the linked storage structure of linear table-linked list
Storage node: includes information about the element itself, as well as the logic of the relationship between elements
This node includes: data field and pointer field.
A pointer domain: pointing to a successor node, a single linked list
Two pointer fields: point to the previous node and point to the double linked list of the successor node
two。 The principle is: s = (LinkNode *) malloc (sizeof (LinkNode)); / / s-> data=e; / / where the value s-> next=p- > next; / / p-> next=s; / / here gives the pointer s to p
Node a-> node b-> node c-> node d
The first data:
P-> data: a corresponds to p-> next. The storage address is 007531F0.
Second:
P-> data: B corresponding to p-> next is the storage address:: 00753200
The third data:
P-> data: C corresponding to p-> next is the storage address: 00753210
...
Last piece of data:
P-> data: e corresponding to p-> next is the storage address: 00000000
In this way, at the time of output: loop using pairp-> next.
P-> next is the first
P-> next- > next is the second
P-> next- > next- > next is the third.
While (paired null) {printf ("% c", p-> data); pumped-> next; printf ("address change:% p\ n", p);}
The loop here makes pumped p-> next. (all the way to the next node)
While (jnext; / printf ("% p", p);} # include#includetypedef char ElemType;typedef struct LNode {ElemType data; struct LNode * next; / / pointer position} LinkNode;bool ListInsert (LinkNode * & L memint iMetre ElemType e) {int jig0; LinkNode * pendant LMague's / / the parameter pointer, the pointer pointer, the pointer assignment, the address if (idata=e; / / here assigned s-> next=p- > next; / / p-> next=s; / / here the pointer s is given to p. Printf ("% p\ n", s-> next) Printf ("% p\ n", p-> next); return true;}} void DispList (LinkNode * L) {LinkNode * paired L-> next / / this L-> next is p-> next, / / is not empty, / / p-> next points to s, returns a, loop / / p-> next- > next, points to b node, refers to b / / p-> next- > next- > next, points to c node. While (paired null) {printf ("% c", p-> data); pairp-> next; printf ("address change:% p\ n", p);} printf ("\ n");} void InitList (LinkNode * & L) {L = (LinkNode *) malloc (sizeof (LinkNode)) Printf ("% p\ n", L); L-> next=NULL; / / initial pointer value is null} int main () {LinkNode * h; ElemType e; printf ("the basic operation of single linked list is as follows:\ n"); printf ("(1) initialize single linked list h\ n"); InitList (h) Printf ("(2) inserts the e elements of a recordbrecy crecedence in turn\ n"); ListInsert (hrecedica'); / / s-> data=e; bbb'; / / s-> next=p- > next; / p-> next=s / / execute ListInsert once here; / / here: ListInsert (hmeme2); / / here: ListInsert (hmeme3); ListInsert (hL4); ListInsert (hL5); printf ("(3) output single linked list h:"); DispList (h) } effect picture:
After reading the above, have you mastered how to understand the linked storage structure of linear tables in C language data structures? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.