大学生涯常用数据结构
FuHao顺序表 SeqList
1 2 3 4 5 6 7
| typedef int DataType; typedef struct SeqList { DataType* a; int size; int capacity; }SeqList;
|
需要实现的操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| void SeqListInit(SeqList* ps);
_Bool SeqListPushBack(SeqList* ps, DataType x);
_Bool SeqListPushFront(SeqList* ps, DataType x);
void SeqListPrint(SeqList* ps);
_Bool SeqListCheckCapacity(SeqList* ps);
int SeqListFind(SeqList* ps, DataType x);
void SeqListInsert(SeqList* ps, int pos, DataType x);
void SeqListErase(SeqList* ps, int pos);
|
链表
1 2 3 4 5
| typedef int DataType; typedef struct LinkList{ DataType data; struct LinkList* next; }LinkList;
|
需要实现的功能:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| void LinkListInit(LinkList* L);
void LinkListPrint(LinkList* L);
int LinkListLength(LinkList* L);
_Bool LinkListPushBack(LinkList* L, DataType x);
_Bool LinkListPushFront(LinkList* L, DataType x);
_Bool LinkListInsert(LinkList* L, int i, DataType x)
void LinkListDelete(LinkList* L, int i)
LinkList* LinkListGetElem(LinkList* L, int i)
|
栈
栈(Stack)是只允许在一端进行插入或删除操作的线性表
1 2 3 4 5 6
| typedef int DataType; typedef struct StackNode { DataType data; struct node *next; } StackNode;
|
需要实现的操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| void Init_LinkStack(StackNode* s);
void DestortStack(StackNode* s);
_Bool StackEmpty(StackNode* s);
void Push(StackNode* s,DataType e);
DataType Pop(StackNode* s);
int GetTop(StackNode* s);
void Display_LinkStack(StackNode* s);
void ClearStack(StackNode* s);
|
队列
只能在表的一端进行插入运算,在表的另一端进行删除运算的表
(头删尾插)
入队是在队尾进入 出队是在对头出去
1 2 3 4 5
| typedef int DataType;
struct Queue{ DataType data; }
|
需要实现的操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| _Bool InitQueue(SQueue* queue)
_Bool QueueEmpty(SQueue* queue)
_Bool QueueFull(SQueue* queue)
DestroyQueue();
ClearQueue();
QueueLength();
GetHead();
void EnQueue(SQueue* queue,DataType e)
DataType DeQueue(SQueue* queue)
void PrintQueue(SQueue* queue)
|