
数据结构和算法
xmsheji
这个作者很懒,什么都没留下…
展开
-
Python dict传址 list传值
【代码】Python dict传址 list传值。原创 2022-10-13 18:41:49 · 326 阅读 · 1 评论 -
word2vec中计算两个词的距离或者相似程度。
在word2vec中,有一个默认程序distance,可以用来计算给定词的最相近的top 40个词,但是不能计算给定两个词的相似程度。本程序对distance.c进行了修改,可以计算给定两个词的相似度。程序如下:// Copyright 2013 Google Inc. All Rights Reserved.//// Licensed under the Apache License原创 2016-11-22 11:17:53 · 11424 阅读 · 2 评论 -
测试矩阵乘法的例子
代码如下:import java.util.Date;public class Main { public static void main(String[] args){ float[][] m1=createFloatMatrix(1000,1000); float[][] m2=createFloatMatrix(1000,1000);原创 2015-06-05 15:27:56 · 881 阅读 · 0 评论 -
用回溯算法解决全排列问题
全排列问题的回溯解法:public class Permute { public int N; public int[] X; public static void main(String[] args) { new Permute().test(4); } public void test(int _N){ N=_N;X=new int[N]; for(int原创 2015-06-01 18:37:03 · 1885 阅读 · 0 评论 -
分治算法之快速排序
下面是分治算法的快速排序:public class QuickSort { public static int[] arr; public static void main(String[] args) { arr=new int[]{3,4,2,45,32,5,3,9}; QSort(0,arr.length-1); } public static void QSor原创 2015-06-01 19:59:59 · 1032 阅读 · 0 评论 -
分治算法解决二分查找
二分查找的递归算法:public class BS { public static void main(String[] args) { int[] arr = new int[10]; for (int i = 0; i < arr.length; i++) { arr[i] = (int)(Math.random()*...原创 2015-06-01 19:10:30 · 1422 阅读 · 0 评论 -
N皇后问题的回溯解法
N皇后问题的回溯解法:public class NQueen { static int[] path; static int N; public static void main(String[] args) { test(8); } public static void test(int _N){ N=_N; path=new int[N+1]; backT原创 2015-05-31 21:54:51 · 720 阅读 · 0 评论 -
用回溯法解决0-1背包问题
以下是没有剪枝的算法:public class Knapsack { static double C;//背包容量 static double[] P;//物品价值 static double[] W;//物品重量 static int N;//物品个数 static double bestP; static double currP; static double c原创 2015-05-31 15:52:41 · 766 阅读 · 0 评论 -
图解EM算法
上图是EM算法的一个例子。原创 2014-08-04 21:59:29 · 1621 阅读 · 0 评论 -
马尔科夫链简介
本文简要介绍了马尔科夫链相关内容。马尔科夫链在网页排序,自然语言处理等领域有广泛的应用。原创 2013-08-20 16:17:28 · 2485 阅读 · 0 评论 -
文本相似度算法
<br />在向量空间模型中,文本泛指各种机器可读的记录。用D(Document)表示,特征项(Term,用t表示)是指出现在文档D中且能够代表该文档内容的基本语言单位,主要是由词或者短语构成,文本可以用特征项集表示为D(T1,T2,…,Tn),其中Tk是特征项,1<=k<=N。例如一篇文档中有a、b、c、d四个特征项,那么这篇文档就可以表示为D(a,b,c,d)。对含有n个特征项的文本而言,通常会给每个特征项赋予一定的权重表示其重要程度。即D=D(T1,W1;T2,W2;…,Tn,Wn),简记为D=D(W原创 2011-04-12 13:46:00 · 12880 阅读 · 9 评论