单链表快速排序算法实现
来源:互联网 发布:小熊电蒸锅 淘宝 编辑:程序博客网 时间:2024/06/06 09:14
单链表结构:
typedef int ElemType;typedef struct ListNode* List;struct ListNode{ElemType keyList next;};
实现代码如下:
void QuickSort( List head, List tail ){if ( head->next == tail || head->next->next == tail )return;List mid = head->next;List p = head;List q = mid;ElemType pivot = mid->key;List t = mid->next;while ( t != tail ){if ( t->key < pivot )p = p->next = t;elseq = q->next = t;t = t->next;}p->next = mid;q->next = tail;QuickSort( head, mid );QuickSort( mid, tail );}
调用时参数head为(带头节点的)单链表头节点指针,tail为单链表尾节点的next指针指向的类容。通常情况下tail的内容为NULL,因此,调用时为QuickSort(head, NULL)。
- 单链表快速排序算法实现
- 单链表快速排序算法实现
- 单链表快速排序算法实现
- 快速排序算法实现
- 快速排序算法实现
- 快速排序算法实现
- 快速排序算法实现
- 实现快速排序算法
- 快速排序算法实现
- 快速排序算法实现
- 快速排序算法实现
- 快速排序算法实现
- 实现快速排序算法
- 快速排序算法实现
- 快速排序算法实现
- 算法实现-->快速排序
- 快速排序算法实现
- 快速排序算法实现
- C中图的深度优先遍历算法
- 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“Connection refused: connect。
- 终于能写博客了!
- oracle中to_char函数操作时间对象
- awk 的一些用法
- 单链表快速排序算法实现
- fork vfork函数区别
- 软件工程开发模型以及在软件工程中的作用
- WPS 常用操作
- Z77比起Z68
- ioremap
- 链接脚本(1)
- 面试贵仁科技,一败涂地
- android sdk 的安装