![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Algorithm
文章平均质量分 85
sunbin0123
这个作者很懒,什么都没留下…
展开
-
Solutions_to_Introduction_to_Algorithm_3nd_Exercise_3
3.1-1 Let f(n) and g(n) be asymptotically nonnegative functions. Using the basic definition of Θ-notation, prove that max(f(n),g(n))=Θ(f(n)+g(n)). Let f(n),g(n) be asymptotically nonnegative. Show原创 2013-02-07 21:31:25 · 995 阅读 · 0 评论 -
求整数数组中和最大的子数组的3种方法
输入一个整型数组,数组里有正数也有负数。数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和。求所有子数组的和的最大值。要求时间复杂度为O(n)。使用三种方式实现,分别是蛮力法:bf_MaxSubArray,分治法:dc_MaxArray,和O(n)实现的单循环法find_max。#include"stdio.h"#include"math.h"#include"time原创 2013-03-09 21:16:40 · 1596 阅读 · 0 评论 -
Stanford公开课之算法:设计与分析——(第四周) Programming Question-4
Question 1Download the text file here. Zipped version here. (Right click and save link as)The file contains the edges of a directed graph. Vertices are labeled as positive integers from 1 to原创 2013-03-04 16:21:42 · 1801 阅读 · 0 评论 -
Stanford公开课之算法:设计与分析——(第三周) Programming Question-3
Question 1Download the text file here. (Right click and save link as)The file contains the adjacency list representation of a simple undirected graph. There are 200 vertices labeled 1 to 200.原创 2013-03-04 16:17:09 · 1762 阅读 · 0 评论 -
Windows环境是使用C语言计算程序或算法执行时间的不同粒度实现
运行环境:Windows,VC++6.0需要微妙级别的童鞋直接看第三种!!!1.精确到秒,计时单位为秒头函数:#include开始时间:/* 长整形数据,time_t为time.h 中的宏定义,原型为 #define long time_t */time_t start_time,end_time;/*记录程序开始的时间*/start_time=time(NULL);结束时转载 2013-02-11 21:55:10 · 1542 阅读 · 0 评论 -
Stanford公开课之算法:设计与分析——II.渐进式分析(第一周)
Stanford课程地址:https://class.coursera.org/algo-003/lecture/index课程讲师:Tim Roughgarden内容提要:大O表示法的定义基本的例子Ω和Θ表示法其他的例子符号O通常考虑算法的最坏情况下的运行时间。Q:什么时候?A:对足够大的n,T(n)的上界是f(n)的常数倍。通俗的说:是增长次数小原创 2013-02-08 15:06:32 · 1618 阅读 · 0 评论 -
矩阵相乘的三种实现
对于两个N阶矩阵的乘法,可以使用蛮力法,三层循环即可实现,也可以使用分治法实现。原数据结构: public class Matrix { public Matrix(int N) { this.n = N; m = new int[n, n]; sx = 0;原创 2013-02-13 18:30:36 · 907 阅读 · 0 评论 -
Solutions_to_Introduction_to_Algorithm_3nd_Exercise_4
4.1-1 What does FIND-MAXIMUM-SUBARRAY return when all elements of A are negative? The biggest negative one.4.1-2 Write pseudocode for the brute-force method of solving the maximum-subarray proble原创 2013-02-11 22:04:59 · 655 阅读 · 0 评论 -
Stanford公开课之算法:设计与分析——(第一周) Programming Question-1
Question 1Download the text file here. (Right click and save link as)This file contains all of the 100,000 integers between 1 and 100,000 (inclusive) in some order, with no integer repeated.原创 2013-02-10 23:15:32 · 1372 阅读 · 1 评论 -
Algorithm Definition Reviews
Divide and ConquerThey break the problem into several subproblems that are similar to the original problem but smaller in size, solve the subproblems recursively, and then combine these solutions to原创 2013-02-13 23:44:17 · 330 阅读 · 0 评论