自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(59)
  • 资源 (2)
  • 收藏
  • 关注

转载 python中整数除法的正负号

先看下面几个小题目:其中符号“//”表示除法结果的整数部分(即3/2=1.5,但3//2=1),“%”表示取余数。(1)7//3 和 7%3 的结果是什么?(2)7//-3 和 7%-3 的结果是什么?(3)-7//3 和 -7%3的结果是什么?(4)-7//-3 和 -7%-3 的结果是什么?来看一下运算结果:(1)7//3 = 2,

2014-04-01 09:41:26 3645

原创 crack the code intervie 4.8

You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree - it does not have to start

2014-03-11 20:08:41 721

原创 crack the code interview 4.7

You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.#include using namespace std;stru

2014-03-11 20:08:02 536

原创 crack the code interview 4.6

Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. Avoid storing additional nodes in a data structure. NOTE: This is not necessarily a binary search tr

2014-03-11 20:06:58 473

原创 crack the code interview 4.5

Write an algorithm to find the ‘next’ node (i.e., in-order successor) of a given node in a binary search tree where each node has a link to its parent.#include using namespace std;struct T

2014-03-11 20:06:20 575

原创 crack the code interview 4.4

Given a binary search tree, design an algorithm which creates a linked list of all the nodes at each depth (i.e., if you have a tree with depth D, you’ll have D linked lists).#include #include

2014-03-11 20:05:39 639

原创 crack the code interview 4.3

Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height.#include using namespace std;struct TreeNode{    int value;    TreeNode * left;

2014-03-11 20:05:02 349

原创 crack the code interview 4.2

Given a directed graph, design an algorithm to find out whether there is a route between two nodes.#include #include #include using namespace std;enum State {unvisited, visited, visiti

2014-03-11 20:04:10 505

原创 计算机图形学——表面细分

表面细分,举一个粒子,一个立方体,细分很多次以后,表面可有变得平滑。表面细分的一个关键步骤就是加点。如上图的a只有几个点,进过多次细分后,可有增加到很多点,像d一样。如何插点呢,看下图:一个图形,是由很多个三角形组成的,首先,在三角形的边上插点。如果一条边包含在两个三角形中,则插入的点的坐标按照第一个图进行分配,即3/8 * left + 3/8 * right +

2014-03-11 19:59:39 2806

原创 计算机图形学——图像压缩

首先,Huffman算法就可以进行压缩,但是直接用Huffman算法对图片的压缩效率并不高。采用Haar Wavelets,对图片的像素进行处理。首先,将第2i个值和第2i+1个值进行操作,相加除以2,得到的值,存放在i个位置,相减除以2,得到的值放在width/2 + i的像素上。其中,i的取值范围:[0,width/2].如下图所示:      

2014-03-11 19:25:50 1392

原创 计算几何——凸包

1.1 应用场景有多个手机信号发射器,求解一个最小区域,要求所有的发射器都包含在这个最小区域中,并且任意两台发射器之间的交流包含于在这个区域内。将所有的发射器看做为点,任意两个点之间的连线都包含于一个平面S。1.2 问题定义一个平面的子集S是凸的,当且仅当S中的任意两个点之间的连线都包含于S中。点集P的凸包是所有包含P的凸集中的最小的一个。凸包是唯一的。1.3 算法分析将所

2014-03-11 19:01:21 594

原创 人群与网络 第十一周

11.1 流行现象 新奇性 ,潮涌性11.2 幂律概率分布:随机事件的统计结果,随机事件的概率性质;概率密度函数,累计概率密度函数;概率和为1;均值;连续随机变量和离散随机变量相同;期望值;比较典型的概率密度函数:正态(大部分分布在均值左右,如身高分布),泊松(),幂律(度的分布,网站的规模)11.3 幂律分布的特别正态分布:大部分事件概

2014-02-19 13:42:40 575

原创 人群与网络 第十周

10.1 三节点敌友关系稳定的关系:朋友的朋友是你的朋友,敌人的敌人是你的朋友;平衡的三角关系:+--, +++,+表示友,-表示敌;不平衡的关系:++-,---;10.2 平衡问题平衡定义:当且仅当1、所有的关系都是朋友关系2、可以分为两组,一组朋友,一组敌人,而朋友群内部都是朋友,敌人群内部都是朋友;弱平衡网络:不存在++-的关系10.3 社

2014-02-19 12:51:10 641

原创 人群与网络 第

9.1 新生事物的社会传播人际关系网络对于新生事物的扩散起着重要的作用;新生事物的扩散,在时间轴上展示为s曲线;9.2 级联cascade扩散模型如果一个网络,使用B产品的回报为b,使用新产品的回报为a,对于一个用户B,如果他的邻居使用产品a的概率大于b/(a+b),则该用户B会转用新产品。整个扩散过程,可以看作是一种博弈过程;博弈的过程中,可以扩散到整个网络中,也

