随笔分类 -  数据结构与算法

摘要:1. 什么时候能默写出来呢?#include <iostream>using namespace std;struct node{ int data; node *next; node *prior;};class Link{ public: Link() { head_ptr = NULL; tail_ptr = NULL; } void insertNode(); void insertNode(node *ptr); void insertNodeAtHead(node *ptr); void ... 阅读全文
posted @ 2011-09-01 20:59 wtx 阅读(336) 评论(0) 推荐(0) 编辑
摘要:1. 递归法 #include <iostream>/* 整数划分问题 http://www.cnblogs.com/dolphin0520/archive/2011/04/04/2005098.html*////* f(n, m)= 1; (n=1 or m=1) f(n,m) = f(n, n); (n<m) 1+ f(n, m-1); (n=m) f(n-m,m)+f(n,m-1)... 阅读全文
posted @ 2011-08-25 15:08 wtx 阅读(511) 评论(0) 推荐(0) 编辑
摘要:0 整理自网络1. Java版(转) 要比较的对象必须实现Comparable接口,重写compareTo 方法,Java在红自带有优先级队列的实现PriorityQueueQueue<ToDoItem> q = new PriorityQueue<ToDoItem>();import java.util.Collections;import java.util.PriorityQueue;import java.util.Queue;public class ToDoItem implements Comparable<ToDoItem>{ private 阅读全文
posted @ 2011-08-24 20:06 wtx 阅读(1966) 评论(0) 推荐(0) 编辑
摘要:1. 100万数据的产生,随机数方式#include <iostream>#include <time.h>#include <assert.h>#include <stdio.h>#include <stdlib.h>using namespace std;const int size = 10000000;int num[size];int main(){ int n; FILE *fp = fopen("data.txt", "w"); assert(fp); for (n = 1; n 阅读全文
posted @ 2011-08-20 21:50 wtx 阅读(2527) 评论(1) 推荐(1) 编辑

点击右上角即可分享
微信分享提示