当前位置:网站首页>2022.1.23
2022.1.23
2022-06-26 04:38:00 【bu_ xiang_ tutou】
The linear table
1. Zero or more data elements Co., LTD. Sequence .
2. The relationship of each element in the sequence is one-to-one .
3. When passing an argument to a function , Whether this parameter will be changed within the function determines what parameter form to use .
3.1 If it needs to be changed , You need to pass a pointer to this parameter ,
3.2 If it doesn't have to be changed , You can pass this parameter directly .
4. Linear tables have a sequential storage structure ( Array ) And chain storage structure ( Linked list ).
Linked list
Linked list
1. The difference between linked list and array :
The array is convenient for finding data ,O(1), Deleting and adding data is complicated ,O(n);
Linked list lookup data is complex ,O(N), Deleting and adding data is simple ,O(1);
2. A linked list must have a header pointer .
3. A one-way linked list has a data field , A pointer field
struct node{
int data;
struct node *next;
}linklist; A two-way linked list has a data field , Two pointer fields
struct node{
int data;
struct node *next;
struct node *pre;
}linklist; 4. Insertion of linked list
int insert(linklist j,int i,int t)//i For the location to insert ,t Is the number to insert
{
int j;
linklist p,t;
p=j;
j=1;
while(p!=NULL&&j<i)
{
p=p->next;
j++;
}
if(p==NULL||j>i)// The first i There are no elements
return 0;
t=(linklist *)malloc(sizeof(struct node));
t->data=e;
t->next=p->next;// Backwards and forwards
p->next=t;
return 1;
} The first interpolation
void creat(linklist p)
{
int n,i,m;
scanf("%d",&n);
linklist t;
p=(linklist *)malloc(sizeof(struct node));// To apply for space
p->next=NULL;// Establish a single linked list of leading nodes
for(i=0;i<n;i++)
{
scanf("%d",&m);
t=(linklist *)malloc(sizeof(struct node));
t->data=m;
t->next=p->next;
p->next=t;// Insert into the header
}
}The tail interpolation
void creat(linklist p)
{
int n,i,m;
scanf("%d",&n);
linklist t,r;
p=(linklist *)malloc(sizeof(struct node));
r=p;//r Point to the entire linked list
for(i=0;i<n;i++)
{
scanf("%d",&m);
t=(linklist *)malloc(sizeof(struct node));
r->next=t;
r=t;// Link list
}
r->next=NULL;// End of list , The next point of the last point should be NULL
}5. Deletion of linked list
int insert(linklist j,int i)//i For the location to insert
{
int j;
linklist p,t;
p=j;
j=1;
while(p->next!=NULL&&j<i)
{
p=p->next;
j++;
}
if(p->next==NULL||j>i)// The first i There are no elements
return 0;
t=p->next;
p->next=t->next;
free(t);
return 1;
} 边栏推荐
- 35岁程序员炒Luna 千万资产3天归零,网友:和赌博一样
- Install SVN in Pagoda and build SVN version Library
- Thymeleaf data echo, single selection backfill, drop-down backfill, time frame backfill
- 35 year old programmer fired Luna millions of assets and returned to zero in three days. Netizen: it's the same as gambling
- Physical design of database design (2)
- 1.21 learning summary
- Realize video call and interactive live broadcast in the applet
- A new paradigm for large model application: unified feature representation optimization (UFO)
- PHP get mobile number operator
- Sixtool- source code of multi-functional and all in one generation hanging assistant
猜你喜欢

1.12 learning summary

2020-12-18

Svn error command revert error previous operation has not finished; run ‘ cleanup‘ if

企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?

Modify the number of Oracle connections

1.21 learning summary

Essential foundation of programming - Summary of written interview examination sites - computer network (1) overview

Construction of art NFT trading platform | NFT mall

SixTool-多功能多合一代挂助手源码
![Laravel framework Alipay payment fails to receive asynchronous callback request [original]](/img/a7/139604ec3a977f2a4e96f392e56602.jpg)
Laravel framework Alipay payment fails to receive asynchronous callback request [original]
随机推荐
[geek challenge 2019] rce me
修改Oracle连接数
Construction of art NFT trading platform | NFT mall
Nightmare
NVM installation and use and NPM package installation failure record
Review of number theory
Oracle data pump table
[Qunhui] command line acme SH automatically apply for domain name certificate
Development trend and prospect forecast report of China's financial industry 2022-2028 Edition
Report on demand situation and development trend of China's OTC industry from 2022 to 2028
基础查询
Motivational skills for achieving goals
0622-马棕榈跌9%
2021-01-31
PHP splits a string into arrays
MySQL enable logbin in Qunhui docker
numpy 索引及切片
2.9 learning summary
Fastadmin always prompts sqlstate[23000]: integrity constraint violation: 1052 column 'ID' in order clause is am
Guide de la pompe de données Oracle