2014-02-19 10:14:57 971

原创 人群与社会 第八周

8.1 从众现象的普遍性及其影响从众行为,会根据群体的扩大,而进一步增强;8.2 一个集群实验每个个体做出的选择,后面的个体是可以看见的;每个个体根据自己看见的和推理的进行选择;个体看见了别人的选择,但是并不知道别人为什么选择;信息级联借助少量的信息就可以产生,也很容易被打破;8.3 概率基础样本空间:随机试验所有可能出现的结果集;事件:一个随机

2014-02-18 16:58:21 561

原创 人群与社会 第七周

7.1 有向图不对称的关系有向图,出度,入度,联通图,强连通图,联通分量,强联通分量7. 2 搜索引擎中权威值和中枢值搜索引擎网页排名hits算法给定一个所有网页的有向图每个网页都有中枢值和权威值。初始化时,将每个节点的权威值和中枢值为1;被很多网页指向:权威值高指向很多网页:中枢值高首先利用中枢值,更新每个网页的权威值,被指向网页的权威值等于指

2014-02-18 14:43:37 1235

原创 人群与社会 第六周

6.1 搜索引擎的广告市场基本定义:广告位:广告位置有限,不同的广告位点击率也不同点击收入:广告主对于每次点击评估的期望收入广告收入=点击次数*点击收入广告主回报=期望的广告收入-广告价格可以通过市场清仓价格对于不同的广告位进行定价。对于每个广告主,会得到收益矩阵,可以达到社会福利最大化,前提是必须知道广告主对于每次广告点击的期望收入。如果不知道这个期望收入,可以按照拍

2014-02-18 13:44:41 584

原创 人群与社会 第五周

5.1 布雷斯悖论:在现实情况很糟糕的情况下,有时候增加资源,反而会使情况便的更加糟糕。道路博弈情况,此时每个人的行驶时间为65;但是当修建C到D的路,花费为0时,所有人都走ACDB这条路,每人花费为80,这就出现了布雷斯悖论。在我们日常生活中,总会参与无形的博弈过程,但是这个过程并不能够用收益矩阵来表示。5.2 布雷斯悖论主要用于交通网络的研究,例如中国高速公

2014-02-13 20:15:35 591

原创 latex写论文

latex编写论文非常的方便,通常英文论文都有一定的cls的模板,直接在模板里面进行内容的填充,就可以写出高质量的论文。下面,记录一下latex中编写论文中常见的一些命令。首先,通常使用CTex和texmaker两种编辑工具,这两种IDE都非常的不错,大家可以进行下载与按照。下面开始正式的编写:1、会议模板\documentclass[conference]{IEEEtran}

2014-01-19 15:35:48 953

原创 算法导引

算法就是计算机求解的步骤和规则,包括输入,输出。算法满足5个特性:·输入·输出·有穷性,在时间上能够终止的,操作系统就不满足,当操作系统没有执行的任务时候,并没有终止,而是等待下一个任务;·确定性,无二义性,每一个语句都有确定的定义;·能行性,可以用基本的语句表示出来,算法的可行性,比如彩票的预测,是不可行的;几何的证明,计算机业很难实现;问题可以分为:可行性和不可行性

2014-01-13 20:55:22 560

转载 布尔、图灵、冯诺依曼与计算机的关系

学习计算机的,对这三个人的名字不可能陌生,但是这三个人到底对计算机有怎样的贡献,下面一一列出。参考:http://www.china001.com/show_hdr.php?xname=PPDDMV0&dname=87HP341&xpos=5冯·诺依曼奠定了现代计算机的基础,被世人尊为“计算机之父”,但在谈到他的理论与构思时,他谦虚地说,这些理论与构思的基础来自于英国数学家图灵

2014-01-05 18:13:35 15937

原创 组合数学上

组合数学

2013-12-22 13:51:18 313

原创 crack the code interview —— binarytree

#include using namespace std;struct BinaryTreeNode{ int value; BinaryTreeNode * left; BinaryTreeNode * right; BinaryTreeNode(int v) { value = v; left = right =

2013-12-17 22:17:12 430

原创 crack the code interview 4.1

//Implement a function to check if a tree is balanced. For the purposes of this question,//a balanced tree is defined to be a tree such that no two leaf nodes differ in distance//from the root by mo

2013-12-17 22:16:20 602

原创 crack the code interview 3.6

Write a program to sort a stack in ascending order. You should not make any assump-tions about how the stack is implemented. The following are the only functions thatshould be used to write this p

2013-12-17 22:15:35 506

原创 crack the code interview 3.5

//Implement a MyQueue class which implements a queue using two stacks.struct StackNode{ int value; StackNode * next; StackNode(int v) { value = v; next = NULL; }

2013-12-16 21:43:58 428

原创 crack the code interview 3.4

