• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
厚积薄发
| 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理
1 2 3 下一页

2012年11月25日

CompilerDesign 个人答案 - Ch1
摘要: E 1.1.1:Compilier: translate code from source language to target languageInterpreter: translate code + execution (code + input + interpreter -> output)E1.1.2:Pro of compiler: simpler design; multiple runPro of interpreter: realtime runningE1.1.3:Easier to debug the compilerCan do an extra level o 阅读全文
posted @ 2012-11-25 23:53 songyy 阅读(218) 评论(0) 推荐(0)
 
 

2012年11月4日

算法导论(CLRS, 2nd) 个人答案 Ch34.1
摘要: 34.1-1:Assumption: the graph is unweightedLONGEST-PATH-LENGTH ∈P=> LONGEST-PATH∈P:Suppose there's a problem solves LHS in polynomial time, gives result k; then for the problem of RHS, it returns true if the given k' <= k.LONGEST-PATH∈P:=> LONGEST-PATH-LENGTH ∈P:Guess the k to the po 阅读全文
posted @ 2012-11-04 21:09 songyy 阅读(3411) 评论(0) 推荐(0)
 
 

2012年1月1日

uva 541 - Error Correction
摘要: Problem:http://uva.onlinejudge.org/external/5/541.htmlBasic Idea: calculate the sum of each row and each column respectively. If found any more than two row/column has an odd sum, or one row has odd sum, but all column have even sum, then it's corrupted; if one row & one column has old sum, 阅读全文
posted @ 2012-01-01 16:36 songyy 阅读(207) 评论(0) 推荐(0)
 
 

2011年7月1日

算法导论(CLRS, 2nd) 个人答案 Ch2 end of chapter
摘要: 2-1:2-2:a) loop invariant,initial condition, termination condition.b) A[j] is thesmallest element in A[j .. length[A]]. initialization: at the start of the loop, j = length[A].It's the smallest element in A[length[A] ~ length[A]] (because it'sthe only element). maintenance: if j = k is the s 阅读全文
posted @ 2011-07-01 16:18 songyy 阅读(723) 评论(0) 推荐(0)
 
算法导论(CLRS, 2nd) 个人答案 Ch2.3
摘要: 2.3-1:2.3-2:function MERGE-IMPROVED(A,p,q,r){ create array B[0 ... r - p]; int i = p, j = q+1, t =0; while(i<=q && j<=r){ if(A[i] >= A[j]){ B[t++] = A[j++]; } else{ B[t++] = A[i++]; } } if(i>q){ // i pile exhaustedwhile(j<=r) B[t++] = A... 阅读全文
posted @ 2011-07-01 12:07 songyy 阅读(487) 评论(4) 推荐(0)
 
 

2011年6月30日

算法导论(CLRS, 2nd) 个人答案 Ch2.2
摘要: 2.2-1:O(n^3)2.2-2:Selection-Sort(A): for( i=0 ; i<A.size()-1 ; i++){ max = A[i]; index = 0; for(j=i+1; j<A.size(); j++){ if(max < A[j]){ max = A[j]; index = j; } } // then swap the next max and the current element A[j] = A[i]; A[i] = max; }2.2-3:Say we're sorting nelementsWorst Case: nB 阅读全文
posted @ 2011-06-30 18:51 songyy 阅读(336) 评论(0) 推荐(0)
 
 

2011年5月28日

算法导论(CLRS, 2nd) 个人答案 Ch2.1
摘要: 2.1-1:2.1-2:NON-INCREASING-INSERTION-SORT(A) forj: 1~ length(A)-1: if(A[j]< A[j-1]): key= A[j]; t = j-1; while(A[t]< key && t>=0): A[t+1]= A[t]; t--; A[t]= key; returnA;2.1-3:// Assumption: Ifthere're duplicated elements, only return// the index of the first element.LINEAR-SEARC 阅读全文
posted @ 2011-05-28 11:35 songyy 阅读(376) 评论(0) 推荐(0)
 
算法导论(CLRS, 2nd) 个人答案 Ch1
摘要: 1.1-1Sorting: rank thestudent's according to the scoreDetermining thebest order for multiplying matrices: When doingprobability calculation, one may require lots of matrices multiplication for the cumulative probabilityresultsFinding the convexhull: 1.1-2Space1.1-3Linked list:Strength: can beuse 阅读全文
posted @ 2011-05-28 11:31 songyy 阅读(509) 评论(0) 推荐(0)
 
 

2011年4月23日

讨论记录:求大于一个时间段的最大平均积分,O(n)时间实现
摘要: 虽然下周就考试了,还有很多没复习……我还如此淡定地花了整整一个下午+晚上想了一个实际问题……(其实也不是那么特别实际,但的确是来自于现实生活的DP问题)问题+讨论的URL:http://topic.csdn.net/u/20110421/17/dc8e63bf-7992-487f-a112-049cf390cb1c.html?seed=1122826158&r=72946293#r_72946293(因为考虑到很多人很懒,不想打开URL去看,我把里面重点的内容复制过来)问题陈述:比如CSDN的积分形式(以下为假设),每当你获得一次积分,服务器便保留这时的时间以及总分。现在要求在哪一段时 阅读全文
posted @ 2011-04-23 22:42 songyy 阅读(344) 评论(0) 推荐(0)
 
 

2011年4月5日

uva 10702 - Travelling Salesman
摘要: URL: http://uva.onlinejudge.org/external/107/10702.htmlAC Code:/*Problem ID: 10702Solver: songyyStart Time: End Time:Time Spent:*/#include <iostream>#include <stdio.h>#include <vector>#include <string.h>#define INF 1000000usingnamespace std;int graph[100][100];int memo[100][1 阅读全文
posted @ 2011-04-05 23:32 songyy 阅读(470) 评论(0) 推荐(0)
 
 
1 2 3 下一页

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3