<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eXclusiveMinds</title>
	<atom:link href="http://eXclusiveMinds.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://eXclusiveMinds.com</link>
	<description>eXclusive resource for programmers, developers and designers</description>
	<lastBuildDate>Sat, 13 Mar 2010 23:28:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick Sort Implementation in C#</title>
		<link>http://eXclusiveMinds.com/2010/03/13/quick-sort-implementation-in-c/</link>
		<comments>http://eXclusiveMinds.com/2010/03/13/quick-sort-implementation-in-c/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 21:23:30 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=1566</guid>
		<description><![CDATA[
/* QuickSort.cs */
&#160;
class QuickSort
&#123;
    static void Main&#40;string&#91;&#93; args&#41;
    &#123;
        a = new&#91;&#93; &#123; 1, 6, 7, 2, 3, 8, 9, 4, 5 &#125;;
        Quicksort&#40;a, 0, a.Length - 1&#41;;
    &#125;
&#160;
    [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td><div class="code"><pre class="csharp" style="font-family:Consolas; monospace;"><span style="color: #008080; font-style: italic;">/* QuickSort.cs */</span>
&nbsp;
<span style="color: #FF0000;">class</span> QuickSort
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        a <span style="color: #008000;">=</span> <span style="color: #008000;">new</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> <span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span> <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
        Quicksort<span style="color: #000000;">&#40;</span>a, <span style="color: #FF0000;">0</span>, a.<span style="color: #0000FF;">Length</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Quicksort<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> array, <span style="color: #FF0000;">int</span> lo, <span style="color: #FF0000;">int</span> hi<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">//  lo is the lower index, hi is the upper index</span>
        <span style="color: #008080; font-style: italic;">//  of the region of array array that is to be sorted</span>
        <span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> lo, j <span style="color: #008000;">=</span> hi<span style="color: #008000;">;</span>
        <span style="color: #FF0000;">int</span> pivot <span style="color: #008000;">=</span> array<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#40;</span>lo <span style="color: #008000;">+</span> hi<span style="color: #000000;">&#41;</span> <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">//  partition</span>
        <span style="color: #0600FF;">do</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>array<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #008000;">&lt;</span> pivot<span style="color: #000000;">&#41;</span>
                i<span style="color: #008000;">++;</span>
            <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>array<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> <span style="color: #008000;">&gt;</span> pivot<span style="color: #000000;">&#41;</span>
                j<span style="color: #008000;">--;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>i <span style="color: #008000;">&lt;=</span> j<span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #FF0000;">int</span> temp <span style="color: #008000;">=</span> array<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
                array<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> array<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
                array<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> temp<span style="color: #008000;">;</span>
                i<span style="color: #008000;">++;</span>
                j<span style="color: #008000;">--;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span> <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>i <span style="color: #008000;">&lt;=</span> j<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">//  recursion</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>lo <span style="color: #008000;">&lt;</span> j<span style="color: #000000;">&#41;</span>
            Quicksort<span style="color: #000000;">&#40;</span>array, lo, j<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>i <span style="color: #008000;">&lt;</span> hi<span style="color: #000000;">&#41;</span>
            Quicksort<span style="color: #000000;">&#40;</span>array, i, hi<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>    
<span style="color: #000000;">&#125;</span></pre></div></td></tr></table></div>

<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=1566&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/13/quick-sort-implementation-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merge Sort Implementation in C#</title>
		<link>http://eXclusiveMinds.com/2010/03/13/merge-sort-implementation-in-c/</link>
		<comments>http://eXclusiveMinds.com/2010/03/13/merge-sort-implementation-in-c/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 21:21:41 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=1564</guid>
		<description><![CDATA[
/* MergeSort.cs */ 
&#160;
class MergeSort
&#123;
    private static int&#91;&#93; a, b;
&#160;
    static void Main&#40;string&#91;&#93; args&#41;
    &#123;
        a = new&#91;&#93; &#123; 1, 6, 7, 2, 3, 8, 9, 4, 5 &#125;;
        b = new [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td><div class="code"><pre class="csharp" style="font-family:Consolas; monospace;"><span style="color: #008080; font-style: italic;">/* MergeSort.cs */</span> 
&nbsp;
<span style="color: #FF0000;">class</span> MergeSort
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">int</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> a, b<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        a <span style="color: #008000;">=</span> <span style="color: #008000;">new</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> <span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span> <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
        b <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #FF0000;">int</span><span style="color: #000000;">&#91;</span>a.<span style="color: #0000FF;">Length</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
        Sort<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, a.<span style="color: #0000FF;">Length</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Sort<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> left, <span style="color: #FF0000;">int</span> right<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>left <span style="color: #008000;">&lt;</span> right<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #FF0000;">int</span> mid <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>left <span style="color: #008000;">+</span> right<span style="color: #000000;">&#41;</span> <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span>
            Sort<span style="color: #000000;">&#40;</span>left, mid<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Sort<span style="color: #000000;">&#40;</span>mid <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span>, right<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Merge<span style="color: #000000;">&#40;</span>left, mid, right<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Merge<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> left, <span style="color: #FF0000;">int</span> mid, <span style="color: #FF0000;">int</span> right<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">int</span> j <span style="color: #008000;">=</span> left<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// copy first half of array a to auxiliary array b</span>
        <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>j <span style="color: #008000;">&lt;=</span> mid<span style="color: #000000;">&#41;</span>
            b<span style="color: #000000;">&#91;</span>i<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> a<span style="color: #000000;">&#91;</span>j<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">int</span> k <span style="color: #008000;">=</span> left<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// copy back next-greatest element at each time</span>
        <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>k <span style="color: #008000;">&lt;</span> j <span style="color: #008000;">&amp;&amp;</span> j <span style="color: #008000;">&lt;=</span> right<span style="color: #000000;">&#41;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>b<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #008000;">&lt;=</span> a<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
                a<span style="color: #000000;">&#91;</span>k<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> b<span style="color: #000000;">&#91;</span>i<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">else</span>
                a<span style="color: #000000;">&#91;</span>k<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> a<span style="color: #000000;">&#91;</span>j<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// copy back remaining elements of first half (if any)</span>
        <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>k <span style="color: #008000;">&lt;</span> j<span style="color: #000000;">&#41;</span>
            a<span style="color: #000000;">&#91;</span>k<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> b<span style="color: #000000;">&#91;</span>i<span style="color: #008000;">++</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></td></tr></table></div>

<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=1564&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/13/merge-sort-implementation-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You have got 3 sorted arrays A1 A2 and A3 having m n and p elements respectively. A gap of 3 is defined to be max distance between 3 numbers if they are put on a number line say u pick three 2 12 and 7 then the gap is 10. Now u have to find an efficient way of choosing 3 numbers from these 3 separate arrays(A1,A2,A3) such that their gap is minimum. Of course if a num say 2 occurs in all 3 then gap is 0</title>
		<link>http://eXclusiveMinds.com/2010/03/05/you-have-got-3-sorted-arrays-a1-a2-and-a3-having-m-n-and-p-elements-respectively-a-gap-of-3-is-defined-to-be-max-distance-between-3-numbers-if-they-are-put-on-a-number-line-say-u-pick-three-2-12-and/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/you-have-got-3-sorted-arrays-a1-a2-and-a3-having-m-n-and-p-elements-respectively-a-gap-of-3-is-defined-to-be-max-distance-between-3-numbers-if-they-are-put-on-a-number-line-say-u-pick-three-2-12-and/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[Inverview Tips]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=15</guid>
		<description><![CDATA[Method 1) Basic Method
 
Let
array1={10,40}
array2={40,50}
array3={10,50}
first second the 0th element from all the 3 arrays and calculate the span and assume that to be minimum span…
for the above case current three values are 10,40,10 from 1st, 2nd and 3rd array respectively and the span is 30.
now increase the index of the array which contains the minimum value [...]]]></description>
			<content:encoded><![CDATA[<p>Method 1) Basic Method<br />
 <br />
Let<br />
array1={10,40}<br />
array2={40,50}<br />
array3={10,50}<br />
first second the 0th element from all the 3 arrays and calculate the span and assume that to be minimum span…<br />
for the above case current three values are 10,40,10 from 1st, 2nd and 3rd array respectively and the span is 30.<br />
now increase the index of the array which contains the minimum value and now since we have a tie between 1st array and 3rd array in the given scenario that is both have their current value as 10 we can increase either of them….<br />
Let us assume we increased the index for 1st array and now again calculate the span…<br />
So now the 3 current values are 40, 40, 10 and the span is again 30.<br />
Continue increasing the current minimum value holder array’s index and recalculate the span…<br />
so now since 3rd array contain the minimum value that is 10 increase its index…<br />
so the next 3 values are 40,40,50 and the span is 10. Since this span is less than the previously stored span value replace the previously store span value with the current one.<br />
Now continue doing this unless any of the index is out of bound…such that index is getting increased beyond the last value.<br />
 <br />
 </p>
<p>Method 2) Optimized<br />
 <br />
O(n*m)<br />
n == number of rows<br />
m == number of columns (if number of elements in rows are not same , take the max value)<br />
 <br />
Merge all rows into a single array, say A (keep track of original row numbers for each of the elements)<br />
 <br />
may be something like<br />
struct {<br />
int element;<br />
int rowno;<br />
}A[n*m];<br />
3, 7, 16, 48<br />
5, 9, 21, 27, 49, 58<br />
1, 4, 8, 17, 47, 50<br />
{ {1,3} {3,1} {4,3} {5,2} {7,1} {8,3} {9,2} {16,1} {17,3} {21,2} {27,2} {47,3} {48,1} {49,2}, {50,3} {58,2}}<br />
 <br />
start from A[0], i.e; index=firstP=0; A[index]<br />
Increment Index till u get to c one element from each row.once u get to c all elements from each row , save a pointer to the array at that point , say secondP;<br />
 <br />
may be something lime<br />
bool Seen[n]={0};<br />
while ( All elements in Seen[n] != 1 )<br />
{<br />
index++;<br />
}<br />
secondP=Index;<br />
This is our first span . (to print the span you can make one more pass over the array from firstP to secondP , and can print elements from different rows)<br />
Find the Span of this Snippet say BestSpan=A[SecondP]-A[firstP];<br />
*Now move firstP to next number , firstP++; , check if the elements between A[firstP] to A[SecondP] contains elements from all rows . if so find the span and update it with the max span (if span < BestSpan)<br />
*If it doesn’t contain all elements from all rows Increment secondP++;<br />
check if the elements between A[firstP] to A[SecondP] contains elements from all rows. If so find the span and update it with the max span (if span < BestSpan)<br />
*Repeat the same till you are done with scanning all elements from the array<br />
 <br />
While ( Scan all elements != Done )<br />
{<br />
         firstP++<br />
         if ( contains elements from all  rows )<br />
         {<br />
           if ( span < BestSpan)<br />
           {<br />
             update BestSpan<br />
           }</p>
<p>           continue;<br />
         }<br />
         secondP++<br />
         if ( contains elements from all  rows)<br />
         {<br />
           if ( span < BestSpan)<br />
           {<br />
             update BestSpan<br />
           }<br />
         }<br />
}<br />
 <br />
{{1,3} {3,1} {4,3} {5,2} {7,1} {8,3} {9,2} {16,1} {17,3} {21,2} {27,2} {47,3} {48,1} {49,2}, {50,3} {58,2}}<br />
FirstP = 1<br />
SecondP = 4<br />
Span = 4<br />
BestSpan = 4<br />
{{1,3} {3,1} {4,3} {5,2} {7,1} {8,3} {9,2} {16,1} {17,3} {21,2} {27,2} {47,3} {48,1} {49,2}, {50,3} {58,2}}<br />
FirstP = 2<br />
SecondP = 4<br />
Span = 2<br />
BestSpan = 2<br />
 <br />
{{1,3} {3,1} {4,3} {5,2} {7,1} {8,3} {9,2} {16,1} {17,3} {21,2} {27,2} {47,3} {48,1} {49,2}, {50,3} {58,2}}<br />
 <br />
{{1,3} {3,1} {4,3} {5,2} {7,1} {8,3} {9,2} {16,1} {17,3} {21,2} {27,2} {47,3} {48,1} {49,2}, {50,3} {58,2}}<br />
FirstP = 3<br />
SecondP = 5<br />
Span = 3<br />
BestSpan = 2<br />
 <br />
{{1,3} {3,1} {4,3} {5,2} {7,1} {8,3} {9,2} {16,1} {17,3} {21,2} {27,2} {47,3} {48,1} {49,2}, {50,3} {58,2}}<br />
 <br />
{{1,3} {3,1} {4,3} {5,2} {7,1} {8,3} {9,2} {16,1} {17,3} {21,2} {27,2} {47,3} {48,1} {49,2}, {50,3} {58,2}}<br />
FirstP = 4<br />
SecondP = 6<br />
Span = 3<br />
BestSpan = 2</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=591&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/you-have-got-3-sorted-arrays-a1-a2-and-a3-having-m-n-and-p-elements-respectively-a-gap-of-3-is-defined-to-be-max-distance-between-3-numbers-if-they-are-put-on-a-number-line-say-u-pick-three-2-12-and/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How will you find the MSB and LSB of a number</title>
		<link>http://eXclusiveMinds.com/2010/03/05/how-will-you-find-the-msb-and-lsb-of-a-number/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/how-will-you-find-the-msb-and-lsb-of-a-number/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=14</guid>
		<description><![CDATA[1111: MSB=4, LSB=4
1101100: MSB=7, LSB=3
To find MSB: Right shift the operator till the number become zero. The number of time that you have right shifted is the MSB
To find LSB: Right shift the number(take out the last number 0 or 1) and then left shift( put a 0 back)
Now if the number before the operation [...]]]></description>
			<content:encoded><![CDATA[<p>1111: MSB=4, LSB=4<br />
1101100: MSB=7, LSB=3<br />
To find MSB: Right shift the operator till the number become zero. The number of time that you have right shifted is the MSB<br />
To find LSB: Right shift the number(take out the last number 0 or 1) and then left shift( put a 0 back)<br />
Now if the number before the operation is equal 0 after the operation then<br />
count++;<br />
rightshift the number<br />
goto start<br />
int msb(int *num)<br />
{</p>
<p>        if(*num >> 1 == 0)</p>
<p>        {</p>
<p>          return msbCount;<br />
        }</p>
<p>        else</p>
<p>        {</p>
<p>          *num >>= 1;</p>
<p>          msbCount++;</p>
<p>          return msb(num);<br />
 <br />
        }<br />
}</p>
<p>int lsb(int *num)<br />
{<br />
         if((*num>>1)<<1 != *num)<br />
           return lsbCount;<br />
         else<br />
         {<br />
           *num >>= 1;<br />
           lsbCount++;<br />
           return lsb(num);<br />
         }<br />
}</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=590&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/how-will-you-find-the-msb-and-lsb-of-a-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How can you get a tree back if traversal of tree output is given</title>
		<link>http://eXclusiveMinds.com/2010/03/05/how-can-you-get-a-tree-back-if-traversal-of-tree-output-is-given/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/how-can-you-get-a-tree-back-if-traversal-of-tree-output-is-given/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=13</guid>
		<description><![CDATA[BST can be constructed if
preorder/postorder+inorder is given
Not possible if preorder+postorder is given
Also refer this link for more algorithm/code regarding this problem
]]></description>
			<content:encoded><![CDATA[<p>BST can be constructed if<br />
preorder/postorder+inorder is given<br />
Not possible if preorder+postorder is given<br />
Also refer this link for more algorithm/code regarding this problem</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=589&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/how-can-you-get-a-tree-back-if-traversal-of-tree-output-is-given/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2D array search</title>
		<link>http://eXclusiveMinds.com/2010/03/05/2d-array-search/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/2d-array-search/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=12</guid>
		<description><![CDATA[There exits 2D array. We need or find out whether a given string (”microsoft”) exits in the given matrix. The string can be vertical or horizontal or in snake form but not in diagonal.
mi..
…c.o..oft
…..r.s
For every element, check its entire neighbor element to get the match
 Please refer this link
]]></description>
			<content:encoded><![CDATA[<p>There exits 2D array. We need or find out whether a given string (”microsoft”) exits in the given matrix. The string can be vertical or horizontal or in snake form but not in diagonal.<br />
mi..<br />
…c.o..oft<br />
…..r.s<br />
For every element, check its entire neighbor element to get the match<br />
 Please refer this link</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=588&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/2d-array-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How will you write your own sizeof operator</title>
		<link>http://eXclusiveMinds.com/2010/03/05/how-will-you-write-your-own-sizeof-operator/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/how-will-you-write-your-own-sizeof-operator/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=11</guid>
		<description><![CDATA[#define MySizeof(x) (char*)((x*)NULL+1)-(char*)((x*)NULL)
]]></description>
			<content:encoded><![CDATA[<p>#define MySizeof(x) (char*)((x*)NULL+1)-(char*)((x*)NULL)</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=587&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/how-will-you-write-your-own-sizeof-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You are given a very large number N of points (x,y,z) in 3D space. You have to find out the k points which are closest to the origin i.e. (0, 0, 0). You have to do it in the most efficient way. (Sorting takes O(nlgn) and apparently there is a much better solution). Distance of P=(x,y,z) from origin is D=sqrt(x*x + y*y + z*z)</title>
		<link>http://eXclusiveMinds.com/2010/03/05/you-are-given-a-very-large-number-n-of-points-xyz-in-3d-space-you-have-to-find-out-the-k-points-which-are-closest-to-the-origin-i-e-0-0-0-you-have-to-do-it-in-the-most-efficient-way-sorti/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/you-are-given-a-very-large-number-n-of-points-xyz-in-3d-space-you-have-to-find-out-the-k-points-which-are-closest-to-the-origin-i-e-0-0-0-you-have-to-do-it-in-the-most-efficient-way-sorti/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=10</guid>
		<description><![CDATA[1. Given a Point P(x,y,z) in the space. The Point is said to be inside the sphere of radius(r) and Origin(0,0,0) if dist(P)=(x^2+y+2+z+2) K then some excess points are inside the sphere. Half R i.e. R = R / 2. RL=R
7. If N = K then you are done with your search.
8. Now you have [...]]]></description>
			<content:encoded><![CDATA[<p>1. Given a Point P(x,y,z) in the space. The Point is said to be inside the sphere of radius(r) and Origin(0,0,0) if dist(P)=(x^2+y+2+z+2)<=r.<br />
2. We are also assuming the Range and the desity of the points are not known.<br />
3. Pick the First Point (p1) and calculate the hamming distance w.r.t origin and let it be R. This is also your boundary i.e. RH=RL=R<br />
4. Create a sphere with radius R.<br />
4. Find all points within this sphere and let it be N.<br />
5. If N < K then some points are outside the sphere. Double R i.e. R=R*2. RH=R</p>
<p>6. If N > K then some excess points are inside the sphere. Half R i.e. R = R / 2. RL=R<br />
7. If N = K then you are done with your search.<br />
8. Now you have got two reference [RL,RH]. You have also got the no of points within the sphere RL i.e. NL. So no of Points within the cavity [Rl,RH] that needs to be picked is K-NL<br />
9. Define a fn. BinarySearch(lowLimit,upperLimit) whose comparision function would be hamming distance from origin i.e. if Rmid is (RL+RH)/2 then we need to determine all points such that they are between [RL,Rmid] and if is less than K &#8211; NL then RL=Rmid else RH=Rmid else id its equal you have found the points.</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=586&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/you-are-given-a-very-large-number-n-of-points-xyz-in-3d-space-you-have-to-find-out-the-k-points-which-are-closest-to-the-origin-i-e-0-0-0-you-have-to-do-it-in-the-most-efficient-way-sorti/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How will you prove that there is no limit of prime number</title>
		<link>http://eXclusiveMinds.com/2010/03/05/how-will-you-prove-that-there-is-no-limit-of-prime-number/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/how-will-you-prove-that-there-is-no-limit-of-prime-number/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=9</guid>
		<description><![CDATA[Consider N as the upper limit of prime number
So consider N!+1 which is not divisible by 1-N.
So now N!+1 is also prime number, so gain considering N!+1 as upper limit we can take it forward like first line in the explanation
Hence there is no limit for prime number
]]></description>
			<content:encoded><![CDATA[<p>Consider N as the upper limit of prime number<br />
So consider N!+1 which is not divisible by 1-N.<br />
So now N!+1 is also prime number, so gain considering N!+1 as upper limit we can take it forward like first line in the explanation<br />
Hence there is no limit for prime number</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=585&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/how-will-you-prove-that-there-is-no-limit-of-prime-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How will you remove duplicate from an unsorted array</title>
		<link>http://eXclusiveMinds.com/2010/03/05/how-will-you-remove-duplicate-from-an-unsorted-array/</link>
		<comments>http://eXclusiveMinds.com/2010/03/05/how-will-you-remove-duplicate-from-an-unsorted-array/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:02:21 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Algorithm]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=8</guid>
		<description><![CDATA[Method 1) Using extra space
 
Bucket sort if range is known
Declare an array of known range and initialize the value of each element as zero
On visiting each input number increment the corresponding array by 1(e.g. if 2 is found then make a[2]+=1)
At the last visit all the elements in the array and display the element if [...]]]></description>
			<content:encoded><![CDATA[<p>Method 1) Using extra space<br />
 <br />
Bucket sort if range is known<br />
Declare an array of known range and initialize the value of each element as zero<br />
On visiting each input number increment the corresponding array by 1(e.g. if 2 is found then make a[2]+=1)<br />
At the last visit all the elements in the array and display the element if the array value is non-zero. This way the repeated number will be removed<br />
 <br />
 </p>
<p>Method 2) without extra space<br />
 <br />
Sort the elements<br />
Keep info about the first element that is visited and the first array that has been filled<br />
Once the info element is not equal to next element (means non-duplicate), put that next to the array that has been filled up<br />
the problem to find duplicate and remove duplicate character to get code/algorithm</p>
<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=584&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2010/03/05/how-will-you-remove-duplicate-from-an-unsorted-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