#include using namespace std;struct StackNode{ int value; StackNode * next; StackNode(int v) { value = v; next = NULL; }};class Stack{private: StackNod

2013-12-16 21:27:40 438

原创 crack the code interview 3.3

//Imagine a (literal) stack of plates. If the stack gets too high, it might topple. There-//fore, in real life, we would likely start a new stack when the previous stack exceeds//some threshold. Imp

2013-12-16 20:56:03 561

原创 crack the code interview 3.2

//How would you design a stack which, in addition to push and pop, also has a function//min which returns the minimum element? Push, pop and min should all operate in//O(1) time.#include #define

2013-12-16 19:59:42 573

原创 crack the code interview 3.1

//Describe how you could use a single array to implement three stacks.#include using namespace std;int stackSize = 900;int indexUsed = 0;//已经存放的value的个数int stackTop[3] = {-1, -1, -1};StackNode

2013-12-16 19:22:23 439

原创 C++ 三道题搞定继承

#include using namespace std;class A{ int a;public: A(int i) { a = i; cout<<"A Constructor"<<endl; } void disp() { cout<<"a="<<a<<endl; }};c

2013-12-12 21:57:15 461

原创 bash: ./a.out: Permission denied的问题

写了一个很简单的hello.cpp,但是g++编译的时候:g++ hellp.cpp生成a.out,但是运行./a.out的时候,出错了bash: ./a.out: Permission denied参考stackoverflow:I think, you are trying to run your program on an NTFS partition, different

2013-12-12 21:31:13 1757

原创 C++ 一道题搞定C++构造析构的调用

#include using namespace std;class CSample { char ch1, ch2;public: friend void set(CSample & s, char c1, char c2); CSample(char a, char b) { ch1 = a; ch2 = b;

2013-12-12 21:26:27 621

原创 functional programming 第0周

课程:Functional Programming Principles in Scala by Martin Oderskyhttps://class.coursera.org/progfun-003/class/index配置课程的环境:

2013-12-06 21:31:06 436

原创 人群与社会——第四周

4.1  博弈论的几个要素博弈的条件:情景-》博弈-》求解博弈:必须大于等于2个人进行博弈每个人都是理性的,每个人会选择个人利益最大化,并且他知道别人也是追求利益最大化的。博弈的决策条件:不商量,每个人让自己利益最大化。

2013-12-05 19:29:20 894

原创 crack the code interview 2.5

Given a circular linked list, implement an algorithm which returns node at the begin-ning of the loop.DEFINITIONCircular linked list: A (corrupt) linked list in which a node’s next pointer point

2013-12-04 21:11:31 446

原创 crack the code interview 2.4

You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a function

2013-12-04 19:32:31 507

原创 crack the code interview 2.3

Implement an algorithm to delete a node in the middle of a single linked list, given only access to that node.这道题的意思是这样的,本来我们删除一个节点,需要将上一个节点的next指向这个节点的next,但是能,现在不能对上一个节点进行操作了,只能对这个节点进行操作。那么直接覆盖这个节

2013-12-04 18:09:32 431

原创 crack the code interview 2.2

//Implement an algorithm to find the nth to last element of a singly linked list.struct LinkNode{ LinkNode * next; int value;}LinkNode * findLastN(LinkNode * head, int n){ int i = 1;

2013-12-04 17:54:54 487

原创 crack the code interview 2.1

Write code to remove duplicates from an unsorted linked list.不断的如果当前元素和前面的重复,删除当前元素。struct Node{ Node * next; int value;};void deleteDupNode(Node * head){ if (head == NULL)

2013-12-04 17:42:48 646

pyqt的教程

很简单的教程,照着做就会。中文的,pyqt简单教程

2012-03-08

电话簿软件的实现(动态查找表算法的应用)

一个完整的电话簿软件应具有以下功能: (1)支持复式电话簿数据的存储,数据条目不少于500条。 每个人名下可保存的信息包括:姓名、手机号码、住宅电话号码、办公电话号码、电子邮件地址、所属群组、备忘录等。 (2)支持电话簿记录的添加、删除、编辑等操作。 (3)将不同类型的人群按照同事、朋友、家人、商务伙伴等分组,支持群组记录的添加、删除、编辑等操作。 (4)支持所有电话簿记录的导入、导出操作,外部数据采用TXT格式。 (5)支持电话簿记录的各种查询操作,具体包括: ① 逐条翻看 能显示所有的电话簿记录,支持分屏查看。 ② 电话号码查找 输入一个电话号码(手机、住宅、办公),能将包含该号码的电话簿记录显示出来。 ③ 人名查找 输入一个人名(全名或者部分名),能将包含该姓名的电话簿记录显示出来。 ④ 群组查找 选择一种群组类型,能将属于该群组的所有电话簿记录显示出来。 (6)要求使用BST或者AVL实现动态索引结构。

2011-02-18

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除