数据结构和算法
gnimgnot
这个作者很懒,什么都没留下…
展开
-
C#数据结构和算法 [Binary Trees and Binary]
Trees are a very common data structure in computer science. A tree is anonlinear data structure that is used to store data in a hierarchical manner.We examine one primary tree structure in this ch翻译 2012-12-26 11:21:07 · 1007 阅读 · 0 评论 -
单链表逆序
#include typedef struct Node { char data; struct Node* next;} Node;void print_list(Node* root) { while (root) { printf("%c ", root->data); root = root->next; } printf("\n");}原创 2014-06-27 00:58:56 · 822 阅读 · 0 评论 -
二叉树遍历(层次,递归,非递归)
void LayerOrder(BTreeNode *t){ //利用队列实现层次遍历,每次访问根结点,然后一次放入左结点和右结点(如果有的话)。 if(t == NULL)return ; queue q; BTreeNode *temp; q.push(t); while(!q.empty()){ te原创 2014-06-27 00:58:12 · 1963 阅读 · 0 评论 -
判断单链表是否有环、找出两个单链表的交点
主要思路:用两个指针,步长分别为1和2,遍历原创 2014-06-27 23:24:59 · 1402 阅读 · 0 评论 -
.NET源码中的栈
.NET源码中的栈是基于数组实现的,原创 2014-06-30 00:54:55 · 982 阅读 · 0 评论 -
.NET源码中的SortedSet
SortedSet是一个排序的数据集合,其基本数据结构如下:注意到这里有一个 public class SortedSet : ISet, ICollection, IEnumerable, ICollection, IEnumerable, ISerializable, IDeserializationCallback { internal const int StackAll原创 2014-07-01 00:46:15 · 1883 阅读 · 0 评论 -
.NET源码中的链表
.NET中自带的链表是LinkedList类,并且已经直接实现成了双向循环链表。原创 2014-06-30 00:11:23 · 1686 阅读 · 0 评论 -
.NET源码中的队列
.NET源码中的栈也是基于数组实现的,基本的内部结构定义如下:用一个数组来保存数据。而用于默认构造函数,初始化空栈。原创 2014-06-30 01:23:51 · 935 阅读 · 0 评论 -
.NET源码中的二分查找实现
二分查找的前提是数据已经预先排序,而然后通过不断地缩小查找范围的方式来查找数据原创 2014-06-22 11:49:38 · 1159 阅读 · 0 评论 -
.NET源码的内部排序实现
使用JetBrains的DotPeek工具可以方便地查看.net的部分源码。于是看了一下.NET的内部是如何实现排序的算法。在System.Collections.Generic 命名空间下可以看到ArraySortHelper的实现。public void Sort(T[] keys, int index, int length, IComparer comparer) {原创 2014-06-22 11:42:11 · 1686 阅读 · 0 评论 -
数据结构与算法整理
初级排序:选择排序插入排序冒泡排序常用排序:归并排序快速排序堆排序原创 2013-07-22 23:07:36 · 1412 阅读 · 0 评论 -
排序比较与总结
之前一共实现了6种比较常见的排序算法,分别是:选择排序,插入排序,冒泡排序,归并排序,快速排序,堆排序 效率:衡量一个算法的效率包括空间和时间,有时候还要考虑稳定性。前3种排序的方法效率较低,实现也比较简单,适合规模比较小的排序,个人认为适合排序总量在10000以下的随机数组。后3种排序的方法效率较高,实现稍微复杂一点,但也还好,适合规模较大的排序。时间方面,前原创 2013-07-26 17:10:48 · 1451 阅读 · 1 评论 -
堆排序
引子:堆排序是第3个比较有意思的排序(相对于 归并排序,快速排序),效率很高,且不用额外的空间。堆的定义是:它用一个数组来存储一个完全二叉树(叶子节点只出现在最下层的树)。原创 2013-07-26 01:38:33 · 1694 阅读 · 0 评论 -
C#数据结构和算法[Basic Searching Algorithms]
Searching for data is a fundamental computer programming task and onethat has been studied for many years. This chapter looks at just one aspect ofthe search problem—searching for a given value in翻译 2012-12-26 11:21:04 · 787 阅读 · 0 评论 -
C#数据结构和算法[Preface]
The study of data structures and algorithms is critical to the developmentof the professional programmer. There are many, many books written ondata structures and algorithms, but these books are u翻译 2012-12-26 11:20:49 · 1238 阅读 · 0 评论 -
C#数据结构和算法 [Arrays and ArrayLists]
Arrays and ArrayListsThe array is the most common data structure, present in nearly all programminglanguages. Using an array in C# involves creating an array object ofSystem.Array type, the abst翻译 2012-12-26 11:20:53 · 808 阅读 · 0 评论 -
C#数据结构和算法 [Basic Sorting Algorithms]
The two most common operations performed on data stored in a computerare sorting and searching. This has been true since the beginning of the computingindustry, which means that sorting and search翻译 2012-12-26 11:21:01 · 716 阅读 · 0 评论 -
C#数据结构和算法[An Introduction to Collections, Generics, and the Timing Class]
An Introduction to Collections, Generics,and the Timing Class集合,泛型,时间类的介绍This book discusses the development and implementation of data structuresand algorithms using C#. The data structures we翻译 2012-12-26 11:20:51 · 896 阅读 · 0 评论 -
C#数据结构和算法 [index]
1--介绍 集合,泛型和时间类2--数组,泛型数组3--基础排序4--基础查找5--栈和队列6--bit数组类7--字符串,String类,StringBuild类8--模式匹配和文字处理9--DictionaryBase和SortedList10-Hashing和HashTable类11-链表12-二叉树和二叉搜索树13-sets14-高级排序翻译 2012-12-26 11:20:46 · 858 阅读 · 0 评论 -
在 DateTime、DateTimeOffset 和 TimeZoneInfo 之间进行选择
使用日期和时间信息的 .NET Framework 应用程序千差万别,它们可以通过多种方式使用这些信息。 日期和时间信息较常见的用法包括以下一种或多种:仅反映日期,时间信息并不重要。 仅反映时间,日期信息并不重要。 反映不依赖于特定时间和地点的抽象日期和时间(例如,大部分国际连锁店都在每个工作日的上午 9:00 开始营业)。 从 .NET Framewo原创 2013-01-08 12:12:42 · 2237 阅读 · 0 评论 -
选择排序
排序算法原创 2013-07-17 00:55:47 · 1474 阅读 · 0 评论 -
插入排序
插入排序原创 2013-07-17 16:44:49 · 1145 阅读 · 0 评论 -
冒泡排序
冒泡排序原创 2013-07-17 17:11:02 · 1255 阅读 · 0 评论 -
快速排序
引子:快速排序算是归并排序的一个改进吧,思路也是递归二分。而区别是归并排序使用的中点是随机数列的索引中点,而快速排序使用的中点是一个具体的值,这个值的初始值是随机的,可以定为数组的第1个元素,也可以是第x个。需要经过一轮切分,来确定这个“中点值”,切分操作还会让让小于中点值的数都放到左边,大于中点的值数都放到右边,所以这一轮切分中会有很多次中点左右两边的交换。然后再次从左边开始切分原创 2013-07-20 14:58:10 · 1183 阅读 · 0 评论 -
归并排序
引子:看了归并排序,觉得这才真正像个算法,插入,选择,冒泡简直特么的就像是暴力猜解密码一样的弱。测试了100000个随机数字的排序,比上述3个算法的运行时间少了近100倍的数量级。算法思想:归并排序的主要思路是分治,可以大概参考二分查找的思路,并且也是递归的方式。首先按数组长度将数组切成左右两半,先将左边排序,再将右边排序,再将两边的合并起来,并且在合并的过程中排序原创 2013-07-20 10:29:02 · 1280 阅读 · 0 评论