- 博客(13)
- 收藏
- 关注
原创 计科1111-1114班第二次实验作业(算法基本功 与 综合思考)
(1)算法基本功——快速排序 对文件 largeW.txt(下载链接)中的数据,应用快速排序算法进行排序,并与冒泡排序、归并排序进行时间比较。体验算法复杂度对设计算法的影响。
2014-06-11 18:38:57 483
原创 第1次实验——NPC问题(回溯算法、聚类分析)
public class Queen { //同栏是否有皇后,1表示有 private int[] column; //右上至左下是否有皇后 private int []rup; //左上至右下是否有皇后 private int[] lup; //解答 private int[] queen;
2014-06-11 18:20:11 567 2
转载 第七周作业——背包算法 .
02.主文件: 03.package main; 04. 05.import java.io.BufferedReader; 06.import java.io.File; 07.import java.io.FileNotFoundException; 08.import java.io.FileReader; 09.import java.io.IOExc
2014-06-09 17:22:09 434
原创 第六周作业1——利用哈夫曼编码英文字母表
(1)最优huffman编码为: 111 (此字符为空格) a 1010 b 100100 c 00101 d 10111 e 010 f 110100 g 100111 h 0001 i 0111 j 1101101110 k 11011010 l 10110 m 110111 n 0110 o 1000 p 100110 q 1101101100
2014-04-18 23:11:31 451
原创 Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, whe
2014-04-12 11:00:53 490
转载 第五周作业——有向图邻接表表示及反向图构造
import java.io.*; import java.util.*; public class GraphReverse { public static void main(String[] args) { try { FileReader fr=new FileReader
2014-04-11 12:58:17 392
原创 Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
2014-04-11 10:32:18 440
原创 Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples: ["2", "1",
2014-04-09 17:50:03 347
原创 Reverse Words in a String
Reverse Words in a String My Submissions Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the".
2014-04-09 11:42:19 397
转载 第四周作业---图的表示
package GraphRepresentation; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader;
2014-04-03 21:07:57 440 1
原创 算法概论第三周作业
package sort; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.Input
2014-03-27 11:08:35 373
原创 算法概论第二周讲义、课外作业
2.1: 判断一个正整数是否为质数的算法。函数签名如下 int isPrime(long a) 输入:一个长整数a 输出:返回1(为质数),返回0(非质数) import java.util.Scanner; public class prime { public static void main(String[] args) { long
2014-03-19 00:00:36 453
原创 第一周算法概论作业
a=input("請輸入一個整數 a :") b=input("請輸入一個整數 b :") a=int(a) b=int(b) if a t=b b=a a=t c=a%b if c==0: print ("這兩個數的最大公約數為:%d"%b) else: while c!=0: a=b b
2014-03-12 22:57:10 499
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人