<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
<channel>
<title>CSDN技术网摘 -- wz.csdn.net(算法)</title>
<description>CSDN技术网摘 -- wz.csdn.net(算法)</description>
<link>http://wz.csdn.net/tag-rss/算法/</link>
<generator>CSDN网摘 (http://wz.csdn.net)</generator>
<language>zh-cn</language>
<docs>CSDN网摘 包罗技术精华</docs>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461d49-6a8f-4684-84b6-aceee56c832f.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461d49-6a8f-4684-84b6-aceee56c832f.html</guid>
<category>算法</category>
<pubDate>Tue, 14 Oct 2008 03:21:53 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>majingcn</dc:creator>
</item>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</guid>
<category>算法</category>
<pubDate>Tue, 14 Oct 2008 00:54:34 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>Plastrio</dc:creator>
</item>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461d49-6a8f-4684-84b6-aceee56c832f.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461d49-6a8f-4684-84b6-aceee56c832f.html</guid>
<category>算法</category>
<pubDate>Mon, 13 Oct 2008 09:50:12 GMT</pubDate>
<description><blockquote>算法</blockquote></description>
<dc:creator>jackyvan</dc:creator>
</item>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</guid>
<category>算法</category>
<pubDate>Sun, 12 Oct 2008 05:34:23 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>harry_1523</dc:creator>
</item>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</guid>
<category>算法</category>
<pubDate>Sat, 11 Oct 2008 11:48:37 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>wuxi15932077655</dc:creator>
</item>
<item>
<title>C  基本算法收集，请给出实现代码</title>
<link>http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</guid>
<category>算法</category>
<pubDate>Sat, 11 Oct 2008 03:25:47 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>xcl_ln</dc:creator>
</item>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461d49-6a8f-4684-84b6-aceee56c832f.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461d49-6a8f-4684-84b6-aceee56c832f.html</guid>
<category>微软,算法</category>
<pubDate>Fri, 10 Oct 2008 07:29:46 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>ustcfxx</dc:creator>
</item>
<item>
<title>C  基本算法收集</title>
<link>http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</guid>
<category>C,算法</category>
<pubDate>Fri, 10 Oct 2008 04:57:55 GMT</pubDate>
<description><blockquote>收集了常用的算法，如排序、计算等。</blockquote></description>
<dc:creator>yangreat</dc:creator>
</item>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</guid>
<category>面试,算法</category>
<pubDate>Thu, 09 Oct 2008 09:58:29 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>yuzhiqiang520</dc:creator>
</item>
<item>
<title>四道微软面试算法题</title>
<link>http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20081006/16/75461D49-6A8F-4684-84B6-ACEEE56C832F.html</guid>
<category>算法</category>
<pubDate>Wed, 08 Oct 2008 16:25:46 GMT</pubDate>
<description><blockquote>一个整数数列，元</blockquote></description>
<dc:creator>red_berries</dc:creator>
</item>
<item>
<title>C  基本算法收集</title>
<link>http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</guid>
<category>C,算法</category>
<pubDate>Tue, 07 Oct 2008 13:33:15 GMT</pubDate>
<description><blockquote>收集了常用的算法，如排序、计算等。</blockquote></description>
<dc:creator>bennyfun79</dc:creator>
</item>
<item>
<title>C  基本算法收集，请给出实现代码</title>
<link>http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</guid>
<category>C,C++,算法,小程序</category>
<pubDate>Mon, 06 Oct 2008 02:34:45 GMT</pubDate>
<description><blockquote>3.选择法：
现在我们终于可以看到一点希望：选择法，这种方法提高了一点性能（某些情况下）这种方法类似我们人为的排序习惯：从数据中选择最小的同第一个值交换，在从省下的部分中选择最小的与第二个交换，这样往复下去。
#include 
void SelectSort(int* pData,int Count)
{
    int iTemp; </blockquote></description>
<dc:creator>Joooe</dc:creator>
</item>
<item>
<title>跟波利亚学解题</title>
<link>http://blog.csdn.net/pongba/archive/2008/04/18/2302905.aspx#814800</link>
<guid isPermaLink="true">http://blog.csdn.net/pongba/archive/2008/04/18/2302905.aspx#814800</guid>
<category>算法,思维方式</category>
<pubDate>Sun, 05 Oct 2008 07:21:01 GMT</pubDate>
<description><blockquote>整个博客都值得慢慢看，先收藏一个。</blockquote></description>
<dc:creator>unionfind</dc:creator>
</item>
<item>
<title>C#中国身份证验证　特别收集一些关于身份证验证的算法C＃版 - 净心编程 - CSDNBlog</title>
<link>http://blog.csdn.net/metababy/archive/2008/02/21/2111056.aspx</link>
<guid isPermaLink="true">http://blog.csdn.net/metababy/archive/2008/02/21/2111056.aspx</guid>
<category>算法</category>
<pubDate>Sat, 04 Oct 2008 16:05:08 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>skeeterLa</dc:creator>
</item>
<item>
<title>C  基本算法收集，请给出实现代码</title>
<link>http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</guid>
<category>算法</category>
<pubDate>Sat, 04 Oct 2008 02:32:12 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>kevinlifeng</dc:creator>
</item>
<item>
<title>C  基本算法收集，请给出实现代码</title>
<link>http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</guid>
<category>算法</category>
<pubDate>Tue, 30 Sep 2008 12:50:58 GMT</pubDate>
<description><blockquote>不错的简单算法代码</blockquote></description>
<dc:creator>everbuie</dc:creator>
</item>
<item>
<title>C  基本算法收集，请给出实现代码</title>
<link>http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/14/4e7a079c-21c4-484b-ab80-3785beccd489.html</guid>
<category>c++,算法</category>
<pubDate>Mon, 29 Sep 2008 02:33:00 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>yongshengfree</dc:creator>
</item>
<item>
<title>百度的笔试题，大家讨论一下吧</title>
<link>http://topic.csdn.net/u/20080928/09/caf3b84c-1b15-4dc1-8204-b39b9e6917f2.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080928/09/caf3b84c-1b15-4dc1-8204-b39b9e6917f2.html</guid>
<category>算法</category>
<pubDate>Sun, 28 Sep 2008 14:06:00 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>waterbow</dc:creator>
</item>
<item>
<title>微软面试题五个囚犯 一道真正难倒亿人的智力题,这是微软的面试题。</title>
<link>http://topic.csdn.net/u/20080927/17/dec430f4-4b39-4aa1-8499-e25ae4d699f0.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080927/17/dec430f4-4b39-4aa1-8499-e25ae4d699f0.html</guid>
<category>算法</category>
<pubDate>Sun, 28 Sep 2008 14:05:11 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>Sunpy11</dc:creator>
</item>
<item>
<title>MMX版本的Alpha Blend算法实现 - GameRes.com</title>
<link>http://dev.gameres.com/Program/Visual/2D/mmxaddalpha.htm</link>
<guid isPermaLink="true">http://dev.gameres.com/Program/Visual/2D/mmxaddalpha.htm</guid>
<category>算法</category>
<pubDate>Fri, 26 Sep 2008 01:35:05 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>benny5609</dc:creator>
</item>
<item>
<title>奇偶换位问题</title>
<link>http://topic.csdn.net/u/20071203/20/4dd4e19e-37bb-42eb-9b13-a388906d9eab.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20071203/20/4dd4e19e-37bb-42eb-9b13-a388906d9eab.html</guid>
<category>算法,数据结构</category>
<pubDate>Thu, 25 Sep 2008 11:48:44 GMT</pubDate>
<description><blockquote>算法 数据结构</blockquote></description>
<dc:creator>insulted</dc:creator>
</item>
<item>
<title>数据结构与算法-面向对象的C  设计模式 CSDN 下载频道</title>
<link>http://download.csdn.net/source/176702</link>
<guid isPermaLink="true">http://download.csdn.net/source/176702</guid>
<category>数据结构,算法,面向对象</category>
<pubDate>Thu, 25 Sep 2008 09:35:10 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>swungle</dc:creator>
</item>
<item>
<title>GCC中SIMD指令的应用方法_想飞的翅膀</title>
<link>http://hi.baidu.com/guozhudu/blog/item/76958511ee669e7fca80c4ba.html</link>
<guid isPermaLink="true">http://hi.baidu.com/guozhudu/blog/item/76958511ee669e7fca80c4ba.html</guid>
<category>算法</category>
<pubDate>Thu, 25 Sep 2008 07:50:02 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>benny5609</dc:creator>
</item>
<item>
<title>用SIMD指令优化程序之抛砖引玉_斯卡佩尔</title>
<link>http://hi.baidu.com/tjpuwz/blog/item/644740f0fe12f6c27931aa4a.html</link>
<guid isPermaLink="true">http://hi.baidu.com/tjpuwz/blog/item/644740f0fe12f6c27931aa4a.html</guid>
<category>算法</category>
<pubDate>Thu, 25 Sep 2008 07:48:00 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>benny5609</dc:creator>
</item>
<item>
<title>发挥缓存的威力,提高代码效率,及如何实现16位浮点数 - sundeepblue - 博客园</title>
<link>http://www.cnblogs.com/sundeepblue/archive/2007/08/10/850388.html</link>
<guid isPermaLink="true">http://www.cnblogs.com/sundeepblue/archive/2007/08/10/850388.html</guid>
<category>算法</category>
<pubDate>Thu, 25 Sep 2008 07:34:44 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>benny5609</dc:creator>
</item>
<item>
<title>快速求平方根的算法 - sundeepblue - 博客园</title>
<link>http://www.cnblogs.com/sundeepblue/archive/2007/07/31/837532.html</link>
<guid isPermaLink="true">http://www.cnblogs.com/sundeepblue/archive/2007/07/31/837532.html</guid>
<category>算法</category>
<pubDate>Thu, 25 Sep 2008 07:34:08 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>benny5609</dc:creator>
</item>
<item>
<title>使用SIMD指令高度优化Matrix类(in C  ) - sundeepblue - 博客园</title>
<link>http://www.cnblogs.com/sundeepblue/archive/2007/08/10/850499.html</link>
<guid isPermaLink="true">http://www.cnblogs.com/sundeepblue/archive/2007/08/10/850499.html</guid>
<category>算法</category>
<pubDate>Thu, 25 Sep 2008 07:33:19 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>benny5609</dc:creator>
</item>
<item>
<title>{ a_1, a_2, ..., a_{2n} } --&gt; { a_1, a_3, ..., a_{2n-1}, a_2, a_4, ..., a_{2n} }</title>
<link>http://topic.csdn.net/u/20071120/13/6a846dc9-0840-4072-a6b8-51420a2c34af.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20071120/13/6a846dc9-0840-4072-a6b8-51420a2c34af.html</guid>
<category>完美洗牌,Job,算法</category>
<pubDate>Thu, 25 Sep 2008 06:13:27 GMT</pubDate>
<description><blockquote>完美洗牌 Job 算法</blockquote></description>
<dc:creator>insulted</dc:creator>
</item>
<item>
<title>qsort完整版</title>
<link>http://blog.sina.com.cn/s/blog_465ff7f1010004op.html</link>
<guid isPermaLink="true">http://blog.sina.com.cn/s/blog_465ff7f1010004op.html</guid>
<category>qsort,算法,教程</category>
<pubDate>Wed, 24 Sep 2008 17:16:52 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>jaywee</dc:creator>
</item>
<item>
<title>【改进】BP算法及其C语言实现分析 - jiazhen的专栏 - CSDNBlog</title>
<link>http://blog.csdn.net/jiazhen/archive/2008/04/16/2296291.aspx</link>
<guid isPermaLink="true">http://blog.csdn.net/jiazhen/archive/2008/04/16/2296291.aspx</guid>
<category>算法</category>
<pubDate>Wed, 24 Sep 2008 08:51:10 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>benny5609</dc:creator>
</item>
<item>
<title>算法竞赛：图片模式识别------如何在屏幕截图中识别一个中国象棋棋盘的位置。（寻找两个米字的位置）</title>
<link>http://topic.csdn.net/u/20080916/11/9D3EE55B-A598-4F9E-9D43-343D6B226156.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080916/11/9D3EE55B-A598-4F9E-9D43-343D6B226156.html</guid>
<category>算法</category>
<pubDate>Tue, 23 Sep 2008 14:34:45 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>suifeng08</dc:creator>
</item>
<item>
<title>如何判断3个文件的相似度？怎么设计算法？</title>
<link>http://topic.csdn.net/u/20080915/22/21209056-47D0-4C62-9D0C-C1CAFABB2555.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080915/22/21209056-47D0-4C62-9D0C-C1CAFABB2555.html</guid>
<category>算法</category>
<pubDate>Tue, 23 Sep 2008 06:44:04 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>aldenphy</dc:creator>
</item>
<item>
<title>在线好友列表与数据结构(2) - Radix Tree</title>
<link>http://hi.baidu.com/jabber/blog/item/757873f41230f5dff3d3853c.html</link>
<guid isPermaLink="true">http://hi.baidu.com/jabber/blog/item/757873f41230f5dff3d3853c.html</guid>
<category>算法</category>
<pubDate>Mon, 22 Sep 2008 10:35:59 GMT</pubDate>
<description><blockquote>Radix Tree 是如图所示一种数据结构，对于小量范围有一定相似度的字符串具有较高的insert/delete/lookup性能。它的这几个操作算法复杂度是 O(k), k指key长度。与hash table相比，虽然O(k) &gt; O(1)。但是 hash table的O(1)没有考虑计算hash所需时间及hash冲突的时间。因此在某些情况下Radix Tree性能比hash table好也不足为奇。</blockquote></description>
<dc:creator>zdg</dc:creator>
</item>
<item>
<title>在线好友状态列表与数据结构(1)</title>
<link>http://hi.baidu.com/jabber/blog/item/b4becbfd3b4d0243d6887da1.html</link>
<guid isPermaLink="true">http://hi.baidu.com/jabber/blog/item/b4becbfd3b4d0243d6887da1.html</guid>
<category>算法</category>
<pubDate>Mon, 22 Sep 2008 10:35:29 GMT</pubDate>
<description><blockquote>在一个典型的IM Server上，每个登录的用户都需要维护一份自己在线用户列表，需要频繁进行以下操作

iterate
循环与遍历，很多操作需要调用iterator

insert/delete
由于在线的好友随时会产生上下线的变化，所以需要增加或删除列表的内容。

lookup 
同时由于列表的元素需要保持唯一性，insert时候也需要查找已有的元素是否存在。

同时还具有以下一些特性

长度
在线的好友列表不会太长，通常都是几十个。</blockquote></description>
<dc:creator>zdg</dc:creator>
</item>
<item>
<title>几个经典的博弈问题 - 道虽远，不行不至 - JavaEye技术网站</title>
<link>http://eastsun.javaeye.com/blog/65615</link>
<guid isPermaLink="true">http://eastsun.javaeye.com/blog/65615</guid>
<category>算法,博弈</category>
<pubDate>Sun, 21 Sep 2008 06:05:47 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>jaywee</dc:creator>
</item>
<item>
<title>请教大家intel关于指针的笔试题(大家一起来讨论下)</title>
<link>http://community.csdn.net/Expert/topicview.asp?id=5730460</link>
<guid isPermaLink="true">http://community.csdn.net/Expert/topicview.asp?id=5730460</guid>
<category>C++,算法</category>
<pubDate>Fri, 12 Sep 2008 09:05:25 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>一位编程高手总结的经典算法：KMP和BM算法的ANSI C实现，大家感兴趣的都来参考一下</title>
<link>http://community.csdn.net/Expert/topicview.asp?id=5378401</link>
<guid isPermaLink="true">http://community.csdn.net/Expert/topicview.asp?id=5378401</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:05:07 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>分治法优化大整数乘法 C++实现</title>
<link>http://blog.csdn.net/dzfb/archive/2005/10/16/505113.aspx</link>
<guid isPermaLink="true">http://blog.csdn.net/dzfb/archive/2005/10/16/505113.aspx</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:02:33 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>鲲鹏学习--大整运算</title>
<link>http://www.nsk.ik8.com/article/c/02/021.html</link>
<guid isPermaLink="true">http://www.nsk.ik8.com/article/c/02/021.html</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:02:19 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>百度曾经考试过的一个算法题：从2.5亿个数字里面找出不重复的数字的个数</title>
<link>http://topic.csdn.net/u/20070929/14/b183cd03-d780-4c59-a666-ab127f12f7b1.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20070929/14/b183cd03-d780-4c59-a666-ab127f12f7b1.html</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:01:59 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>近年来出现的概率类问题的一个总结（二）——扑克类</title>
<link>http://topic.csdn.net/u/20080713/02/23E56D3C-2DAC-49DB-94A8-E4B07166D98F.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080713/02/23E56D3C-2DAC-49DB-94A8-E4B07166D98F.html</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:01:47 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>从100万个整数里找出100个最大的数</title>
<link>http://topic.csdn.net/u/20080725/15/15ff0ed1-0482-4af6-9e41-bcbf960056eb.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080725/15/15ff0ed1-0482-4af6-9e41-bcbf960056eb.html</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:01:15 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>位运算常用操作总结</title>
<link>http://topic.csdn.net/u/20080729/03/49D36E50-6432-48AF-8FE8-79FA24CE152E.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080729/03/49D36E50-6432-48AF-8FE8-79FA24CE152E.html</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:01:10 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>利用数组实现大数乘法 - Jeffrey.zhu - CSDNBlog</title>
<link>http://blog.csdn.net/gueter/archive/2008/08/04/2766572.aspx</link>
<guid isPermaLink="true">http://blog.csdn.net/gueter/archive/2008/08/04/2766572.aspx</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:00:50 GMT</pubDate>
<description><blockquote>利用数组实现大数乘法</blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>google面试题及我的算法（2）——0~n之间1的个数（完美版） - 三二一（小鱼） 算法爱好者的家园 - CSDNBlog</title>
<link>http://blog.csdn.net/livelylittlefish/archive/2008/08/05/2768348.aspx</link>
<guid isPermaLink="true">http://blog.csdn.net/livelylittlefish/archive/2008/08/05/2768348.aspx</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 09:00:43 GMT</pubDate>
<description><blockquote>0~n之间1的个数</blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>一种同步消息队列模型 - 长江七号</title>
<link>http://blog.chinaunix.net/u1/52242/showart_725095.html</link>
<guid isPermaLink="true">http://blog.chinaunix.net/u1/52242/showart_725095.html</guid>
<category>算法,队列</category>
<pubDate>Fri, 12 Sep 2008 09:00:29 GMT</pubDate>
<description><blockquote>一种同步消息队列模型
 
 
 
    在已故巨匠Stevens先生中的&lt;&gt;中有记载使用互斥锁和条件变量来解决生产者/消费者的方法，在多线程编程中，我们也常常需要解决这样的生产者消费者问题。在实际项目中，我见到过很多种解决类似问题的同步消息队列，有的复杂而优雅，有得简陋而实用。
    对于生产者，如果不考虑内存和队列的大小问题，只需要一直往消息队列里推消息就可以了。而对于消费者就要复杂一点了，在消息队列取空后，消费者可以循环轮询队列，直到取到新的消息，这种方式编码简单，但是浪费CPU时间片;  更加优雅的方法是当消息队列为空时，将消费者挂起，等到有消息可读时再唤醒。
    这里引用Stevens先生的方法，使用互斥锁和信号量实现了一个简单的同步消息队列模型。
 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std; 

template
class Message_Queue
{
public:
    //构造函数，初始化2个互斥锁和1个条件变量

    Message_Queue():_nready(0)
    {
     pthread_mutex_init(&amp;_mutex, NULL); 
     pthread_mutex_init(&amp;_ready_mutex, NULL); 
     pthread_cond_init(&amp;_cond, NULL); 
    }

    //推消息

    int push_msg(DataType &amp;d)
    {
        //加锁_mutex，向queue里推消息

        pthread_mutex_lock(&amp;_mutex);  
        _queue.push_back(d); 
        pthread_mutex_unlock(&amp;_mutex); 

        //加锁_ready_mutex，判断是否需要唤醒挂起的消费者

        pthread_mutex_lock(&amp;_ready_mutex); 
        if (!_nready)
            pthread_cond_signal(&amp;_cond);  //唤醒阻塞在此消息队列上的消费者

        _nready++;  //计数器++

        pthread_mutex_unlock(&amp;_ready_mutex); 
        
        return 0;         
    }
    //取消息

    int get_msg(DataType &amp;d)
    {
        //加锁，查看计数器，看是否需要挂起

        pthread_mutex_lock(&amp;_ready_mutex); 
        while (_nready == 0) //计数器为0，队列为空，挂起
              pthread_cond_wait(&amp;_cond, &amp;_ready_mutex);  //为空时，所有消费者会阻塞在此

        //当被生产者唤醒时，消费者重新加_ready_mutex锁，_nready &gt; 0, 程序跳出while(_nready)循环继续运行

        _nready--; 
        pthread_mutex_unlock(&amp;_ready_mutex); 
        
        //加锁，取队列操作

        pthread_mutex_lock(&amp;_mutex);  
        d = _queue.front(); 
        _queue.pop_front(); 
        pthread_mutex_unlock(&amp;_mutex); 

        return 0; 
    }

private:
    pthread_cond_t     _cond; 
    int                 _nready; 
    pthread_mutex_t     _ready_mutex; 
    pthread_mutex_t     _mutex; 
    deque _queue; 
}; 


//测试程序，模拟N个生产者和M个消费者使用消息队列同时工作的情况。

void *consume(void *arg) //消费者线程

{
    Message_Queue *queue = (Message_Queue *)arg; 
    int    i; 
    for (;  ;  )
    {
        sleep(1); 
        printf(&quot;[%u]ready to get_msg\n&quot;, pthread_self()); 
        queue-&gt;get_msg(i); 
        printf(&quot;[%u]get msg = %d\n&quot;, pthread_self(), i); 
    }

}
void *produce(void *arg) //生产者线程

{
    Message_Queue *queue = (Message_Queue *)arg; 
    int    i; 
    for (;  ;  )
    {
        sleep(1); 
        printf(&quot;[%u]ready to push_msg\n&quot;, pthread_self()); 
        queue-&gt;push_msg(i); 
        printf(&quot;[%u]push_msg finished\n&quot;, pthread_self()); 
        i++; 
    }
}

int main()
{

    Message_Queue msg_queue; 

    int    n ; 
    int c = 2; 
    int p = 3; 
    pthread_t    k; 
    printf(&quot;create %d consume................\n&quot;, c); 
    for (n=0;  n&lt; c;  n++)
    {
        pthread_create(&amp;k, NULL, consume, &amp;msg_queue); 
    }
    printf(&quot;create %d produce.............\n&quot;, p); 
    for (n=0;  n&lt; p;  n++)
    {
        pthread_create(&amp;k, NULL, produce, &amp;msg_queue); 
    }

    pause(); 
}

 

    这样，我们对STL的deque 进行一个简单的封装，就获得了一个可用的同步消息队列。这里需要提及的是，一次pthread_cond_signal操作会唤醒所有阻塞在此条件变量上的消费者，而所有阻塞在pthread_cond_wait上的消费者被唤醒，这就是所谓“惊群”。而被唤醒的所有消费者都会去竞争_ready_mutex锁，这就是所谓“二次竞争”。这样的“惊群”和“二次竞争”在各个平台上是否存在，对性能的影响有多大，我没有验证过，只是一种猜测，不过相信这样的模型满足一般的应用程序应该没有问题。</blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>算法大家想</title>
<link>http://topic.csdn.net/u/20080805/15/2708be03-9df0-43cc-9df1-7889a2ccd5f8.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080805/15/2708be03-9df0-43cc-9df1-7889a2ccd5f8.html</guid>
<category>统计重复子串,算法</category>
<pubDate>Fri, 12 Sep 2008 09:00:09 GMT</pubDate>
<description><blockquote>统计重复子串</blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>如何求得二进制数中“1”的个数</title>
<link>http://topic.csdn.net/u/20080807/13/b2ced13a-2ed1-4bd6-87fd-09d35374a985.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080807/13/b2ced13a-2ed1-4bd6-87fd-09d35374a985.html</guid>
<category>算法</category>
<pubDate>Fri, 12 Sep 2008 08:59:33 GMT</pubDate>
<description><blockquote>如何求得二进制数中“1”的个数</blockquote></description>
<dc:creator>perfectpdl</dc:creator>
</item>
<item>
<title>求一个简单的递归程序</title>
<link>http://topic.csdn.net/u/20080904/23/29d874d1-4bc2-4496-a04e-111db47cd054.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080904/23/29d874d1-4bc2-4496-a04e-111db47cd054.html</guid>
<category>java,递归,算法</category>
<pubDate>Thu, 11 Sep 2008 12:50:51 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>jaywee</dc:creator>
</item>
<item>
<title>【算法比赛】打印有变化规律的数字正方形，看谁的代码扩展性、可读性最好。</title>
<link>http://topic.csdn.net/u/20080826/13/9E609334-2688-49CC-B0BF-B93534D3F78B.html</link>
<guid isPermaLink="true">http://topic.csdn.net/u/20080826/13/9E609334-2688-49CC-B0BF-B93534D3F78B.html</guid>
<category>算法</category>
<pubDate>Thu, 11 Sep 2008 03:04:33 GMT</pubDate>
<description><blockquote></blockquote></description>
<dc:creator>xieminemma</dc:creator>
</item>
</channel></rss>
