更新数据结构第二章

This commit is contained in:
Alice-and-Bob
2020-04-02 10:18:03 +08:00
parent 03cb8ed9f8
commit d62aa2f568
8 changed files with 232 additions and 10 deletions

View File

@@ -7,23 +7,23 @@
+ 能填多少坑取决于作者决定考哪个学校如果决定的学校不是考408那我只会更新那个学校的科目的总结┓( ´∀` )┏)咕咕咕
+ 如果对你有帮助有启发欢迎点个star资瓷一下作者同时欢迎有对内容更好想法/懂得xmind排版的朋友提交issue帮助这个项目更好
+ 或许你也可以参考这个[相似项目](https://github.com/SSHeRun/CS-Xmind-Note)
+ 如果对你有帮助有启发,欢迎**点个star**资瓷一下作者;同时欢迎有**对内容更好想法/懂得xmind排版**的朋友提交issue帮助这个项目更好
> 或许你也可以参考[这个项目](https://github.com/SSHeRun/CS-Xmind-Note)
![image](https://images.cnblogs.com/cnblogs_com/unknown404/1368664/o_200228080609138b9120a159048225d7ead2d9f7bea6.jpg)
---
## 计算机网络
+ [x] 第一章 概论
+ [x] 第二章 物理层
+ [x] 第三章 数据链路层
+ [x] 第四章 网络层
+ [x] 第五章 运输层
+ [x] 第六章 应用层
+ [x] [第一章 概论](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E7%BB%AA%E8%AE%BA/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E6%A6%82%E8%BF%B0.xmind)
+ [x] [第二章 物理层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%BA%8C%E7%AB%A0%20%E7%89%A9%E7%90%86%E5%B1%82/%E7%AC%AC%E4%BA%8C%E7%AB%A0%20%E7%89%A9%E7%90%86%E5%B1%82.xmind)
+ [x] [第三章 数据链路层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%B8%89%E7%AB%A0%20%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82/%E7%AC%AC%E4%B8%89%E7%AB%A0%20%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82.xmind)
+ [x] [第四章 网络层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E5%9B%9B%E7%AB%A0%20%E7%BD%91%E7%BB%9C%E5%B1%82/%E7%AC%AC%E5%9B%9B%E7%AB%A0%20%E7%BD%91%E7%BB%9C%E5%B1%82.xmind)
+ [x] [第五章 运输层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%BA%94%E7%AB%A0%20%E8%BF%90%E8%BE%93%E5%B1%82/%E7%AC%AC%E4%BA%94%E7%AB%A0%20%E8%BF%90%E8%BE%93%E5%B1%82.xmind)
+ [x] [第六章 应用层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E5%85%AD%E7%AB%A0%20%E5%BA%94%E7%94%A8%E5%B1%82/%E7%AC%AC%E5%85%AD%E7%AB%A0%20%E5%BA%94%E7%94%A8%E5%B1%82.xmind)
## 数据结构
+ [x] 第一章 绪论
+ [x] [第一章 绪论](https://github.com/Alice-and-Bob/CS408/blob/master/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E7%BB%AA%E8%AE%BA/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E7%BB%AA%E8%AE%BA.xmind)
+ [ ] 第二章 线性表
+ [ ] 第三章 栈和队列
+ [ ] 第四章 树与二叉树

View File

@@ -0,0 +1,150 @@
/***
* @Author: Alice-and-Bob
* @Date: 2020-03-31 22:03:34
* @LastEditTime: 2020-04-02 09:30:54
* @LastEditors: Alice-and-Bob
* @Description: 线性表基本操作在链表上的cpp实现代码实现不全不能运行用于演示算法步骤
* @*******************************************
* @* 全世界程序员,联合起来! *
* @* Programmers of all lands, Unite! *
* @* программист всех стран, соединяйтесь! *
* @*******************************************
*/
/*------------------------单链表------------------------*/
#define END 1000000 //预先确定的结束值
typedef struct LNode
{
int data;
struct LNode *next;
} LNode, *LinkList;
//头插法建立链表
LinkList List_HeadInsert(Linklist &L)
{
LNode *s;
int x;
L = (LinkList)malloc(sizeof(LNode));
L.next = NULL;
while (cin >> x)
{
if (x == END)
{
break;
}
else
{
s = (LinkList)malloc(sizeof(LNode));
s.data = x;
s.next = L.next;
L.next = s;
}
}
return L;
}
//尾插法建立链表
LinkList List_TailInsert(LinkList L)
{
int x;
L = (LinkList)malloc(sizeof(LNode));
LNode *s, *t = L; //t是尾指针总指向链表最后一个节点s是临时节点
while (cin >> x)
{
if (x == END)
{
break;
}
else
{
s = (LinkList)malloc(sizeof(LNode));
s.data = x;
s.next = NULL;
r.next = s;
r = r.next;
}
}
//r.next = NULL;
return L;
}
//按序号查找节点
LNode *GetElem(LinkList L, int i)
{
LNode *s = L.next;
int j = 1;
if (i == 0)
{
return L
}
else if (i < 1)
{
return NULL;
}
while (s && j < i)
{
s = s.next;
j++;
}
return s;
}
//按值查找节点
LNode *LocalteElem(LinkList L, int x)
{
LNode *s = L.next;
while (s.data != x && s.next != NULL)
{
s = s.next;
}
return s;
}
//在某个给定节点前插
{//前插操作
p = GetElem(L, i - 1); //找到要插入的前驱节点
s.next = p.next;
p.next = s;
}
{//后插转前插
s.next = p.next;
p.next = s;
temp = p.data;
p.data = s.data;
s.data = temp;
}
//删掉某个给定节点
{//前删操作
p = GetElem(L, i-1);
q = p.next;
p.next = q.next;
free(q);
}
{//后删转前删
q = p.next;
p.data = p.next.data;
p.next = q.next;
free(q);
}
/*------------------------改进链表----------------------*/
//双链表
typedef struct DNode
{
ElemType data;
struct DNode *prior,*next;//前驱指针,后继指针
};
//插入节点
{
s.next = p.next;
p.next.prior = s;
s.prior = p;
p.next = s;
}
//删除节点
{
p.next = q.next;
q.next.prior = p;
free(q);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -0,0 +1,72 @@
/***
* @Author: Alice-and-Bob
* @Date: 2020-03-26 23:45:49
* @LastEditTime: 2020-03-27 12:05:27
* @LastEditors: Alice-and-Bob
* @Description: 顺序表的基本操作cpp实现
* @
* @全世界无产者,联合起来!
* @Workers of all lands, Unite!
* @Пролетарии всех стран, соединяйтесь!
*/
bool ListInsert(SqList &L, int i, Elemtype e)
{
/***
* @description:实现把元素e插入到顺序表L的第i个位置
* @param {type}
* @return:
*/
if (i < 0 || 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 true;
}
bool ListDelete(SqList &L, int i, Elemtype &e)
{
/***
* @description:实现删除顺序表L的第i个元素使用e返回被删除的元素
* @param {type}
* @return:
*/
if (i < 0 || i > L.length + 1)
{
return false;
}
e = L.data[i - 1];
for (int j = i; j < L.length; j++)
{
L.data[j - 1] = L.data[j];
}
L.length--;
return true
}
int LocateElem(SqList L, ElemType e)
{
/***
* @description: 实现在顺序表里按序查找第一个值为e的元素
* @param {type}
* @return:
*/
for (int i = 0; i < L.length; i++)
{
if (L.data[i] == e)
{
return i + 1;
}
}
return 0;
}