Jack's Blog

流淌的心,怎能阻拦,吹来的风,又怎能阻挡。

数据结构(链表、栈、队列)--ACM第四讲

Jacob posted @ Oct 23, 2017 10:24:45 PM in 未分类 with tags C语言 acm , 1488 阅读

函数的参数是什么样的?
结构体
struct A指针或引用
链表 数组
线性表
链表——无顺序数组
为什么是零散的状态?
1.可以动态申请内存
链表不需要任何静态的申请
eg.1
1 2 3 4 6 8 10
1 2 3 6 8 10
删除第四位
for(int i=3;i<=n;i++){
    a[i]=a[i+1]
}
链表插入一次就好
数组得挪很多次
链表访问比数组麻烦
链表结构体

声明一个指针函数
Struct link{
    int data;
    link* next;(内置类型的一个东西)
}
link *l;
l=new link();
(*l).data=15(l->data=15);
l->next =NULL;
link *head=new link();
link *push_back(link *p,int x)
{
    link *q= new link();
    q->data = x;
    q->next = NULL;
    p->next = q;
    return p->next;

}
Link *tmp = head;

链表访问复杂度较高(频繁插入删除,不频繁查找)
for(int i=1;i<10;i++)
{
    tmp = push_back(tmp,i);
}
栈 stack(抽象数据结构)
只能在顶端进行插入和删除
先进后出
队列(抽象数据结构)
可以用数组,也可用链表
数据结构
1.数据形态
2.数据操作

Avatar_small
AP 1st Iwgu student 说:
2022年8月20日 20:04

western governors university student login. Access the WGU student portal here. Students can find instructions for initial log in to the learning portal for the university. At WGU, we're student obsessed, wgu student portal so you'll get one on one faculty support. ... distance, learning, and all other barriers to ensure that everyone has access 2021

Avatar_small
Emma 说:
2023年1月24日 22:08

The unordered array is in a fragmented state due to the frequent insertion and deletion of data. This requires the array to be moved multiple times, making access more real estate The Terraces at Encino Creek difficult than a linked list structure. A linked list structure utilizes a pointer function to declare a link, which allows for dynamic memory allocation without any static application. For example, when deleting the fourth bit, you can simply insert the linked list once, whereas the array has to be moved multiple times. This makes the linked list structure a more efficient and effective tool for this purpose.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter