数据结构
qq_31258245
中南大学学生
展开
-
CSU-ACM 1005: Binary Search Tree analog
CSU-ACM 1005: Binary Search Tree analogDescriptionBinary Search Tree, abbreviated as BST, is a kind of binary tree maintains the following property: each node has a Key value, which can be used to原创 2017-03-14 00:49:27 · 496 阅读 · 0 评论 -
单链表实现排序算法复杂度nlogn之归并排序
单链表实现时间复杂度nlogn, 空间复杂度为常数的归并算法。 作为复习,下面回顾一下归并排序的大致思路 归并排序举个例子就是,假如需要对一个大小为8的数列进行排序,那个首先分成两个大小为4的数列并排序,将这两个大小为4的数列排序后进行合并即可得到排序好的数组。对大小为4的数列进行排序时,又可以分成两个大小为2的数列进行排序后合并。体现了分治的思想。代码比较巧妙的是快慢指针&...原创 2018-02-15 22:39:49 · 534 阅读 · 0 评论 -
单链表实现排序算法之插入排序
插入排序的意思是每次从待排序数列中选出一个,插入到已排序的数列中。/** 这个是一开始的答案,但是案例没有全部通过,检查发现是注释处修改了head指针所致。* Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x)...原创 2018-02-16 01:05:06 · 889 阅读 · 0 评论 -
数据结构问题之重排链表
题目 Given a singly linked list L: L 0→L 1→…→L n-1→L n, reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→… You must do this in-place without altering the nodes’ values. For example, Giv...原创 2018-02-17 01:18:14 · 378 阅读 · 0 评论