
算法
文章平均质量分 63
wyj7260
这个作者很懒,什么都没留下…
展开
-
算法思想
转载自http://blog.sina.com.cn/s/blog_692c05d20100jwjz.htmlTaken from "Introduction to The Design and Analysis of Algorithms" by Anany Levitin节选自《算法设计与分析基础》潘彦 译蛮力法就像宝剑不是撬棍一样,科学也很少使用蛮力。——Edward转载 2013-01-12 10:33:31 · 1679 阅读 · 0 评论 -
剑指offer_02_二维数组中的查找
#include using namespace std;bool ifHasNum(int *data,int row, int col, int num){ if(data == NULL || row <= 0 || col <= 0){ return false; } int i = 0; int j = col - 1; while(i = 0){ if(nu原创 2014-09-06 10:34:20 · 800 阅读 · 0 评论 -
采集元数据的C++实现
我要做的是提取Test_case的名字,以及Test_case的持续时间(单位秒):下面是一段示例元数据Start| 20140618 root (6033) | tpi 1.4 | 14:53:52 10050943579848 0 |Start| 20814 SunOS 5.11 11.2 i86pc tcx4440-01 |STF_ENV| STC_NAME = os-zones |原创 2014-09-06 09:45:16 · 2087 阅读 · 0 评论 -
贪心算法 解决 活动选择问题
#define GREEDY_RECURIVE#ifdef GREEDY_RECURIVE#include #include #include using namespace std;void recursive_activity_selector( const int started[], const int finished[],vector& result, int i,in转载 2014-08-02 17:10:33 · 809 阅读 · 0 评论 -
微软实习生第一题
/*时间限制:10000ms单点时限:1000ms内存限制:256MBFor this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a’ and ‘z’ (including原创 2014-04-13 13:36:10 · 949 阅读 · 3 评论 -
一个简单的数据收集程序
#include #include#define BufferLength 500#define NUM_BENCHMARKS 10int isBufferContainsStr(char buffer[], char str[], int n) { int isContains=0; int i = 0; int j = 0; int k = 0; for(i=0; i原创 2014-03-20 11:42:27 · 1975 阅读 · 1 评论 -
二分查找
#include //LENGTH 为有序表长度 #define LENGTH 6 //int binarySearch(int a[], int value, int len){ int low = 0; int high = len - 1; int mid = 0; while(low <= high){ mid = low + (high - low) / 2;原创 2014-04-13 21:20:06 · 729 阅读 · 0 评论 -
将文件中存储的十进制数转化为2进制
将文件leakyCellFile_32GB_1024ms.txt中的十进制数转化为2进制数,存储在文件HashSourceFile_2中。由于c中没有直接输出2进制的函数,所以选择,首先将文件leakyCellFile_32GB_1024ms.txt转化为16进制HashSourceFile16.txt,然后读取HashSourceFile16.txt中的16进制数,运用switch,将16进原创 2014-03-04 08:30:18 · 1584 阅读 · 1 评论 -
rand()函数的最大值问题
今天在做dram的模拟时候,需要用rand()函数模拟dram的cell的retention time,所以查看了一个rand()函数,该函数能产生0到RAND_MAX之间的数。不同平台下RAND_MAX值不同,我在32bit的windows VC6.0下测试,得出RAND_MAX 的值为32767(即2^15 - 1)。我在64bit的ubuntu下,测试,得到RAND_MAX的值为21原创 2013-04-23 19:39:15 · 3748 阅读 · 0 评论 -
采用openMP并行方法,实现用分支界限法解决的旅行售货员问题
#include "StdAfx.h"//源代码:#include #include #include #include #include #define NoEdge 1000struct MinHeapNode{ int lcost; //子树费用的下界 int cc; //当前费用 int rcost; //x[s:原创 2013-06-16 02:27:58 · 2108 阅读 · 1 评论 -
作为一个programmer你应该了解的latency
转载自:https://gist.github.com/jboner/2841832 Latency Comparison Numbers--------------------------L1 cache reference 0.5 nsBranch mispredict 5 nsL原创 2013-02-25 02:40:24 · 876 阅读 · 0 评论 -
MapReduce两位作者简介--两位谷歌大牛
MapReduce这篇论文由google的两位大牛Jeffery Dean和 Sanjay Ghemawat于2004年发表在操作系统设置和实现(OSDI)会议上。作者简介首先我们来了解一下Jeff Dean 和 Sanjay Ghemawat这两位大牛。Jeff Dean是一个谷歌的系统基础设施部门的研究员。Jeff Dean是ACM的一个资深会员,他曾以优异成绩取得了美国明尼苏达大学的原创 2013-06-16 09:59:23 · 2509 阅读 · 2 评论 -
Leetcode Add two numbers
/*#include using namespace std; *//** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */cla原创 2014-08-22 18:50:25 · 740 阅读 · 0 评论