- 博客(11)
- 收藏
- 关注
原创 单链表排序
#include #include typedef struct Node{ int data; struct Node *next;}node;//单链表排序,比较过程中只交换节点数据void link_sort(node *head){ node *tmp1 = head->next; node *tmp2 = NULL; int val = 0; if(tmp1
2018-05-01 22:35:24 939
原创 将两个有序单链表合并为一个有序单链表
#include #include typedef struct Node{ int data; struct Node *next;}node;//两个带头结点的有序单链表合并后任然有序//先确定头结点,再在剩下的节点中选择值较小的节点链接到已排好序的尾节点//直到有一个链表为空node *link_merge(node *head1, node *head2){ no
2018-05-01 21:07:39 14358 2
原创 单链表逆序---时间复杂度和空间复杂度较优
typedef struct Node{ int data; struct Node *next;}node;typedef struct{ node head; node tail;}link;void link_revert(link *p){ node *first = NULL, *mid = NULL, *last = NULL, *tmp = NULL; if(p
2018-05-01 14:09:28 2652
原创 单链表的实现
#include #include typedef struct Node{ int data; struct Node *next;}node;typedef struct{ node head; node tail;}link;void link_init(link *p){ p->head.next = &(p->tail); p->tail.next = N
2018-05-01 13:20:06 176
原创 链队列的实现
#include #include typedef struct Node{ int data; struct Node *next;}node;typedef struct{ node head; node tail; int num; //队列元素个数}queue;void queue_init(queue *ps){ ps->head.next = &(ps-
2018-05-01 13:18:06 611
原创 顺序队列的实现
#include typedef struct{ int buf[SIZE]; //编译时指定SIZE的值 int head; int tail; int qty; //队列元素个数}queue;void queue_init(queue *q){ q->head = 0; q->tail = 0; q->qty = 0;}int queue_size(const
2018-05-01 13:11:25 341 1
原创 链栈的实现
#include #include typedef struct Node{ int data; struct Node *next;}node;typedef struct{ node head; node tail; int num; //节点个数}stack;void stack_init(stack *ps){ ps->head.next = &(ps->t
2018-05-01 13:08:03 156
原创 顺序栈的实现
#include typedef struct{ int buf[SIZE]; //编译时指定SIZE的值 int num; //栈元素个数}stack;void stack_init(stack *ps){ ps->num = 0;}void stack_delete(stack *ps){ ps->num = 0;}int stack_size(const s
2018-05-01 13:01:55 154
原创 有序二叉树的实现
#include <stdio.h>#include <stdlib.h>struct Node;typedef struct{ struct Node *pnode;}tree;typedef struct Node{ int data; tree left; tree right;}node;//树的初始化函数void tree_init...
2018-05-01 12:44:45 1359
原创 二分查找算法
int *search(const int *p_arr, int size, int val){ const int *start = p_arr; const int *end = p_arr + size - 1; const int *mid = NULL; while(start < end){ //首先计算中间点存储区的地址 并...
2018-05-01 11:51:46 119
原创 需重点掌握的排序算法:快速排序和冒泡排序
//快速排序的经典实现(重点)void quick_sort(int *parr, int size){ int base = *parr, tmp = 0; int *start = parr, *end = parr + size - 1; if(size <= 1){ return; } while(start < en...
2018-05-01 11:16:22 209
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人