CodeBus
www.codebus.net
Search
Sign in
Sign up
Hot Search :
Source
embeded
web
remote control
p2p
game
More...
Location :
Home
Search - n2-1
Main Category
SourceCode
Documents
Books
WEB Code
Develop Tools
Other resource
Sub Category
Games
SDK
Other
Search - n2-1 - List
[
Other resource
]
最小生成树prim算法
DL : 0
最小生成树的prim算法 是求图中的最短路径的一个重要算法 但是是O(n2)复杂度的一个算法-minimum spanning tree algorithm is the prim map for the shortest path algorithm of an important but is O (n2) of a complex algorithm
Date
: 2008-10-13
Size
: 3.07kb
User
:
袁文
[
Other resource
]
sgj4
DL : 0
邻接矩阵类的根是A d j a c e n c y W D i g r a p h,因此从这个类开始。程序1 2 - 1给出了类的描述。程 序中,先用程序1 - 1 3中函数Make2DArray 为二组数组a 分配空间,然后对数组a 初始化,以描述 一个n 顶点、没有边的图的邻接矩阵,其复杂性为( n2 )。该代码没有捕获可能由M a k e 2 D A r r a y 引发的异常。在析构函数中调用了程序1 - 1 4中的二维数组释放函数D e l e t e 2 D -adjacency matrix type is the root A d j a c c e n y W D i g r a p h, the category from the start. Procedure 1 2 - 1 is a kind of description. Procedures, use procedures 1 - 1 3 Make2DArray Function of two arrays a group of space allocation, Then a pair of array initialization to describe a n vertices, there is no edge of the adjacency matrix, the complexity of (n2). The code may not caught by M a k e r 2 D. A. r y a trigger abnormal. The destructor method is called in the process 1 - 1 4 2-D array of release function D e l e t e 2 D
Date
: 2008-10-13
Size
: 1.28kb
User
:
史桂金
[
Other resource
]
countsort
DL : 0
计数排序是一个非基于比较的线性时间排序算法。它对输入的数据有附加的限制条件: 1、输入的线性表的元素属于有限偏序集S; 2、设输入的线性表的长度为n,|S|=k(表示集合S中元素的总数目为k),则k=O(n)。 在这两个条件下,计数排序的复杂性为O(n)。 计数排序算法的基本思想是对于给定的输入序列中的每一个元素x,确定该序列中值小于x的元素的个数。一旦有了这个信息,就可以将x直接存放到最终的输出序列的正确位置上。例如,如果输入序列中只有17个元素的值小于x的值,则x可以直接存放在输出序列的第18个位置上。 计数排序算法没有用到元素间的比较,它利用元素的实际值来确定它们在输出数组中的位置。因此,计数排序算法不是一个基于比较的排序算法,从而它的计算时间下界不再是Ω(nlogn)。另一方面,计数排序算法之所以能取得线性计算时间的上界是因为对元素的取值范围作了一定限制,即k=O(n)。如果k=n2,n3,..,就得不到线性时间的上界。-Count ranking is based on a comparison of non-linear time sorting algorithm. Its input data Additional restrictions : 1, the importation of the linear element is a limited poset S; 2. The linear input based on the length of the table n | S | = k (S said set of elements in the total number of k), k = O (n). In these two conditions, the ranking counting for the complexity of O (n). Counting sorting algorithm is the basic idea for a given input sequence of each element x, determine the sequence x value is less than the number of elements. Once this information, it can be placed directly x to the final output the correct sequence position. For example, if the input sequence, only 17 elements in the value of x is less than the value then x can be placed directly on the output sequence of 18 pos
Date
: 2008-10-13
Size
: 1.35kb
User
:
金龙
[
Other resource
]
Sink
DL : 0
Ex8-4 汇点问题 « 问题描述: 采用邻接矩阵表示一个具有n 个顶点的图时,大多数关于图的算法时间复杂性为 O(n2 ),但也有例外。例如,即使采用邻接矩阵表示一个有向图G,确定G 是否含有一个 汇(即入度为n-1,出度为0 的顶点),只需要O(n)计算时间。试写出其算法。 « 编程任务: 对于给定的有n个顶点的图G 的邻接矩阵,各顶点依次编号为1,2,…,n。试设计一 个O(n)时间算法,计算图G 的汇点。 « 数据输入: 由文件input.txt提供输入数据。文件的第1 行有1 个正整数n,表示图G 中顶点个数。 第2 行起每行n个数,共n行,给出图G 的邻接矩阵。 « 结果输出: 程序运行结束时,将计算出的汇点编号输出到output.txt中。当图G 没有汇点时输出0。 输入文件示例 输出文件示例 input.txt 5 0 0 1 1 1 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1 0 1 1 0 0 output.txt 3
Date
: 2008-10-13
Size
: 50.89kb
User
:
Tonsen
[
Other resource
]
FastQuery
DL : 0
/*快速排序采用分治算法,将所需要排序的内容从文件读入放入数组a[p:r],按以下三个步骤进行排序 以a[p]为基准元素将数组分为三段,将大于基准元素的放到后面的单元,小的放到前面的单元, 再用递归对a[p:q-1],a[q+1:r]进行排序,最后合并 时间复杂度:最坏时间复杂度:O(n2) 平均时间复杂度:O(nlogn) */
Date
: 2008-10-13
Size
: 1.49kb
User
:
stone
[
Other resource
]
MAGIC_SE
DL : 0
n阶魔方阵,就是把1-n2个连续的正整数填到一个m*n的方阵中,使得每一列的和,每一行的和,以及两个对角线的和都相等。本程序只填奇数阶的魔方阵
Date
: 2008-10-13
Size
: 1.65kb
User
:
V
[
Other resource
]
b~a~hh
DL : 0
由n2个方块排成n行n列的正方形称为“n元棋盘”。如果两个皇后位于n元棋盘上的同一行或同一列或同一对角线上,则称它们为互相攻击。要求输出使n无棋盘上的n个皇后互不攻击的所有布局。 具体要求如下; (1)n可由键盘输入。 (2)在输入n后,动态建立方法说明中所需要建立的数组空间;程序运行结束时释放该存储空间。 (3)分别用n=4,5,6运行你的程序。-by n2-n squares formed n trip out of a square called "n chessboard." If the two Queen's n chessboard at the same line or in the same series or on the same diagonal, claimed they attack each other. Request output enable chessboard n-n the Queen's not attack each other all the layout. Specific requirements are as follows; (1) n input from the keyboard. (2) n input, dynamic methodology established by the needs of an array of space; Running at the end of the release of the storage space. (3), respectively, n = 4,5,6 run your procedures.
Date
: 2008-10-13
Size
: 8.78kb
User
:
林新华
CodeBus
is one of the largest source code repositories on the Internet!
Contact us :
1999-2046
CodeBus
All Rights Reserved.