<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>阅微客栈: 最新帖子</title>
<link>http://zhiqiang.org/bbs/</link>
<description>阅微客栈: 最新帖子</description>
<language>en</language>
<pubDate>Sun, 12 Oct 2008 22:33:34 +0000</pubDate>

<item>
<title>sevear 在 "给一些不同的正整数和ｍ，求所有ａ，ｂ使得ａ＋ｂ＝ｍ"</title>
<link>http://zhiqiang.org/bbs/topic/76#post-258</link>
<pubDate>星期四, 09 Oct 2008 13:47:32 +0000</pubDate>
<dc:creator>sevear</dc:creator>
<guid isPermaLink="false">258@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;嗯，排序后查找是啥意思
&#60;/p&#62;</description>
</item>
<item>
<title>szuxjq 在 "给一些不同的正整数和ｍ，求所有ａ，ｂ使得ａ＋ｂ＝ｍ"</title>
<link>http://zhiqiang.org/bbs/topic/76#post-257</link>
<pubDate>星期四, 09 Oct 2008 03:37:06 +0000</pubDate>
<dc:creator>szuxjq</dc:creator>
<guid isPermaLink="false">257@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;&#34;标记数是否出现过&#34;? 复杂度为　O(n)? 不是很明白哦
&#60;/p&#62;</description>
</item>
<item>
<title>zhang 在 "构造最小深度树"</title>
<link>http://zhiqiang.org/bbs/topic/77#post-256</link>
<pubDate>星期四, 09 Oct 2008 00:44:43 +0000</pubDate>
<dc:creator>zhang</dc:creator>
<guid isPermaLink="false">256@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;已知一颗无向无环连通图T的所有顶点和边的信息，现需要将其转换为一棵树，要求树的深度最小，请设计一个算法找到所有满足要求的树的根结点，并分析时空复杂度（描述算法即可，无需代码）&#60;/p&#62;
&#60;p&#62;算法：两次深度优先求出Ｔ的直径，直径中间的两点即为所求。
&#60;/p&#62;</description>
</item>
<item>
<title>zhang 在 "给一些不同的正整数和ｍ，求所有ａ，ｂ使得ａ＋ｂ＝ｍ"</title>
<link>http://zhiqiang.org/bbs/topic/76#post-255</link>
<pubDate>星期四, 09 Oct 2008 00:43:07 +0000</pubDate>
<dc:creator>zhang</dc:creator>
<guid isPermaLink="false">255@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;排序后查找　O(n\log n).&#60;/p&#62;
&#60;p&#62;空间换时间，使用ｍ长数组标记数是否出现过，不计算分配空间消耗的时间外，复杂度为　O(n).
&#60;/p&#62;</description>
</item>
<item>
<title>zhang 在 "关于STL里重排数组算法random_shuffle()"</title>
<link>http://zhiqiang.org/bbs/topic/71#post-254</link>
<pubDate>星期一, 29 Sep 2008 13:21:00 +0000</pubDate>
<dc:creator>zhang</dc:creator>
<guid isPermaLink="false">254@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;这个先给我们讲讲函数都是啥意思吧，我还看不懂这些源代码。
&#60;/p&#62;</description>
</item>
<item>
<title>szuxjq 在 "求一个缺失的数"</title>
<link>http://zhiqiang.org/bbs/topic/74#post-253</link>
<pubDate>星期五, 26 Sep 2008 01:34:07 +0000</pubDate>
<dc:creator>szuxjq</dc:creator>
<guid isPermaLink="false">253@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;这种题目我老是没思路~~
&#60;/p&#62;</description>
</item>
<item>
<title>zhang 在 "找重复的数 - MSRA面试题"</title>
<link>http://zhiqiang.org/bbs/topic/75#post-252</link>
<pubDate>星期二, 23 Sep 2008 05:33:26 +0000</pubDate>
<dc:creator>zhang</dc:creator>
<guid isPermaLink="false">252@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;题目是这样的，给定一个包含4300000000个32位整数的顺序文件，请问如何找到一个至少出现两次的整数？&#60;/p&#62;
&#60;p&#62;顺序文件，不允许随机访问。
&#60;/p&#62;</description>
</item>
<item>
<title>zhang 在 "求一个缺失的数"</title>
<link>http://zhiqiang.org/bbs/topic/74#post-251</link>
<pubDate>星期二, 23 Sep 2008 05:31:41 +0000</pubDate>
<dc:creator>zhang</dc:creator>
<guid isPermaLink="false">251@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;给你很多很多数（32位整数），求一个不在这些数里的数（亦为32位整数）
&#60;/p&#62;</description>
</item>
<item>
<title>zhang 在 "求运算次数 - 百度面试题"</title>
<link>http://zhiqiang.org/bbs/topic/73#post-250</link>
<pubDate>星期二, 23 Sep 2008 05:30:23 +0000</pubDate>
<dc:creator>zhang</dc:creator>
<guid isPermaLink="false">250@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;简述：实现一个函数，对一个正整数n,算得到1需要的最少操作次数：&#60;/p&#62;
&#60;p&#62;如果n为偶数，将其处以2；&#60;/p&#62;
&#60;p&#62;如果n为奇数，可以加1或减1；&#60;/p&#62;
&#60;p&#62;一直处理下去。&#60;/p&#62;
&#60;p&#62;求最小运算次数。
&#60;/p&#62;</description>
</item>
<item>
<title>king 在 "关于STL里重排数组算法random_shuffle()"</title>
<link>http://zhiqiang.org/bbs/topic/71#post-248</link>
<pubDate>星期一, 07 Jul 2008 12:42:14 +0000</pubDate>
<dc:creator>king</dc:creator>
<guid isPermaLink="false">248@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;源码如下：&#60;br /&#62;
template &#38;lt;class RandomAccessIterator, class Distance&#38;gt;&#60;br /&#62;
void __random_shuffle(RandomAccessIterator first, RandomAccessIterator last,&#60;br /&#62;
                      Distance*) {&#60;br /&#62;
  if (first == last) return;&#60;br /&#62;
  for (RandomAccessIterator i = first + 1; i != last; ++i)&#60;br /&#62;
#ifdef __STL_NO_DRAND48&#60;br /&#62;
    iter_swap(i, first + Distance(rand() % ((i - first) + 1)));&#60;br /&#62;
#else&#60;br /&#62;
  iter_swap(i, first + Distance(lrand48() % ((i - first) + 1)));&#60;br /&#62;
#endif&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;这里的iter_swap(i, first + Distance(rand() % ((i - first) + 1)));能否保证数组是均匀的重排呢？&#60;br /&#62;
如何保证？
&#60;/p&#62;</description>
</item>
<item>
<title>Yuanyuan 在 "Amazon面试题：八个球中找出重量不同的一个"</title>
<link>http://zhiqiang.org/bbs/topic/20#post-247</link>
<pubDate>星期二, 24 Jun 2008 06:57:18 +0000</pubDate>
<dc:creator>Yuanyuan</dc:creator>
<guid isPermaLink="false">247@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;看了半天，终于找到一个简单的了，hahahaha&#60;/p&#62;
&#60;p&#62;八个秋，一边放四个，看指针往那边倾斜····然后再这样称几次就好了&#60;/p&#62;
&#60;p&#62;a piece of cake :-)
&#60;/p&#62;</description>
</item>
<item>
<title>Yuanyuan 在 "据说是google的电面题目"</title>
<link>http://zhiqiang.org/bbs/topic/40#post-246</link>
<pubDate>星期二, 24 Jun 2008 06:53:13 +0000</pubDate>
<dc:creator>Yuanyuan</dc:creator>
<guid isPermaLink="false">246@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;。。。。。。。。。。。
&#60;/p&#62;</description>
</item>
<item>
<title>Yuanyuan 在 "魔方相邻格子能否不同色？"</title>
<link>http://zhiqiang.org/bbs/topic/69#post-245</link>
<pubDate>星期二, 24 Jun 2008 06:51:34 +0000</pubDate>
<dc:creator>Yuanyuan</dc:creator>
<guid isPermaLink="false">245@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;应该可以吧····
&#60;/p&#62;</description>
</item>
<item>
<title>Yuanyuan 在 "微软面试题 - 找路径条数"</title>
<link>http://zhiqiang.org/bbs/topic/46#post-244</link>
<pubDate>星期二, 24 Jun 2008 06:50:50 +0000</pubDate>
<dc:creator>Yuanyuan</dc:creator>
<guid isPermaLink="false">244@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;呵呵呵呵····还是不会····
&#60;/p&#62;</description>
</item>
<item>
<title>Yuanyuan 在 "Amazon面试题 - 找最短的cover"</title>
<link>http://zhiqiang.org/bbs/topic/38#post-243</link>
<pubDate>星期二, 24 Jun 2008 06:49:17 +0000</pubDate>
<dc:creator>Yuanyuan</dc:creator>
<guid isPermaLink="false">243@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;额滴神呀~~~~&#60;br /&#62;
看着有点像数列，&#60;br /&#62;
嗯·····sorry ,i don't know ...
&#60;/p&#62;</description>
</item>
<item>
<title>521zheng 在 "算法 - 旋转数组"</title>
<link>http://zhiqiang.org/bbs/topic/47#post-242</link>
<pubDate>星期二, 03 Jun 2008 07:35:00 +0000</pubDate>
<dc:creator>521zheng</dc:creator>
<guid isPermaLink="false">242@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;先整个数组旋转，再分别旋转前k和后n-k个
&#60;/p&#62;</description>
</item>
<item>
<title>zhiqiang 在 "尺规作图问题"</title>
<link>http://zhiqiang.org/bbs/topic/70#post-241</link>
<pubDate>星期六, 24 May 2008 02:22:17 +0000</pubDate>
<dc:creator>zhiqiang</dc:creator>
<guid isPermaLink="false">241@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;给你一个三角形ABC，请用圆规和尺找出点P，保证三角形ABP、ACP和BCP周长相等&#60;br /&#62;
。
&#60;/p&#62;</description>
</item>
<item>
<title>apunix 在 "微软面试题 - 找路径条数"</title>
<link>http://zhiqiang.org/bbs/topic/46#post-240</link>
<pubDate>星期二, 20 May 2008 01:07:15 +0000</pubDate>
<dc:creator>apunix</dc:creator>
<guid isPermaLink="false">240@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;void FindPath(Graph&#38;#38; G, int v, int vj, Edge* &#38;#38;path, int l) //G是图，v是当前结点，vj是目标结点，path保存当前路径的数组，l是当前路径的长度&#60;br /&#62;
{&#60;br /&#62;
    if(v == vj)&#60;br /&#62;
    {&#60;br /&#62;
        printPath(path, l);&#60;br /&#62;
        return;&#60;br /&#62;
    }&#60;br /&#62;
    for(Edge e = G.FirstEdge(v); G.IsEdge(e); e = G.NextEdge(e))&#60;br /&#62;
    {&#60;br /&#62;
         if(!InPath(G.ToVetex(e))) { //Inpath判断下一搜索结点是否已经在路径中出现过&#60;br /&#62;
             l++;&#60;br /&#62;
           path[l] = G.ToVetex(e);&#60;br /&#62;
           FindPath(G, G.ToVetex(e), vj, path, l);&#60;br /&#62;
           l--; //恢复路径&#60;br /&#62;
     }&#60;br /&#62;
}&#60;br /&#62;
就是一个回溯法搜索的过程
&#60;/p&#62;</description>
</item>
<item>
<title>zhshlin 在 "魔方相邻格子能否不同色？"</title>
<link>http://zhiqiang.org/bbs/topic/69#post-239</link>
<pubDate>星期日, 27 Apr 2008 05:31:05 +0000</pubDate>
<dc:creator>zhshlin</dc:creator>
<guid isPermaLink="false">239@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;yes you can
&#60;/p&#62;</description>
</item>
<item>
<title>szuxjq 在 "魔方相邻格子能否不同色？"</title>
<link>http://zhiqiang.org/bbs/topic/69#post-234</link>
<pubDate>星期六, 26 Apr 2008 04:22:09 +0000</pubDate>
<dc:creator>szuxjq</dc:creator>
<guid isPermaLink="false">234@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;从原始的一面一色状态的魔方，能否扭转到任两相邻格子都是不同的颜色呢？
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "微软面试题 - 找路径条数"</title>
<link>http://zhiqiang.org/bbs/topic/46#post-233</link>
<pubDate>星期日, 13 Apr 2008 16:20:31 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">233@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;反向迭代，有点类似与dijkstra求最短路径
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "算法 - 旋转数组"</title>
<link>http://zhiqiang.org/bbs/topic/47#post-232</link>
<pubDate>星期日, 13 Apr 2008 16:16:41 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">232@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;生成元就是前gcd(n,k)个数
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "判断一个图是否为一个二叉树"</title>
<link>http://zhiqiang.org/bbs/topic/59#post-231</link>
<pubDate>星期日, 13 Apr 2008 16:10:32 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">231@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;v=e+1&#60;br /&#62;
d(v)&#38;lt;=3
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "自然数按一定运算变为1的运算次数"</title>
<link>http://zhiqiang.org/bbs/topic/61#post-230</link>
<pubDate>星期日, 13 Apr 2008 16:05:18 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">230@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;zhang 的算法对3来说就不是最优。 得稍微修改一下。从高位做， 对于第一段连续的1，如果个数&#38;gt;3用＋1除以2，&#38;lt;3用-1除以2。 以后的连续1段用 zhang的策略就行
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "求部分有序的数列的中位数"</title>
<link>http://zhiqiang.org/bbs/topic/62#post-229</link>
<pubDate>星期日, 13 Apr 2008 15:47:51 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">229@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;另外，两组长为n的各自有序的数组，找到在两者里面第k大的成员， 时间复杂度是lgk * lgk
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "求部分有序的数列的中位数"</title>
<link>http://zhiqiang.org/bbs/topic/62#post-228</link>
<pubDate>星期日, 13 Apr 2008 15:46:23 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">228@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;wsamc 的算法还可进一步优化：如果sum(a的位置) &#38;gt; n^2/2，将所有 {i &#124; ai&#38;gt;=a } 所对应的序列长度减半. 可改成：将所有 {i &#124; ai&#38;gt;=a }  和 {i &#124; i&#38;lt; a的位置-(sum(a的位置)-n^2/2) } 剪去
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "算法 - 均分数组"</title>
<link>http://zhiqiang.org/bbs/topic/49#post-227</link>
<pubDate>星期日, 13 Apr 2008 08:15:04 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">227@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;其实就是子集和问题。&#60;br /&#62;
mathena 说对了，他们的平均值, 就是数组的平均值.&#60;br /&#62;
把数组中所有数都减去数组的平均值，  这样问题就变成 求一个子集其和为0的问题。
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "Amazon面试题 - 找最短的cover"</title>
<link>http://zhiqiang.org/bbs/topic/38#post-226</link>
<pubDate>星期日, 13 Apr 2008 07:32:23 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">226@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;LCS ＋ 标记起始位置
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "找缺失的数"</title>
<link>http://zhiqiang.org/bbs/topic/58#post-225</link>
<pubDate>星期日, 13 Apr 2008 07:15:38 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">225@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;判断第一位是0 or 1，并计数，根据计数和n的奇偶性来判断缺失的数所在的集合&#60;br /&#62;
继续判断第二位。。。。。&#60;/p&#62;
&#60;p&#62;复杂度 n + n/2 + n/4 + .. &#38;lt; 2n
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "数组中元素和最接近于0的子数组"</title>
<link>http://zhiqiang.org/bbs/topic/67#post-224</link>
<pubDate>星期日, 13 Apr 2008 06:50:47 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">224@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;转化成全连通有向图，再用floyd算法（判定条件改成abs最小)，注意排除回路。 时间复杂度应该是O(n^3).  Wanting的算法没仔细看。 不过，感觉这个问题不大可能有O(n^2)的解
&#60;/p&#62;</description>
</item>
<item>
<title>szuxjq 在 "数组中元素和最接近于0的子数组"</title>
<link>http://zhiqiang.org/bbs/topic/67#post-223</link>
<pubDate>星期六, 12 Apr 2008 08:33:48 +0000</pubDate>
<dc:creator>szuxjq</dc:creator>
<guid isPermaLink="false">223@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;to Wanting&#60;/p&#62;
&#60;p&#62;老兄你blabla写这么多代码，看晕眼啊。写个算法描述和复杂度出来就得了嘛。对于一维数组，显然有线性复杂度的解法。对于二维数组，别的帖子有讨论。
&#60;/p&#62;</description>
</item>
<item>
<title>szuxjq 在 "How to in-place right-rotate a two dimensional array?"</title>
<link>http://zhiqiang.org/bbs/topic/68#post-222</link>
<pubDate>星期六, 12 Apr 2008 05:01:06 +0000</pubDate>
<dc:creator>szuxjq</dc:creator>
<guid isPermaLink="false">222@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;某知名网站的讨论，&#60;br /&#62;
For example, given a MxN (3x4) two dimensional array&#60;/p&#62;
&#60;p&#62;1, 2, 3, 4&#60;br /&#62;
5, 6, 7, 8&#60;br /&#62;
9,10,11,12&#60;/p&#62;
&#60;p&#62;You need to rearrange it into:&#60;/p&#62;
&#60;p&#62;9 , 5, 1,&#60;br /&#62;
10, 6, 2,&#60;br /&#62;
11, 7, 3,&#60;br /&#62;
12, 8, 4&#60;/p&#62;
&#60;p&#62;Write a function to do it in-place. &#60;/p&#62;
&#60;p&#62;e.g. M=3, N=4, and a memory block contains:&#60;br /&#62;
[1,2,3,4,5,6,7,8,9,10,11,12]&#60;/p&#62;
&#60;p&#62;You need to change the memory block into&#60;br /&#62;
[9,5,1,10,6,2,11,7,3,12,8,4]&#60;/p&#62;
&#60;p&#62;&#34;In-place&#34; means memory constaint is O(1).
&#60;/p&#62;</description>
</item>
<item>
<title>lemonutzf 在 "据说是google的电面题目"</title>
<link>http://zhiqiang.org/bbs/topic/40#post-221</link>
<pubDate>星期五, 11 Apr 2008 03:37:53 +0000</pubDate>
<dc:creator>lemonutzf</dc:creator>
<guid isPermaLink="false">221@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;第一题&#60;/p&#62;
&#60;p&#62;如果不考虑整型表示范围（题目似乎也没强调），那么有个很简单的方法：&#60;br /&#62;
遍历一遍，找到最小值min， 输出 min-1 就哦了。&#60;/p&#62;
&#60;p&#62;如果有范围，比如sizeof(int)=4，Wanting 的bit标记法应该可以很容易解1GB.  而对于10MB的情况，bit标记法最坏情况下要pass 50遍。 用 取模MOD 做可能会快一些
&#60;/p&#62;</description>
</item>
<item>
<title>Sainkei 在 "据说是google的电面题目"</title>
<link>http://zhiqiang.org/bbs/topic/40#post-220</link>
<pubDate>星期四, 10 Apr 2008 03:41:48 +0000</pubDate>
<dc:creator>Sainkei</dc:creator>
<guid isPermaLink="false">220@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;sorry,上面所说是错的。汗！&#60;/p&#62;
&#60;p&#62;应该用bit建立一个二叉树来解
&#60;/p&#62;</description>
</item>
<item>
<title>521zheng 在 "面试题 - 旋转排序数组的二分查找"</title>
<link>http://zhiqiang.org/bbs/topic/48#post-219</link>
<pubDate>星期四, 10 Apr 2008 02:38:47 +0000</pubDate>
<dc:creator>521zheng</dc:creator>
<guid isPermaLink="false">219@http://zhiqiang.org/bbs/</guid>
<description>&#60;p&#62;为何不找到分界点，然后判断在左侧还是右侧查找呢？&#60;br /&#62;
测试通过的算法&#60;br /&#62;
int binarysearch(int key, int* arr, int n)&#60;br /&#62;
{&#60;br /&#62;
	int low = 0;&#60;br /&#62;
	int high = n-1;&#60;/p&#62;
&#60;p&#62;	while(low&#38;lt;=high)&#60;br /&#62;
	{&#60;br /&#62;
		int mid = (low+high)/2;&#60;br /&#62;
		if(arr[mid] == key)&#60;br /&#62;
			return mid;&#60;br /&#62;
		if(arr[mid]&#38;lt;key) low = mid+1;&#60;br /&#62;
		else high = mid-1;&#60;br /&#62;
	}&#60;br /&#62;
	return -1;&#60;br /&#62;
}&#60;br /&#62;
int getoffset(int *arr, int n)&#60;br /&#62;
{&#60;br /&#62;
	if(n&#38;lt;=1) return 0;&#60;br /&#62;
	if(arr[0] &#38;lt;arr[n-1])return 0;&#60;/p&#62;
&#60;p&#62;	int low =0;&#60;br /&#62;
	int high= n-1;&#60;/p&#62;
&#60;p&#62;	while(high-low&#38;gt;1)&#60;br /&#62;
	{&#60;br /&#62;
		int mid  = (low+high)/2;&#60;br /&#62;
		if(arr[mid] &#38;gt;=arr[low]) low = mid;&#60;br /&#62;
		else high = mid;&#60;/p&#62;
&#60;p&#62;	}&#60;/p&#62;
&#60;p&#62;	return high;&#60;/p&#62;
&#60;p&#62;}&#60;br /&#62;
int searchlooparray(int key, int * arr, int n)&#60;br /&#62;
{&#60;br /&#62;
	int offset  = getoffset(arr,n);&#60;br /&#62;
	if(offset ==0) return binarysearch(key, arr, n);&#60;br /&#62;
	if(key&#38;gt;=arr[0] &#38;#38;&#38;#38; key &#38;lt;=arr[offset-1])&#60;br /&#62;
		return binarysearch(key, arr, offset);&#60;br /&#62;
	else if(key&#38;gt;=arr[offset] &#38;#38;&#38;#38; key&#38;lt;=arr[n-1])&#60;br /&#62;
	{&#60;br /&#62;
		int result = binarysearch(key,arr+offset, n-offset);&#60;br /&#62;
		return result==-1 ? result:offset + result;&#60;br /&#62;
	}&#60;br /&#62;
	else return -1;&#60;br /&#62;
}
&#60;/p&#62;</description>
</item>

</channel>
</rss>
