Re: [algogeeks] Find longest consecutive subsequence

2014-01-29 Thread VARUN SACHDEVA
If we don't process the same number more than once, does it not create a
situation when we miss out on the solution?
For example the digit 6 in this sequence:
1,2,3,4,0,2,3,1,4,5,2,4,3,4,5,6,7,8,9

Varun


Varun Sachdeva



On 28 January 2014 00:29, Don  wrote:

> This works, and I think is O(N*log(N)) which is similar to sorting and
> scanning.
>
> An unordered map will be faster, in general. It could be made faster in
> most cases by looping over items left in the map, to avoid processing the
> same number more than once. Also, when the number of items left in the map
> is less than max, there is no need to continue because you know they can't
> form a sequence longer than max.
>
> int longest_sequence(vector &nums)
> {
>   unordered_map mp;
>   int max = 0;
>   for(unsigned int i = 0; i < nums.size(); i++)
> mp[nums[i]] = true;
>
>   while(mp.size() > max)
>   {
>  int i;
>  int n = mp.begin()->first; // Pick first item in map
>  mp.erase(n);
>  int count = 1;
>  for(i = n+1; mp.contains(i); ++i)
>  {
> ++count;
> mp.erase(i);
>  }
>  for(i = n-1; mp.contains(i); --i)
>  {
>  ++count;
>  mp.erase(i);
>  }
>
>  if (count > max) max = count;
>   }
>
>   return max;
> }
>
>
>
> On Monday, January 27, 2014 9:17:56 AM UTC-5, Nishant Pandey wrote:
>
>> I think this the most optimized code i have writen :
>>
>> #include 
>> #include 
>> #include 
>> using namespace std;
>>
>> int longest_sequence(vector &nums) {
>>   map mp;
>>   int count;
>>   int max = -;
>>   int n = 0;
>>   for(unsigned int i = 0; i < nums.size(); i++) {
>> mp[nums[i]] = true;
>>   }
>>
>>   for(unsigned int i =0;i> n = nums[i];
>> mp.erase(n);
>> count = 1;
>> while(mp.find(n+1)!= mp.end()) {
>>   count++;
>>   mp.erase(n+1);
>>   n++;
>> }
>> n = nums[i];
>> while(mp.find(n-1)!= mp.end()) {
>>   count++;
>>   mp.erase(n-1);
>>   n--;
>> }
>> if(count > max) {
>>   max = count;
>> }
>>   }
>>   return max;
>> }
>>
>> int main() {
>> // your code goes here
>>  cout << "Jai Ganesha";
>> vector vc;
>> vc.push_back(5);
>>  vc.push_back(20);
>> vc.push_back(45);
>> vc.push_back(3);
>>  vc.push_back(98);
>> vc.push_back(4);
>> vc.push_back(21);
>>  vc.push_back(1);
>> vc.push_back(99);
>> vc.push_back(2);
>>  cout << endl << longest_sequence(vc);
>> return 0;
>> }
>>
>>
>>
>> NIshant Pandey
>> Cell : 9911258345
>> Voice Mail : +91 124 451 2130
>>
>>
>>
>>
>> On Mon, Jan 27, 2014 at 4:29 PM, Amol Sharma  wrote:
>>
>>>  Given an array of positive numbers arranged in any order. You have to
>>> find the length of longest continuos(difference of +1, -1) sequence in the
>>> array.
>>>
>>> for eg.
>>> A[] = *5*, 20, 45, *3*, 98, *4*, 21, *1*, 99, *2*
>>>
>>> then longest continuos subsequence is [1, 2, 3, 4, 5] and hence the
>>> output should be *"5"*, the length of this sequence.
>>>
>>> Other Continuos sequence are -
>>>
>>> [20, 21]
>>> [45]
>>> [98, 99]
>>> [21]
>>>
>>> A[i] can be > 10^6, so hashing is not an option.
>>>
>>> Possible Approach is by sorting and time complexity will be O(nlogn).
>>>
>>> Does anyone have better approach for this ?
>>>
>>>
>>>
>>> --
>>> Thanks and Regards,
>>> Amol Sharma
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+...@googlegroups.com.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Casual: MS in US expenses

2013-06-25 Thread Varun Nagpal
I think you should go to Edulix.com. There you can find details about the
expenses for MS in a many different US universities


On Tue, Jun 25, 2013 at 4:54 PM, Shachin Sharma  wrote:

> Most of the good/top universities will have many TA and RA positions.
> Besides this University associated institutes provide RAs. As far as my
> experience goes almost all of the computer science MS students got RA or TA
> which covers for 75% waiver in tuition and like 1100 to 1500 $ money, which
> covered the expenses. But this may not be true for all the universities and
> you might want to ask specfically for the program you are applying.
>
> Regards,
> Shachin
>
>
> On Tue, Jun 25, 2013 at 4:49 PM, Jagannath Prasad Das  > wrote:
>
>> Folks,
>>I suppose this is not the right blog to query about the aforementioned
>> subject, but i am of opinion that i can get a comprehensive reply to my
>> question. On an average how much money(approx) does it take somebody to do
>> a MS in US(including tution,hostel and miscellaneous) ?
>>
>> I suppose it is easy to get a RA in the university you study and that
>> helps in someway.
>>
>> Regards,
>> Jagannath
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




Re: [algogeeks] Casual: MS in US expenses

2013-06-25 Thread Varun Nagpal
Prepare to spend atleast 20 Lakhs


On Tue, Jun 25, 2013 at 4:49 PM, Jagannath Prasad Das
wrote:

> Folks,
>I suppose this is not the right blog to query about the aforementioned
> subject, but i am of opinion that i can get a comprehensive reply to my
> question. On an average how much money(approx) does it take somebody to do
> a MS in US(including tution,hostel and miscellaneous) ?
>
> I suppose it is easy to get a RA in the university you study and that
> helps in someway.
>
> Regards,
> Jagannath
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




[algogeeks] Find a specific set of numbert

2013-04-03 Thread Varun
Hello all,

I have this problem to solve, and seek your assistance.

Program should be feeded with following integer inputs.
1. n integers in ascending order (a1,a2,a3...an)
2 an integer K.

We need to find K(k1,k2...kn) integers between [a1..an] both inclusive 
such that the sum of the absolute value of the difference of nearest ai and 
ki is minimum.

I know dynamic programming should be used here, but not able to figure out 
the correct way of doing it.
Any insights.

Thnx.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Puzzle.. How to solve??

2013-01-29 Thread varun pahwa
Hi,
Look at team Team7. F2,F9,F12,F14,F15.
=> F12 -> Chelsa.
C -> 7,12
L -> 2,9
and 14,15 not from liverpool.
Now, look at Team 6.
So,
C -> 7,12
L -> 3,6,2,9
U -> 15 , 1 (From Team 1)
Team 2 -> 11 & 13 not from liverpool.
Team 3 -> 11 & 5 not from liverpool
Team 5 => 11 from C
So,
C -> 7,12,11,10 (From Team 4),14 (From Team 7)
L -> 3,6,2,9,4(From Team 5),16 (From Team 5), 8 (From Team 8)
U -> 15 , 1 , 5 (From Team 3), 13 (From Team 8)

Rewriting it.
L -> 2,3,4,6,8,9,16
C -> 7,10,11,12,14
U -> 1,5,13,15


Now, all the questions can be answered.
Hope I'm cleared.

Thanks & Regards,
Varun





On Tue, Jan 29, 2013 at 12:25 AM, nikhil rao  wrote:

> Dream teams are formed by television viewers by selecting five players
> from the sixteen players namely
> F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15 and F16.The players
> belong to exactly one of the three teams namely Chelsea,Liverpool and
> United.Every Dream Team must have two players each from Chelsea and
> Liverpool and one player from united.Following information is provided
>
> a)F12 is not from United
> b)F7 is from Chesla.
> c)F2 and F9 are from liverpool
> d)the 'match fee' of each player belonging to chesla ,liverpool, and
> united is Euro 800.Euro775 and euro 725 match played respectively.
>
> 8 such dearm teams were formed are mentioned below...
> team1=F3,F9,F7,F1,F12
> Team2=F12,F11,F13,F6,F9
> Team3=F6,F3,F5,F11,F7
> Team4=F2,F10,F7,F6,F1
> Team5=F1,F4,F16,F11,F10
> Team6=F6,F3,F7,F15,F12
> Team7=F2,F9,F12,F14,F15
> Team8=F4,F8,F13,F11,F10
>
>Q1)in dream team 6 name the united player?
> 1)F3 2)F6 3)F12 4)F15
>
> Q2)how many players belong to Chesla from the given sixteen   players?
> 1)4 2)5 3) 6 4)7
>
>   Q3)In team 8 who are from liverpool?
> a)F4,F8
> b)F10,F11
> c)F11,F13
> d)F4,F11
>
>  Q4)what is the total fees per match (in Euros) for team ?
> 1)3875
> 2)3825
> 3)3800
> 4)none of these
>
>   Q5)which of the following combinations have only Liverpool players?
> a)F13,F3
> b)F3,F16
> c)F16,F14
> d)F14,F2
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Varun
Product Engineer,
Vizury

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: OS question..

2012-11-05 Thread Varun
see, ideally for Q1, the answer the NO.
But paging has some advantage, therefore its better to have it neverthless

Q2, ??

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/44rIrz0Vil8J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Accolite placement papers???

2012-09-08 Thread varun singh
For datastructure round, do practice simple datastructure questions
generally asked in microsoft interviews.

Varun Singh
9958130047


On Sat, Sep 8, 2012 at 11:13 AM, sandeep kumar
wrote:

> Hey!!!
> Can anyone give some idea about Accolite technologies placement procedure
> and questions it asks in the interview???
> Thnx in advance!!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Enter in the loop challenge

2012-09-06 Thread Varun

>
> This one's clever!

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/DVlEUy17gMgJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Queue problem

2012-07-24 Thread Varun

>
> Circular Queue, as it will overwrite in that case.

   I am not sure, if I understood the question correctly though.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/Z-CCtRFK9CQJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: storing URL's

2012-05-19 Thread Varun
That's agreed Gene.
Answer depends on context.

On Saturday, 19 May 2012 22:46:06 UTC+5:30, Gene wrote:
>
> This question has no answer. Every good student of computer science 
> will know that you choose a data structure based on the _operations_ 
> that must be performed on it: insert, lookup and what flavors of 
> lookup, delete, etc..  So if an interviewer uses this question, he or 
> she is probably trying to get you discuss this. So the right 
> _response_ (not an answer) is "What will you be _doing_ with these 
> URLs?" 
>
> An example: Suppose you take Varun's approach and build a tree.  Then 
> it turns out the operation is "Count the URLs for .png files."  Well, 
> the tree is no help here. You have to search the whole thing. 
>
> On May 15, 11:50 am, atul anand  wrote: 
> > Given a file which contain millions of URL's. which data structure would 
> > you use for storing these URL's . data structure used should store and 
> > fetch data in efficient manner.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/Pmzj6PeBWJ4J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: storing URL's

2012-05-15 Thread Varun
should be a tree based on domain in url and directory mentioned in url.

On Tuesday, 15 May 2012 21:20:55 UTC+5:30, atul007 wrote:
>
> Given a file which contain millions of URL's. which data structure would 
> you use for storing these URL's . data structure used should store and 
> fetch data in efficient manner. 


On Tuesday, 15 May 2012 21:20:55 UTC+5:30, atul007 wrote:
>
> Given a file which contain millions of URL's. which data structure would 
> you use for storing these URL's . data structure used should store and 
> fetch data in efficient manner. 

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/idbhSUZ6TNIJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: determine if a string if of form pZq

2012-04-20 Thread Varun
what's q then? can you please give few more examples?

On Thursday, 19 April 2012 23:02:31 UTC+5:30, tech coder wrote:
>
> determine whether the given string is of form pZq.
> p and q can contain only X and Y.
> like if p=XXYX then z will be XYXX
> for ex  XXYXXXYXX   is valid
>
> the limitation is that "you can read only the next character  at each 
> point" .
> -- 
>
>  Regards
> "The Coder"
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/XQCzNOIeoUUJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Which data structure to use in searching a list for information about - -

2012-04-10 Thread Varun
use double hash

On Friday, 6 April 2012 22:50:14 UTC+5:30, Rose wrote:
>
> Thanks all of you. I'm new to algorithms and data structure and I'm new in 
> this forum.
> I have an assignment but not sure yet:
>
> A. Describe a data structure which can effectively answer the following 
> questions:
>
> 1. A list of actors (f) : Print a list of actors who took part in film* f 
> *. 
> 2. A list of films -(s): Print a list with all the films that actor s has 
> been in.
> 3. Participation (s,f): Return true if the actor s took part in film f, 
> and false if not. 
>
> Explain the data structure and how the questioning is done. 
> Analyse the worst case running time for the above queries- in asymptotic 
> notation, as tight as possible 
>
> In the analysis use e.g. F=number of films; S =number of  actors; Fs= 
> number of films actor s took part in;
> and Sf =number of actors who took part in film f.
>
> Thanks a lot for your help 
>
> -- 
> Med Venlig Hilsen/Kind regards
>
> Rose
>
>
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/KTMjO_vcQBcJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: GPU doubt

2012-04-09 Thread Varun Nagpal
Sorry for lot of typos

On Mon, Apr 9, 2012 at 1:53 PM, Varun Nagpal wrote:

> GP programming on GPU is useful for those algorithms which are
> computationally intensive, can be paralleled with least overheads,
> granularity of per thread computations is not big, less+similar control
> flow per thread and at the same time do regular data access(for example
> array based data is regular while pointer based data is irregular). Massive
> multi-threading us used by GPU's to hide memory latency
>
> CPUs are essentially meant to run control-intensive(lot of conditional
> code: branch predictors help here) , irregular memory access (Memory
> hierarchy Register file, L1, L2 L3 caches helps here) and coarse grained
> multi-threaded applications(Multi-threaded processor architectures and
> HyperThreading helps here). Memory hierarchy + hardware multi-threading is
> used for hiding memory latency
>
> For a given algorithm, thousands of threads run on a GPU compared to
> handful (max some hundreds) that would run on a CPU.
>
> There is no general rule to say that an algorithm of O(n^3) complexity
> will run faster on CPU or GPU. My answer would be it depends. It depends
> upon lot of other things about the algorithm(data structure layout,
> floating point calculations etc.)  and the available hardware options and
> its architecture.
>
> One of the criteria of how to choose would be see the calculations/per
> memory access. The higher is this value, the better it would be suitable
> for GPU than CPU and vice versa
>
> I suggest you to this question on a computer architecture forum.
>
> Thanks
> Varun
>
> On Mon, Apr 9, 2012 at 1:21 PM, vikas  wrote:
>
>> Hey Arun, IIya,
>>   the GPUs are faster because of
>>
>> 1. designed for graphics processing, which involves a lot of matrix
>> processing capabilities , simple example transformation of matrices in
>> to various view (projection, model and viewport , some times needed
>> even in real time) so these computation are done in parallel
>> 2. all or most of processing are done at much precise rate and until
>> one does not specify, all are 'double computations' which is quite
>> costly even in modern CPU - ALU
>> 3. not only computations, a lot of other parallel architectural
>> advantage gives normal algorithms ( e.g. cache) better speedup than
>> CPU
>>
>> hope it clarifies. So if you are planning to start on GPU, start
>> thinking in multi-threaded
>>
>> copying data generally involves separate processing of DMA, I worked
>> with USB and PCI 66MHz connection of CPU/GPU , and does not seem to be
>> slow. even Fujitsu CoralPA was ok which has very slow dma and a PCI 33
>> connection.
>>
>>
>> On Apr 8, 4:04 am, Ilya Albrekht  wrote:
>> > Hey Phoenix,
>> >
>> > It is true that current GPU have way better floating point throughput
>> than
>> > any general purpose processor. But when you want to run your algo. on
>> the
>> > GPU there are always an overhead of copying data between CPU & GPU,
>> drivers
>> > and other system calls and you can gain performance even with those
>> > overhead if you have a lot of calculations (more calculations, less
>> > overhead %). And  I assume in general you have to do at least O(n^3)
>> > calculations to gain any perf.
>> >
>> > Out of my experience, the same thigh with the SSE vectorization - it
>> > doesn't make sense to vectorize the loop if it is less than ~25-27
>> > iterations, because the overhead of preparing data and aligning buffers
>> > will be too high.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Saturday, 7 April 2012 08:54:20 UTC-7, phoenix wrote:
>> >
>> > > @SAMM: what about general mathematical computations such as matrix
>> > > multiplication which is O(n^3) as such? How do you relate your
>> explanation
>> > > to such math computations or any algorithm of atleast O(n^3)?
>> >
>> > > On Sat, Apr 7, 2012 at 3:22 AM, SAMM 
>> wrote:
>> >
>> > >> This is becoz the GPU is multithreaded . In graphics there are three
>> main
>> > >> steps , Application based work where vertex Processing , read the
>> data ,
>> > >> pixel processing are done .
>> > >> Secondly come the Culling which which determimes which portion will
>> be
>> > >> shown given the Line of sight . This also checks for any
>> intersection with
>> > >> other objects . For instance a man is pr

Re: [algogeeks] Re: GPU doubt

2012-04-09 Thread Varun Nagpal
GP programming on GPU is useful for those algorithms which are
computationally intensive, can be paralleled with least overheads,
granularity of per thread computations is not big, less+similar control
flow per thread and at the same time do regular data access(for example
array based data is regular while pointer based data is irregular). Massive
multi-threading us used by GPU's to hide memory latency

CPUs are essentially meant to run control-intensive(lot of conditional
code: branch predictors help here) , irregular memory access (Memory
hierarchy Register file, L1, L2 L3 caches helps here) and coarse grained
multi-threaded applications(Multi-threaded processor architectures and
HyperThreading helps here). Memory hierarchy + hardware multi-threading is
used for hiding memory latency

For a given algorithm, thousands of threads run on a GPU compared to
handful (max some hundreds) that would run on a CPU.

There is no general rule to say that an algorithm of O(n^3) complexity will
run faster on CPU or GPU. My answer would be it depends. It depends upon
lot of other things about the algorithm(data structure layout, floating
point calculations etc.)  and the available hardware options and its
architecture.

One of the criteria of how to choose would be see the calculations/per
memory access. The higher is this value, the better it would be suitable
for GPU than CPU and vice versa

I suggest you to this question on a computer architecture forum.

Thanks
Varun

On Mon, Apr 9, 2012 at 1:21 PM, vikas  wrote:

> Hey Arun, IIya,
>   the GPUs are faster because of
>
> 1. designed for graphics processing, which involves a lot of matrix
> processing capabilities , simple example transformation of matrices in
> to various view (projection, model and viewport , some times needed
> even in real time) so these computation are done in parallel
> 2. all or most of processing are done at much precise rate and until
> one does not specify, all are 'double computations' which is quite
> costly even in modern CPU - ALU
> 3. not only computations, a lot of other parallel architectural
> advantage gives normal algorithms ( e.g. cache) better speedup than
> CPU
>
> hope it clarifies. So if you are planning to start on GPU, start
> thinking in multi-threaded
>
> copying data generally involves separate processing of DMA, I worked
> with USB and PCI 66MHz connection of CPU/GPU , and does not seem to be
> slow. even Fujitsu CoralPA was ok which has very slow dma and a PCI 33
> connection.
>
>
> On Apr 8, 4:04 am, Ilya Albrekht  wrote:
> > Hey Phoenix,
> >
> > It is true that current GPU have way better floating point throughput
> than
> > any general purpose processor. But when you want to run your algo. on the
> > GPU there are always an overhead of copying data between CPU & GPU,
> drivers
> > and other system calls and you can gain performance even with those
> > overhead if you have a lot of calculations (more calculations, less
> > overhead %). And  I assume in general you have to do at least O(n^3)
> > calculations to gain any perf.
> >
> > Out of my experience, the same thigh with the SSE vectorization - it
> > doesn't make sense to vectorize the loop if it is less than ~25-27
> > iterations, because the overhead of preparing data and aligning buffers
> > will be too high.
> >
> >
> >
> >
> >
> >
> >
> > On Saturday, 7 April 2012 08:54:20 UTC-7, phoenix wrote:
> >
> > > @SAMM: what about general mathematical computations such as matrix
> > > multiplication which is O(n^3) as such? How do you relate your
> explanation
> > > to such math computations or any algorithm of atleast O(n^3)?
> >
> > > On Sat, Apr 7, 2012 at 3:22 AM, SAMM  wrote:
> >
> > >> This is becoz the GPU is multithreaded . In graphics there are three
> main
> > >> steps , Application based work where vertex Processing , read the
> data ,
> > >> pixel processing are done .
> > >> Secondly come the Culling which which determimes which portion will be
> > >> shown given the Line of sight . This also checks for any intersection
> with
> > >> other objects . For instance a man is present behind the building ,so
> he
> > >> should not be visible to us in Graphics or some portion of this body
> will
> > >> be shown , This intersection is called redering .
> >
> > >> The third step if draw . to finally draw the model .
> >
> > >> These three process are done multithreaded parallerly given 3x
> Processing
> > >> speed .
> > >> You can refer this link below :-
> > >>http://www.panda3d.org/manual/i

[algogeeks] Re: networking

2012-03-29 Thread Varun
use RPC or RMI.
Since java use RPC

On Friday, 23 March 2012 10:07:12 UTC+5:30, Aman Kumar wrote:
>
> Hii to all 
>
> how to make a call of class's method(function) from client side to 
> server in java? 
>
> please replyit's urgent

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/KYWmIFMTAqQJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Doubt in removing loop from linked list

2012-03-10 Thread Varun
Yes, if they meet then its a loop, but in later case, they won't meet
in case where loop has anything more than 1 element.
here one ptr is at meeting point, and second is at start of loop, but
the distance between them isn't always one, its the number of elements
in the loop.
Now when u move each by one step, the place they meet is the starting
point of loop.
Hope this clarifies.

On Mar 9, 3:18 pm, rahul sharma  wrote:
> i have 2 pointers fast and slow.now if tehy meet there is a loop...
>
> now keep one ptr at meeting point and take other one to the begining of
> listmove both at speed of one..they will meet at start of loophow
> this happens???why they meet at start..plz tell logic behind this???thnx in
> advance

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] thanx to all

2012-02-28 Thread Varun Nagpal
cool

On Tue, Feb 28, 2012 at 9:22 PM, Ravi Ranjan wrote:

> hey Geeks thanx a lot .. for the valuable information in the
> discussions
>
> i got selected in Yatra.com (R n D profile)
>
> thanx a lot for the algorithms explained by to guys
>
> THANX A LOT
>
> :D:D:D:D
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] doubt about macro.......

2012-02-04 Thread Varun
Yep..that's correct.
In this context, I would like to understand a little more about inline 
functions?
Other than they being a type sensitive compared to macro, what else differs 
them from macro, and does each call to inline function, does get replaced 
by its definition!.

Any link, that can give me little more insight into its intricacies, if u 
can share.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/DJUpIAVj8y0J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] algorithm to sort based on frequency.

2012-02-01 Thread Varun
I was asked this question sometime during an interview.

WE have an array of known length. The elements in array can be repetitive.
now sort the array based on frequency of occurrence of each element in 
array.
Eg: a= {4.3.2.5.4.6.2.6}
after sorting a={4,4,2,2,6,6,3,5}

4,2,6 all occurs twice, in this case retain the order in which they 
appeared in original array.
I was able to give a solution using hashing the elements of the array to a 
new array, and if hash matches, incrementing the count, and then sort the 
hash values. Later, re scan the array to retain the order in case there's a 
match in frequency of any two element.

Looking for better alternatives.
Please pour in.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/ODTZfmgepZIJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Director Round MS Google

2012-01-31 Thread Varun
Ideally it should be invested intellectually to reap fruits for
future.
Invest in RnD for upcoming technologies like wireless, video, roaming,
seamless integration of devices, achieving standards for protocols
which are heavily used but not standardized.

On Feb 1, 5:53 am, Ashish Goel  wrote:
> Hi,
>
> This is not algo question, but has been asked in Google as well as MS.
> If you are given infinite supply of resources and money, what will you do
> in software. Why? Key criteria and key benefits please.
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: MICROSOFT WRITTEN

2011-10-02 Thread Varun Jakhoria
return (((-1+!x)&y) | ((-1+!!x)&z)) ;


On Sun, Oct 2, 2011 at 3:18 PM, ravi maggon  wrote:
> How about this answer:
> b?z:y
>
> int main() {
>     int a=0,b,y=4,z=5,k;
>     cin>>b;
>     k=(((b+~a+1)>>7)&1);//k will either be 0 or 1
>     cout<< (z-int((bool)k&(z-y)));
>     return 0;
> }
>
> On Mon, Sep 12, 2011 at 5:32 PM, beginner  wrote:
>>
>> although multiplication operator is not allowed..
>> but it's an attempt to write shorter...
>>
>> c++ implementation-
>>
>> int cond(int x, int y, int z){
>>  return  y*(int)((bool)x)+z*(1+(~(int)((bool)x)+1));
>> }
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/5uGBGvacNEwJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>
>
>
> --
> Regards
> Ravi Maggon
> B.E. CSE, Final Year
> Thapar University
>
> www.algorithmguru.com
>
> "Failure is the opportunity to begin again more intelligently"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Jakhoria
...it's only about 0's & 1's

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: google os ques on pipelining

2011-09-27 Thread Varun Nagpal
Thats right. Clock speed is governed by slowest processing stage + register
delay. With clock cycle of  (160+5) ns even the faster stages will be forced
to run slowly. As a result 1st instruction will take 165*4 ns and rest of
following 999 instructions will take 165*999 ns.

On Tue, Sep 27, 2011 at 4:03 PM, praneethn  wrote:

>
> clock period=(slowest stage delay)+(Buffer delay).
>
> slowest stage delay is 160 ns and Buffer delay is 5ns. Buffer delay will
> always be there between two stages .
>
> clock period=165ns.
>
> In the pipelining the time it takes =(k+n-1) * (clock period)
>
> k=number of stages and n=number of instructions(data items)
>
> hence time it takes=(4+1000-1)*(165)=165.4 microsec
>
>
>
>
> On Tue, Sep 27, 2011 at 11:51 AM, Aditya Virmani  > wrote:
>
>> 585 + (160 + 5)for slowest transactions *999 for the rest of the
>> instructions!
>>
>>
>> On Tue, Sep 27, 2011 at 12:49 AM, Gene  wrote:
>>
>>> You guys have the right idea except that since it's multiple choice
>>> you can do this with no math.  With 1000 data items and only 4 stages,
>>> the bottleneck has to be the slowest pipeline stage with its register
>>> delay.  So you can answer b in 10 seconds and move on to the next
>>> question!
>>>
>>> On Sep 26, 8:50 pm, Dumanshu  wrote:
>>> > @bharat:
>>> > for the second part where u multiplied (160+5) with 999, it should be
>>> > 160*999 because it is max of (150,120,160,140,5). Correct me if i am
>>> > wrong.
>>> >
>>> > On Sep 26, 4:02 pm, bharatkumar bagana 
>>> > wrote:
>>> >
>>> >
>>> >
>>> > > for the first instruction : 150+5+120+5+160+5+140=585 ns
>>> > > for the rest of the instructions , though pipeline
>>> > > max(150,120,160,140)=160
>>> >
>>> > > (160+5)*999=164835 ns
>>> > >  we assume that there will be no extra stalls existed in our system
>>> > > -585 + 164835 =165420 ns =165.4 us...
>>> > > correct me if I'm wrong .
>>> >
>>> > > On Sun, Sep 25, 2011 at 9:25 AM, siva viknesh <
>>> sivavikne...@gmail.com>wrote:
>>> >
>>> > > > A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 ns
>>> > > > (nano seconds)
>>> > > > respectively. Registers that are used between the stages have a
>>> delay
>>> > > > of 5 ns each. Assuming
>>> > > > constant clocking rate, the total time taken to process 1000 data
>>> > > > items on this pipeline will
>>> > > > approximately be
>>> > > > a. 120 us (micro seconds)
>>> > > > b. 165 us
>>> > > > c. 180 us
>>> > > > d. 175 us
>>> >
>>> > > > ...plz give detailed explanation for the ans
>>> >
>>> > > > --
>>> > > > You received this message because you are subscribed to the Google
>>> Groups
>>> > > > "Algorithm Geeks" group.
>>> > > > To post to this group, send email to algogeeks@googlegroups.com.
>>> > > > To unsubscribe from this group, send email to
>>> > > > algogeeks+unsubscr...@googlegroups.com.
>>> > > > For more options, visit this group at
>>> > > >http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > > --
>>> >
>>> > > **Regards
>>> > > *BharatKumar Bagana*
>>> > > **http://www.google.com/profiles/bagana.bharatkumar<
>>> http://www.google.com/profiles/bagana.bharatkumar>
>>> > > *
>>> > > Mobile +91 8056127652*
>>> > > - Hide quoted text -
>>> >
>>> > - Show quoted text -
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C++ Doubts !!

2011-09-24 Thread Varun Nagpal
Dude google C++ Faqs. You will find all your answers. You can also buy some
books

1. C++ Common Knowledge: Essential Intermediate Programming
2. Effective and More effective C++
3. C++ gotchas

On Sat, Sep 24, 2011 at 11:52 AM, Decipher  wrote:

> Q1) What does the compiler does if I declare a base class VIRTUAL ??
>
> Q2) In the below test code ,
>
> class A : public B, public C
> {
> };
>
> The order of constructor invocation is :
> B
> C
> A
>
> but if C is virtual base class the it changes to :
> C
> B
> A
>
> Why ??
>
> Q3) Write a macro that swaps any data given to it (Eg: char , int , pointer
> of any kind , float )
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/mj25b-AYRgAJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Blocked/Unrolled linked list with no duplicates and sorted

2011-09-16 Thread Varun Nagpal
rrentNode.next)
insertionsort(elem, currentNode)
return startNode;
  }
  else
  {
// nextNode doesnt exist i.e. null or nextNode must be full
// so a newNode must be inserted between currentNode and nextNode(or null)
create newNode
newNode.next = currentNode.next
newNode.Array[newNode.last_index] =
currentNode.Array[currentNode.last_index]
insertionsort(elem, currentNode)
currentNode.next = newNode
return startNode
  }
}
}
  }
}
*END Function*

*You can look at below email for more explanation of unrolled linked list.*
*
*
*
*
*Thanks *
*V.*
*
*
*
*

On Thu, Jul 28, 2011 at 6:43 PM, Varun Nagpal wrote:

> Thanks a lot for your inputs Sunny. Your solution seems correct to me. Is
> this the only method ? Can you think of any other methods which could be
> more efficient. I heard merge sort or quick sort are also used for linked
> lists. Do you see their applicability in this case?
>
> What about duplicate avoidance ? Do I perform binary search on each node
> during the list construction to check for duplicates? Or you can think of a
> more efficient way?
>
> Thanks a lot
>
> Varun
>
>
>
>
> On Thu, Jul 28, 2011 at 11:02 AM, sunny agrawal 
> wrote:
>
>> Nice Problem :)
>>
>> i think taking care of duplicates is very simple...but main point is
>> sorted insertion
>> that has to very carefully done
>> there are many cases that need to be taken care of
>> 1. if the value to be inserted is between two nodes and both nodes are
>> fullthen a new node will be inserted in the link list and value to be
>> inserted will be the first element in the new node
>> case: (1,2)->(4,5) and 3 need to be inserted
>> after insertion list will be
>> (1,2)->(3,x)->(4,5)->NULL
>>
>> 2. else the value that need to be inserted will be inside some node...
>> if there is empty space in the nodesimply insert using insertion sort
>> (1,2)->(4,x) and 3 is to be inserted, insertion sort in node 2 will
>> suffice
>> (1,2)->(3,4)->NULL
>> 3. but if the node in which the value need to inserted is full then last
>> number from that node will be shifted to a new node and then insert the
>> value in the node.
>> if array_sz is large the one instead of shifting the last element u can
>> split into two halves and put first half in first and second in 2nd
>> (1,2)->(3,5)4 to be inserted
>> (1,2)->(1,4) ->(5,x) ->NULL
>> i think considering these 3 cases would suffice...although first case
>> can be merged with 3rd if programmed carefully
>>
>>
>>
>> On Thu, Jul 28, 2011 at 3:35 AM, banu  wrote:
>>
>>> Anyone ?
>>>
>>> On Jul 26, 10:27 pm, banu  wrote:
>>> > Hi,
>>> > Basically I am trying to create a blocked linked list(unrolled linked
>>> > list) with following properties
>>> > - Configurable number of elements in each node
>>> > - No duplicate elements in the unrolled linked list
>>> > - Linked list is sorted either during insertion or after creating the
>>> > linked list
>>> > - In place
>>> >
>>> > Assuming I need to create a sorted unrolled linked list with no
>>> > duplicate elements with block size say 2
>>> >
>>> > Example: 10,2,4,2,5,7,9.11,11,5
>>> >
>>> > Final blocked linked list: (2,4)->(5,7)->(9,10)->(11,x) or in reverse
>>> > order
>>> >
>>> > Note: x means unutilized location in the array wihtin the node. In
>>> > case there are not enough elements to insert in a node, some memory
>>> > allocated for a node is unutilized
>>> >
>>> > // Following is node structure
>>> > #define ARRAY_SZ 2
>>> > typedef struct node
>>> > {
>>> > struct node* next;
>>> > long long int elements[ARRAY_SZ];
>>> > long long int elemIndex;
>>> >
>>> > }NODE, *NODE_PTR;
>>> >
>>> > Can you suggest me a way to do this correctly and efficiently? It
>>> > could be an pseudo text or C-code.
>>> >
>>> > Thanks
>>> > Varun
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Sunny Aggrawal
>> B-Tech IV year,CSI
>> Indian Institute Of Technology,Roorkee
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c output doubt

2011-08-11 Thread Varun Jakhoria
i didn't tried it  .. but it might  be internal conversion only , like
whenever we do +1 to the address of int it automatically convert it
into +4(i.e int size)

On Fri, Aug 12, 2011 at 11:34 AM, rohit  wrote:
>
> int main()
> {
> int a[5]={1,2,3,4,5};
> printf("%d",&a[4]-&a[0])
> }
> why it show 4 not 16?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to 
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
Varun Jakhoria
...it's only about 0's & 1's

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: puzzle

2011-08-10 Thread varun pahwa
make two ropes 50m and 100 meter. make a loop kind of thing with that now
you have two 50 mtr ropes so get down to 100 mtr point and tie loop rope in
downward now cut the loop at 100 mtr you have 100 mtr rope then move down
with the help of that. i hope i am clear.

On Mon, Aug 8, 2011 at 1:52 PM, Shachindra A C wrote:

> tie the rope to the peg and hold the rope at a little less than 100m point.
> Then jump.
>
>
> On Mon, Aug 8, 2011 at 1:19 PM, Himanshu Srivastava <
> himanshusri...@gmail.com> wrote:
>
>> @Dave oh i thought some logical concept willl be applied in that
>> case...it is ok!!!
>> thanks:)
>>
>>
>> On Fri, Aug 5, 2011 at 1:47 AM, Dave  wrote:
>>
>>> @Himanshu: That is easy for any boy scout. :-) Tie the rope at the top
>>> of the tower. Then tie a sheepshank knot of a comfortable length in
>>> the rope and cut the middle strand inside the knot. Climb down the
>>> rope to the peg and tie the other end of the rope onto the peg. Then,
>>> while standing on or hanging from the peg, shake the upper rope to
>>> release the sheepshank knot. The upper end will fall down and you can
>>> climb the rest of the way down.
>>>
>>> Dave
>>>
>>>
>>> On Aug 4, 1:50 pm, Himanshu Srivastava 
>>> wrote:
>>> > suppose u tie the rope at 200mt height and now climb down to 100m
>>> > heightthen u tie the rope at that point then how will you open the
>>> rope
>>> > at point above 200mt where u have tied it earlier
>>> >
>>> >
>>> >
>>> > On Thu, Aug 4, 2011 at 11:15 PM, mohit verma 
>>> wrote:
>>> > > can't we tie the rope where we are standing (at height of 200 meter)?
>>> >
>>> > > On Thu, Aug 4, 2011 at 10:26 PM, neeraja marathe <
>>> > > neeraja.marath...@gmail.com> wrote:
>>> >
>>> > >> this was the puzzle asked to me in NVIDIA interview:
>>> > >> you are standing on top of a tower of ht 200 mt. .At 100 mt. ht .
>>> from
>>> > >> bottom of tower there is a peg where u can tie a rope. You have a
>>> rope
>>> > >> of length 150 mt. with you and using this rope you have to get down
>>> > >> the tower. you can not jump or there is nobody to help you. how will
>>> u
>>> > >> get down the tower??
>>> >
>>> > >> --
>>> > >> You received this message because you are subscribed to the Google
>>> Groups
>>> > >> "Algorithm Geeks" group.
>>> > >> To post to this group, send email to algogeeks@googlegroups.com.
>>> > >> To unsubscribe from this group, send email to
>>> > >> algogeeks+unsubscr...@googlegroups.com.
>>> > >> For more options, visit this group at
>>> > >>http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > > --
>>> > > 
>>> > > *MOHIT VERMA*
>>> >
>>> > >  --
>>> > > You received this message because you are subscribed to the Google
>>> Groups
>>> > > "Algorithm Geeks" group.
>>> > > To post to this group, send email to algogeeks@googlegroups.com.
>>> > > To unsubscribe from this group, send email to
>>> > > algogeeks+unsubscr...@googlegroups.com.
>>> > > For more options, visit this group at
>>> > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>>> >
>>> > - Show quoted text -
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Shachindra A C
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: need a pgm pls help me

2011-08-09 Thread Varun Jakhoria
if linux use split command

On Tue, Aug 9, 2011 at 8:56 PM, Don  wrote:
> #include 
> #include 
>
> int main()
> {
>  char inFileName[80];
>  char outFileName[80];
>  int numSegments;
>  int bytesPerSegment;
>
>  printf("Enter file name:");
>  fgets(inFileName,80,stdin);
>  printf("Enter number of segments:");
>  scanf("%d", &numSegments);
>
>  FILE *f = fopen(inFileName, "rb");
>  if (!f) return 0;
>
>  // Get size of file to determine bytes per file segment
>  fseek(f, 0, SEEK_END);
>  int bytesPerSegment = 1 + (ftell(f) / numSegments);
>  fseek(f,0,SEEK_SET);
>  char *buffer = (char *)malloc(bytesPerSegment);
>  for(int segment = 0; segment < numSegments; ++segment)
>  {
>    sprintf(outFileName,"%s%d", inFileName,segment);
>    FILE *out = fopen(outFileName,"wb");
>    int len=fread(buffer, bytesPerSegment, 1, f);
>    fwrite(buffer, len, 1, out);
>    fclose(out);
>  }
>  return 1;
> }
>
> On Aug 9, 7:28 am, Divya Elangovan  wrote:
>> pls help me..its very urgent
>>
>> need a program to divide a file into equal parts(segments)
>>
>> --
>>
>> *
>>             **
>> *
>> *      **        **DIVI*
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to 
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
Varun Jakhoria
...it's only about 0's & 1's

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] os

2011-08-09 Thread Varun Jakhoria
@Raghvendhra +1 ... because it doesn't require entry at kernel

On Tue, Aug 9, 2011 at 10:55 PM, raghavendhra rahul
 wrote:
> Shared memory is fastest IPC mechanism, since it doesn’t involve any system
> call as it is done in user space.
> --
>
> Regards
> Raghavendhra
>
>
>
> "changing the face" can change nothing .. but "facing the change" can change
> everything
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Jakhoria
...it's only about 0's & 1's

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] output?

2011-08-09 Thread Varun Jakhoria
it doesn't matter

On Tue, Aug 9, 2011 at 10:24 PM, Jayanthi shravan
 wrote:
>
>   it matters..
> On Tue, Aug 9, 2011 at 10:20 PM, tech rascal 
> wrote:
>>
>>
>>
>> what will b the output??
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>
>
>
> --
> shravan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Jakhoria
...it's only about 0's & 1's

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] pls help

2011-08-05 Thread Varun Jakhoria
I think it can be done using bitwise ANDing with a mask

On Fri, Aug 5, 2011 at 12:58 PM, Gaurav Menghani
 wrote:
> An Implementation:
>
> #include
> #include
> using namespace std;
>
> string alphabet;
> int maxlen;
> void backtrack(string s,int l)
> {
>  if(l==maxlen) { cout<  s.push_back('-');
>  for(int i=0;i        { s[l]=alphabet[i]; backtrack(s,l+1); }
> }
>
> int main()
> {
>  maxlen=3;
>  alphabet="op";
>  backtrack("",0);
>  return 0;
> }
>
>
> On Fri, Aug 5, 2011 at 12:42 PM, Kamakshii Aggarwal
>  wrote:
>> @gaurav:i could not understand ur sol.can u explain it again..
>>
>> On Fri, Aug 5, 2011 at 12:32 PM, Gaurav Menghani 
>> wrote:
>>>
>>> On Fri, Aug 5, 2011 at 12:20 PM, Kamakshii Aggarwal
>>>  wrote:
>>> > given a set of letters and a length N, produce all possible output.(Not
>>> > permutation). For example, give the letter (p,o) and length of 3,
>>> > produce
>>> > the following output(in any order you want, not just my example order)
>>> >
>>> > ppp ppo poo pop opp opo oop ooo
>>> >
>>> > another example would be given (a,b) and length 2
>>> >
>>> > answer: ab aa bb ba
>>> >
>>> > --
>>> > Regards,
>>> > Kamakshi
>>> > kamakshi...@gmail.com
>>>
>>> This can be done easily by backtracking
>>>
>>> void backtrack(string s, int l)
>>> {
>>>   if(l == maxlen) { cout<>>
>>>   s.push_back('-');
>>>   for(int i=0;i>>   {
>>>     s[l]=alphabet[i];
>>>     backtrack(s,l+1);
>>>   }
>>> }
>>>
>>> --
>>> Gaurav Menghani
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards,
>> Kamakshi
>> kamakshi...@gmail.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Gaurav Menghani
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to 
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
Varun Jakhoria
...it's only about 0's & 1's

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Missing elements

2011-08-01 Thread varun pahwa
suppose the array is given as :
1 2 6 6 2 4
make the array as -1 -2 6 -6 2 -4.

working code ::

#include

int main ()
{
int a[] = {1 ,2 ,6 ,6,2,4,8,8};
int i,j;
for(i = 0; i < 8; i++)
{
j = a[i];
if(a[i] < 0 )
j = -j;
j--;
if(a[j] > 0)
a[j] = -a[j];
}
for(i = 0; i < 8; i++)
if(a[i] > 0)
printf("%d ",i+1);
return 0;
}

correct me if i am wrong;

On Mon, Aug 1, 2011 at 6:55 PM, Deepak  wrote:

> Given an array of elements 'n'. some k elements such that the repalced elements are  missing elements, without wasting any extra memory.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] array constant

2011-07-30 Thread varun pahwa
make max as a macro. as for c static memory allocation take place either
with a constant or a macro.
i.e.
either u declare
#define max 5
then write float arr[max];

or u may write

float arr[5];



On Sat, Jul 30, 2011 at 1:05 PM, Arshad Alam  wrote:

> Why it is showing an error at line number 5
>
>
> 1. void main()
> 2. {
> 3. clrscr();
> 4. int i,max=5;
> 5. float arr[max];
> 6. for(i=0;i 7.scanf("%f",&arr[i]);
> 8. getch();
> 9.}
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: binary search tree question!!!!

2011-07-30 Thread varun pahwa
do morris traversal until you find k. but that may modify the tree if you
break as you find k.

On Sat, Jul 30, 2011 at 9:14 AM, ankit sambyal wrote:

> Here the required program :
>
> void findkthSmallest(Node *root,int k)
> {
> Node *stack[100];
> int top=-1,count=0;
> Node *temp;
> stack[++top]=root;
>
> /*First we will find the minimum node*/
> temp=root;
> while(temp->left != NULL)
> {
> stack[++top]=temp->left;
> temp->left=NULL; //Make it NULL so that we do not traverse it
> again
> temp=temp->left;
> }
> //Now top of the stack contains the minimum node.
> //Now we will do inorder traversal
> while(top!=-1)
> {
> temp=stack[top];
> count++;   //Increment the count for every eleemnt
> traversed
> if(count==k)   //If count reaches k, we have kth smallest
> element as the top of the stack
> return stack[top]->value;
> else if(temp->left!=NULL)
> {
> stack[++top]=temp->left;
> temp->left=NULL;  //Make it NULL so that we do not traverse
> it again
> count++;
> }
> else if(temp->right!=NULL)
> {
> stack[++top]=temp->right;
> temp->right=NULL;  //Make it NULL so that we do not
> traverse it again
> count++;
> }
> else
> top--;
>
> }
> }
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Permutations in a string

2011-07-28 Thread varun pahwa
@ambika :: assuming only pointer can move in forward direction.

On Thu, Jul 28, 2011 at 11:26 PM, varun pahwa wrote:

> @amit:: I think ur solution will give wrong answer if all the characters
> are not unique.
>
> On Thu, Jul 28, 2011 at 11:13 PM, SAMMM  wrote:
>
>>
>> http://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm
>>
>>
>>
>>
>> U can try this too ..  Without any recursion ...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112
> Official Email :: rit2008...@iiita.ac.in
> Another Email :: varunpahwa.ii...@gmail.com
>
> People who fail to plan are those who plan to fail.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Permutations in a string

2011-07-28 Thread varun pahwa
@amit:: I think ur solution will give wrong answer if all the characters are
not unique.

On Thu, Jul 28, 2011 at 11:13 PM, SAMMM  wrote:

>
> http://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm
>
>
>
>
> U can try this too ..  Without any recursion ...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Blocked/Unrolled linked list with no duplicates and sorted

2011-07-28 Thread Varun Nagpal
Thanks a lot for your inputs Sunny. Your solution seems correct to me. Is
this the only method ? Can you think of any other methods which could be
more efficient. I heard merge sort or quick sort are also used for linked
lists. Do you see their applicability in this case?

What about duplicate avoidance ? Do I perform binary search on each node
during the list construction to check for duplicates? Or you can think of a
more efficient way?

Thanks a lot

Varun



On Thu, Jul 28, 2011 at 11:02 AM, sunny agrawal wrote:

> Nice Problem :)
>
> i think taking care of duplicates is very simple...but main point is
> sorted insertion
> that has to very carefully done
> there are many cases that need to be taken care of
> 1. if the value to be inserted is between two nodes and both nodes are
> fullthen a new node will be inserted in the link list and value to be
> inserted will be the first element in the new node
> case: (1,2)->(4,5) and 3 need to be inserted
> after insertion list will be
> (1,2)->(3,x)->(4,5)->NULL
>
> 2. else the value that need to be inserted will be inside some node...
> if there is empty space in the nodesimply insert using insertion sort
> (1,2)->(4,x) and 3 is to be inserted, insertion sort in node 2 will suffice
> (1,2)->(3,4)->NULL
> 3. but if the node in which the value need to inserted is full then last
> number from that node will be shifted to a new node and then insert the
> value in the node.
> if array_sz is large the one instead of shifting the last element u can
> split into two halves and put first half in first and second in 2nd
> (1,2)->(3,5)4 to be inserted
> (1,2)->(1,4) ->(5,x) ->NULL
> i think considering these 3 cases would suffice...although first case
> can be merged with 3rd if programmed carefully
>
>
>
> On Thu, Jul 28, 2011 at 3:35 AM, banu  wrote:
>
>> Anyone ?
>>
>> On Jul 26, 10:27 pm, banu  wrote:
>> > Hi,
>> > Basically I am trying to create a blocked linked list(unrolled linked
>> > list) with following properties
>> > - Configurable number of elements in each node
>> > - No duplicate elements in the unrolled linked list
>> > - Linked list is sorted either during insertion or after creating the
>> > linked list
>> > - In place
>> >
>> > Assuming I need to create a sorted unrolled linked list with no
>> > duplicate elements with block size say 2
>> >
>> > Example: 10,2,4,2,5,7,9.11,11,5
>> >
>> > Final blocked linked list: (2,4)->(5,7)->(9,10)->(11,x) or in reverse
>> > order
>> >
>> > Note: x means unutilized location in the array wihtin the node. In
>> > case there are not enough elements to insert in a node, some memory
>> > allocated for a node is unutilized
>> >
>> > // Following is node structure
>> > #define ARRAY_SZ 2
>> > typedef struct node
>> > {
>> > struct node* next;
>> > long long int elements[ARRAY_SZ];
>> > long long int elemIndex;
>> >
>> > }NODE, *NODE_PTR;
>> >
>> > Can you suggest me a way to do this correctly and efficiently? It
>> > could be an pseudo text or C-code.
>> >
>> > Thanks
>> > Varun
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Question

2011-07-25 Thread varun pahwa
is D the correct option.

On Mon, Jul 25, 2011 at 11:18 PM, Arpit Sood  wrote:

> @karan ya that's correct
> my first answer was insufficient information too, but since there was no
> such option had to think more :)
> cool question :D
>
>
> On Mon, Jul 25, 2011 at 11:12 PM, bagaria.ka...@gmail.com <
> bagaria.ka...@gmail.com> wrote:
>
>> the man is taking 20 mins less then what it actually requires i.e. the car
>> needs to travel 20 mins less then what it actually used to do ,
>> now the car had to spend that 20 mins in going and coming back from office
>> i.e. 10 mins each while going to office and the same for coming to office
>> hence the amount of distance covered by the car in 10 min is the same as
>> that covered by man in (90-10)=80 min so their relative speed is such.
>> I hope i am clear
>>
>>
>> On Mon, Jul 25, 2011 at 11:06 PM, Rohit jalan wrote:
>>
>>> Can you explain this ??
>>>
>>> On Mon, Jul 25, 2011 at 10:29 PM, shady  wrote:
>>>
>>>> easy guys...
>>>>
>>>> @sagar nice question, if there had been an option for incomplete info, i
>>>> would have gone with that... but it made me think thoroughly :)  80 min. is
>>>> answer
>>>>
>>>> @aashish we are forming new group for apti kind of questions...
>>>>
>>>>
>>>> On Mon, Jul 25, 2011 at 10:23 PM, AASHISH SUMAN <
>>>> aashish.barn...@gmail.com> wrote:
>>>>
>>>>>
>>>>> @sagar :: this group is for programming concepts not for apti.. if
>>>>> u wana to post some apti or reasoning question post here..
>>>>> http://www.facebook.com/groups/150933398312351?ap=1
>>>>>  --
>>>>> *WITH BEST REGARDS :
>>>>>
>>>>> AASHISH SUMAN
>>>>> MCA FINAL YEAR
>>>>> *
>>>>> *NIT DURGAPUR*
>>>>> *+91-9547969906*
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> Regards :
>>> ROHIT JALAN
>>> B.E. Graduate,
>>> Computer Science Department,
>>> RVCE, Bangalore
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Thanks and Regards
>>
>> *Karan Bagaria*
>> *MCA Final Year*
>> Training and Placement Representative
>> *NIT Durgapur*
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Arpit Sood
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C OUTPUT

2011-07-25 Thread varun pahwa
@Rajeev : little endian and big endian could create difference in the
answers.

On Mon, Jul 25, 2011 at 11:50 AM, rajeev bharshetty wrote:

> 257 is stored as
> B  A
>   0001 0001
>
> So iptr if int* will be pointing to this above
>
> So if we typecast it as char* then it will point to 0001 (A)
> and *ptr+1 will point to 0001(B)
>
> Hope this clear .
>
>
> On Mon, Jul 25, 2011 at 11:41 AM, aditya kumar <
> aditya.kumar130...@gmail.com> wrote:
>
>> main()
>> {
>> int i = 257;
>> int *iPtr = &i;
>> printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
>> }
>>
>> can any one explain me the o/p ??
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards
> Rajeev N B <http://www.opensourcemania.co.cc>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS Written Test

2011-07-24 Thread varun pahwa
Use trie tree and store word count also along with the pointer. So, that
search could take at max word size time.

On Sat, Jul 23, 2011 at 10:44 PM, rajeev bharshetty wrote:

> Trie data structure can be used ? What you say guys??
>
>
> On Sat, Jul 23, 2011 at 10:43 PM, ankit sambyal wrote:
>
>> Use hashing with the words as key. Store the string of the word as the
>> value..
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Regards
> Rajeev N B <http://www.opensourcemania.co.cc>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS Written Test

2011-07-23 Thread varun pahwa
I think regarding memory trie would be better.

On Sat, Jul 23, 2011 at 11:08 PM, saurabh singh  wrote:

> Hashtable o(1) trie atleast o(logn)
>
>
> On Sat, Jul 23, 2011 at 11:05 PM, wats my name for 2day 
> wrote:
>
>> @ankit, rajeev
>> even I wrote hashtable as the answer ..
>>
>> but which would be faster? Hashtabel or Trie?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT ALLAHABAD
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread varun pahwa
For breaking the first loop after the input gives EOF.
u can write it as.

for(;~scanf("%c",&a); )

On Fri, Jul 22, 2011 at 11:43 PM, LALIT SHARMA  wrote:

> No, actually , a is defined as char ... and comparing char with EOF ,,
> makes it go in infinte loop...as it never returns false.
>
> correct me if i am wrong...
>
>
> On Fri, Jul 22, 2011 at 11:41 PM, aditi garg wrote:
>
>> @shady. so in this case we shud use a!=-1 as the condition??
>>
>>
>> On Fri, Jul 22, 2011 at 11:37 PM, shady  wrote:
>>
>>> you are scanning from stdin therefore it is not coming out of first for
>>> loop... because your terminating condition is for EOF, which is -1( scanf
>>> returns -1 ) at the end.
>>>
>>>
>>> On Fri, Jul 22, 2011 at 11:34 PM, shady  wrote:
>>>
>>>> well you didn't mention the question, directly posted the code with no
>>>> head-tail... wait will answer, it is not coming out of first loop
>>>>
>>>>
>>>> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek 
>>>> wrote:
>>>>
>>>>> @shady this is nt a joke..
>>>>> sorry if i am asking too stupid question
>>>>> i m getting an infinite loop here.
>>>>> not getting how?
>>>>>
>>>>>
>>>>> On Fri, Jul 22, 2011 at 10:40 AM, shady  wrote:
>>>>>
>>>>>> what kind of joke is this ?
>>>>>>
>>>>>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek >>>>> > wrote:
>>>>>>
>>>>>>> #include
>>>>>>> main()
>>>>>>> {
>>>>>>> FILE *fp;
>>>>>>> char a;
>>>>>>> fp=fopen("old.out","w");
>>>>>>> if(fp==0)
>>>>>>> printf("File opening error");
>>>>>>> else
>>>>>>> {
>>>>>>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a))
>>>>>>> fprintf(fp,"%c",a);
>>>>>>> fclose(fp);
>>>>>>> fp=fopen("old.out","r");
>>>>>>> while(!feof(fp))
>>>>>>> putchar(getc(fp));
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>>> To unsubscribe from this group, send email to
>>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>&

Re: [algogeeks] Re: Contiguous subarray with sum zero

2011-07-20 Thread varun pahwa
nice solution by ankit. but can anyone tell if we were to find sequence that
may or may not be contiguous.

On Thu, Jul 21, 2011 at 12:22 AM, Kamakshii Aggarwal
wrote:

>
> a little mistake in ankur's solution
> 20 , -9 , 3 , 1, 5 , 0, -6 , 9
> 20 , 11,14,15,20,20(instead of 0),14,23
> now if sum of two consecutive terms is same then this means a 0 exists.and
> hence it can be printed as a subarray..else ankur's sol works fine..:)
>
>
> On Thu, Jul 21, 2011 at 12:06 AM, sagar pareek wrote:
>
>> @ankur
>>
>> pls explain through an example by taking above problem.
>>
>>
>> On Wed, Jul 20, 2011 at 10:52 PM, SAMMM  wrote:
>>
>>>
>>>
>>> Nice solution dude . Like that one 
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> **Regards
>> SAGAR PAREEK
>> COMPUTER SCIENCE AND ENGINEERING
>> NIT ALLAHABAD
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Kamakshi
> kamakshi...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon

2011-07-19 Thread varun pahwa
ankit solution is correct all five bases will be 1/5 and altitude of each
triangle will be h same. so all have equal area. 1/2*(b/5) *h.

On Tue, Jul 19, 2011 at 2:07 PM, sagar pareek  wrote:

> Ok then
> What about  ques 2 ?
>
>
> On Tue, Jul 19, 2011 at 1:40 PM, Nitish Garg wrote:
>
>> The algo gives the number of set bits in the number as pointed out by
>> SAMMM above.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/lyzigAph1iYJ.
>>
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: INFINITY

2011-07-19 Thread varun pahwa
printf("\u221E\n");



On Tue, Jul 19, 2011 at 4:10 PM, SAMMM  wrote:

> Yaa guys it hav something to do with UNICODE ... I know that 
>
>
>
> On Jul 19, 3:32 pm, sagar pareek  wrote:
> > yeah in my ubuntu too its not printing  :)
> >
> >
> >
> >
> >
> > On Tue, Jul 19, 2011 at 3:20 PM, SAMMM  wrote:
> > > But if we use gcc or g++ . In that case it doesn't print it .. Wht abt
> > > tht ...
> >
> > > On Jul 19, 2:40 pm, Piyush Sinha  wrote:
> > > > In Dev C it does
> >
> > > > On Tue, Jul 19, 2011 at 3:08 PM, SAMMM 
> wrote:
> > > > > It doesn't display the infinity symbol.
> >
> > > > > On Jul 19, 2:24 pm, Piyush Sinha  wrote:
> > > > > > *printf("%c\n",236);*
> >
> > > > > > On Tue, Jul 19, 2011 at 2:45 PM, SAMMM  >
> > > wrote:
> > > > > > > Print the symbol ∞  (INFINITY) through code . Unicode ..
> >
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the
> Google
> > > > > Groups
> > > > > > > "Algorithm Geeks" group.
> > > > > > > To post to this group, send email to
> algogeeks@googlegroups.com.
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > algogeeks+unsubscr...@googlegroups.com.
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > > > > > --
> > > > > > *Piyush Sinha*
> > > > > > *IIIT, Allahabad*
> > > > > > *+91-7483122727*
> > > > > > * <https://www.facebook.com/profile.php?id=10655377926>
> "NEVER
> > > SAY
> > > > > > NEVER"
> > > > > > *
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Algorithm Geeks" group.
> > > > > To post to this group, send email to algogeeks@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > algogeeks+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > > > --
> > > > *Piyush Sinha*
> > > > *IIIT, Allahabad*
> > > > *+91-7483122727*
> > > > * <https://www.facebook.com/profile.php?id=10655377926> "NEVER
> SAY
> > > > NEVER"
> > > > *- Hide quoted text -
> >
> > > > - Show quoted text -
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algogeeks@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > **Regards
> > SAGAR PAREEK
> > COMPUTER SCIENCE AND ENGINEERING
> > NIT ALLAHABAD- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] ms ques

2011-07-18 Thread varun pahwa
is there any direct conversion possible like from 2 to 16 ??

On Mon, Jul 18, 2011 at 11:56 PM, Nishant Mittal  wrote:

> 1st convert base 5 to base 10 and then base 10 to base 9
>
>
> On Mon, Jul 18, 2011 at 11:54 PM, sivaviknesh s wrote:
>
>>
>> convert a number in base 5  to  base 9 
>>
>> --
>> Regards,
>> $iva
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Long string and the first non-repeating character

2011-07-18 Thread varun pahwa
@sagar: that's what i have done i have taken two variables x and y which can
show if repetition is there or not. and we can store the initial positions
in the array in that case u don't have to traverse the string twice.

On Mon, Jul 18, 2011 at 10:33 PM, sagar pareek wrote:

> @dumanshu
> first read my soution just above yours   :)
>
> On Mon, Jul 18, 2011 at 10:21 PM, Dumanshu  wrote:
>
>> heres my solution with TC O(n) and SC O(26)
>> input string str
>> int arr[26] = {0};
>> traverse the string, character by character and increment the
>> corresponding counter.
>> i.e. arr[str[i]]++;
>>
>> Now traverse the string again and print out the first character
>> encountered whose arr[str[i]] == 1;
>>
>> On Jul 18, 9:20 pm, sagar pareek  wrote:
>> > Very good solution :-  but space complexity = O(26)
>> >
>> > take integer array arr[0-25] and initialise it with 0 by taking it
>> static
>> > logic is that we have only 26 characters so if i want to map character
>> 'a'
>> > with 0th position of arr[] then it can be done as atoi('a')-97.
>> > so whenever we encounter any character say str[i] (where str is array of
>> > given string) then it can be incremented as arr[atoi(str[i])-97]++
>> > so traverse the whole str[] and increment the corresponding values .
>> > At the end those characters which never encounter have values 0 in arr ,
>> > which encounter only once have values 1 and more than once have
>> values>1.
>> > at the end traverse the whole arr[] and find out the corresponding
>> character
>> > as itoa(arr[i]+97) :) :)
>> >
>> > But we have to do extra work to find the first character which repeats
>> only
>> > once
>> >
>> > On Mon, Jul 18, 2011 at 8:09 PM, hary rathor 
>> wrote:
>> > > can we use bit vector ?
>> > > because  by  do it we need just 32 bits of one extra variable .
>> >
>> > >  --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Algorithm Geeks" group.
>> > > To post to this group, send email to algogeeks@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > algogeeks+unsubscr...@googlegroups.com.
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/algogeeks?hl=en.
>> >
>> > --
>> > **Regards
>> > SAGAR PAREEK
>> > COMPUTER SCIENCE AND ENGINEERING
>> > NIT ALLAHABAD
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Long string and the first non-repeating character

2011-07-18 Thread varun pahwa
assuming lower case characters.
#include 
#include 
#include 
#include 

using namespace std;

int main ()
{
unsigned int x,y;
int ar[26];
string s;
cin >> s;
x = 0;
y = 0;
int l;
int min = INT_MAX;
unsigned int i = 0;
memset(ar,-1,sizeof(ar));

for(i = 0; i < s.size(); i++)
{
l = s[i] - 'a';
/*first occurrence*/
if(!((1 << (l)) & x))
{
ar[l] = i;
x = x|(1 << l);
}
else {
y = y|(1 << l);
}
}
//cout << x << " " << y << endl;
for(i = 0; i < 26; i++)
{
//cout << ar[i] << endl;
if(ar[i] == -1)
continue;
if(min > ar[i] && (!((1< wrote:

> "Any possible o(1) space o(n) soln?"
> O(1) space and O(n) time complexity ?
>
>
> On Mon, Jul 18, 2011 at 7:46 PM, saurabh singh wrote:
>
>> In that case only the size of hash table will be required to increase.Any
>> possible o(1) space o(n) soln?
>>
>>
>> On Mon, Jul 18, 2011 at 7:43 PM, shady  wrote:
>>
>>> O(n) for both space and time...
>>> count the number of times each character is coming = O(n) space in worst
>>> case
>>> start from the string beginning if character has count == 1 print it O(n)
>>> in worst case
>>> this works with ASCII characters... since we can hash them on their
>>> values 0, 255.. for languages like hindi, german don't know :)
>>>
>>>
>>> On Mon, Jul 18, 2011 at 7:35 PM, hary rathor wrote:
>>>
>>>> can anybody tell me in O(n)  solution,?
>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT ALLAHABAD
>>
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Long string and the first non-repeating character

2011-07-18 Thread varun pahwa
Assuming string as only lower case characters.
now declare two unsigned int as x,y and ar[26].
now when u encounter any character c among (a,...z) first time u will set
(c-'a') bit of x and check if it has already been occurred then set (c-'a')
bit of y.and ar[i] will be storing the very first occurrence of the c
character where i will be (c-'a').
now traverse the array and output will be (i+'a') where a[i] is min and
(ith) bit in x is set and ith bit in y bit is unset.

On Mon, Jul 18, 2011 at 7:26 PM, vaibhav shukla wrote:

> one solution could be:
>
> #include
> #include
> char non_repetition(char *p,int size)
> {
> int i,j,flag=0;
> for(i=0;i {
> for(j=0;j {
> if(j==i)
> continue;
> if(p[i]==p[j])
> flag=1;
> }
> if(flag==0)
> return p[i];
> else
> flag=0;
> }
> return '\0';
> }
>
> int main()
> {
> char
> str[]="aaabccc
> *V*";
> int len=strlen(str);
> char firstNR=non_repetition(str,len);
> if(firstNR=='\0')
> printf("all are repeating at least once\n");
> else
> printf("first non repeated character is=%c\n",firstNR);
> return 0;
> }
>
> gives *V* as the output
>
> On Mon, Jul 18, 2011 at 6:45 PM, Dumanshu  wrote:
>
>> You are given a long string and you have to print the "first" non
>> repeating character.
>> Solve it keeping SC and TC in mind. That is present both solutions,
>> one with high SC and low TC and viceversa.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
>   best wishes!!
> Vaibhav
> DU-MCA
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Missing Number in an array

2011-07-18 Thread varun pahwa
sorry that would not work. only it could work if each element is present
exactly once.

On Mon, Jul 18, 2011 at 5:44 PM, Aakash Johari wrote:

> Yes, you will have to write a quad eq. solver. It's easy to write.
>
>
> On Mon, Jul 18, 2011 at 5:13 AM, Aakash Johari wrote:
>
>> @varun: can you write the code for one?
>>
>>
>> On Mon, Jul 18, 2011 at 5:11 AM, varun pahwa wrote:
>>
>>> The above solution will work if each other number is exactly once
>>> present. but if that 's not true.
>>> then 4 equations can be formed.
>>> Assuming a,b repeated number where a may or may be equal to b.
>>>
>>> then equations will be
>>> x + y = a + b;
>>> x^2 + y^2 = a^2 + b^2.
>>> x.y = a.b
>>> x^3 + y^3 = a^3 + b^3.
>>> now 4 equations 4 variables can be solved.
>>>
>>>
>>> On Mon, Jul 18, 2011 at 5:31 PM, ankit sambyal 
>>> wrote:
>>>
>>>> 1. Initialize a bit vector of size n.
>>>> 2. For every no. set the corresponding bit vector.
>>>> 3. Now scan through the bit vectors and get the missing numbers
>>>> corressponding to the unset bits in the bit vector.
>>>>
>>>>
>>>> Time complexity : O(n)
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>
>>>
>>> --
>>> Varun Pahwa
>>> B.Tech (IT)
>>> 7th Sem.
>>> Indian Institute of Information Technology Allahabad.
>>> Ph : 09793899112
>>> Official Email :: rit2008...@iiita.ac.in
>>> Another Email :: varunpahwa.ii...@gmail.com
>>>
>>> People who fail to plan are those who plan to fail.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> -Aakash Johari
>> (IIIT Allahabad)
>>
>>
>>
>>
>>
>
>
> --
> -Aakash Johari
> (IIIT Allahabad)
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Missing Number in an array

2011-07-18 Thread varun pahwa
The above solution will work if each other number is exactly once present.
but if that 's not true.
then 4 equations can be formed.
Assuming a,b repeated number where a may or may be equal to b.

then equations will be
x + y = a + b;
x^2 + y^2 = a^2 + b^2.
x.y = a.b
x^3 + y^3 = a^3 + b^3.
now 4 equations 4 variables can be solved.

On Mon, Jul 18, 2011 at 5:31 PM, ankit sambyal wrote:

> 1. Initialize a bit vector of size n.
> 2. For every no. set the corresponding bit vector.
> 3. Now scan through the bit vectors and get the missing numbers
> corressponding to the unset bits in the bit vector.
>
>
> Time complexity : O(n)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Missing Number in an array

2011-07-18 Thread varun pahwa
make two equations as .
suppose numbers to be x,y
x + y = p = (n*(n+1))/2 - (sum of all elements of array).

x^2 + y^2 = q = (n*(n+1)*(2n+1))/6 - (sum of square of all elements of
array).

so 2*x*y can be calculated as (p^2 - q);

so, a quad equation is formed as you now (x + y) and (2*xy).

P.S. :: overflow is not handled.

Please comment.

On Mon, Jul 18, 2011 at 5:01 PM, TUSHAR_MCA wrote:

> Given an array of size n. It contains numbers in the range 1 to n.
> Each number is present at least once except for 2 numbers. Find the
> missing numbers ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c++ output

2011-07-17 Thread varun pahwa
@sourabh are you sure the code

int main()
{

g();
f();
}

inline int f(){
g();
return  g()+1;
}
inline int g()
{
return 1;
}

does work i think i must give compilation error.
Because a function need to be declared, before it is called in case of c++.
and by inline the code in the function is replaced when it is called.

On Wed, Jun 8, 2011 at 8:31 PM, hary rathor  wrote:

> because compiler have know about g funtion while evaluating f
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] what would be the output of following code??

2011-07-16 Thread varun pahwa
ignore my previous result.
the ans to first should be 2 22 2 0.
and the ans to second should be.
2 222
2
please correct me if i am wrong.



On Sat, Jul 16, 2011 at 5:38 PM, varun pahwa wrote:

> the ans to first should be 2 2 2 2 0.
> and the and to second should be.
> 222 2
> 2
> please correct me if i am wrong.
>
> On Sat, Jul 16, 2011 at 4:57 PM, shady  wrote:
>
>> @ankur that's right :)
>>
>>
>> On Sat, Jul 16, 2011 at 3:25 PM, Ankur Khurana 
>> wrote:
>>
>>> answer for first should be
>>> 2 22 23
>>>
>>> and for second
>>> 2 222
>>> 2
>>> correct me if i am wrong.
>>> On Sat, Jul 16, 2011 at 3:08 PM, Deoki Nandan  wrote:
>>>
>>>> what about this 
>>>> printf("\n%d",printf("%d %d",2,2)&printf("%d%d ",2,2));
>>>>
>>>>
>>>> On Sat, Jul 16, 2011 at 3:04 PM, swetha rahul 
>>>> wrote:
>>>>
>>>>> 2
>>>>>
>>>>>
>>>>> On Sat, Jul 16, 2011 at 2:51 PM, shiv narayan <
>>>>> narayan.shiv...@gmail.com> wrote:
>>>>>
>>>>>> Printf(“%d”,printf(“%d %d”,2,2) & printf(“%d %d ”, 2, 2));
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> **With Regards
>>>> Deoki Nandan Vishwakarma
>>>>
>>>> *
>>>> *
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112
> Official Email :: rit2008...@iiita.ac.in
> Another Email :: varunpahwa.ii...@gmail.com
>
> People who fail to plan are those who plan to fail.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] what would be the output of following code??

2011-07-16 Thread varun pahwa
please ignore my previous post.

On Sat, Jul 16, 2011 at 5:38 PM, varun pahwa wrote:

> the ans to first should be 2 2 2 2 0.
> and the and to second should be.
> 222 2
> 2
> please correct me if i am wrong.
>
> On Sat, Jul 16, 2011 at 4:57 PM, shady  wrote:
>
>> @ankur that's right :)
>>
>>
>> On Sat, Jul 16, 2011 at 3:25 PM, Ankur Khurana 
>> wrote:
>>
>>> answer for first should be
>>> 2 22 23
>>>
>>> and for second
>>> 2 222
>>> 2
>>> correct me if i am wrong.
>>> On Sat, Jul 16, 2011 at 3:08 PM, Deoki Nandan  wrote:
>>>
>>>> what about this 
>>>> printf("\n%d",printf("%d %d",2,2)&printf("%d%d ",2,2));
>>>>
>>>>
>>>> On Sat, Jul 16, 2011 at 3:04 PM, swetha rahul 
>>>> wrote:
>>>>
>>>>> 2
>>>>>
>>>>>
>>>>> On Sat, Jul 16, 2011 at 2:51 PM, shiv narayan <
>>>>> narayan.shiv...@gmail.com> wrote:
>>>>>
>>>>>> Printf(“%d”,printf(“%d %d”,2,2) & printf(“%d %d ”, 2, 2));
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> **With Regards
>>>> Deoki Nandan Vishwakarma
>>>>
>>>> *
>>>> *
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112
> Official Email :: rit2008...@iiita.ac.in
> Another Email :: varunpahwa.ii...@gmail.com
>
> People who fail to plan are those who plan to fail.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] what would be the output of following code??

2011-07-16 Thread varun pahwa
the ans to first should be 2 2 2 2 0.
and the and to second should be.
222 2
2
please correct me if i am wrong.

On Sat, Jul 16, 2011 at 4:57 PM, shady  wrote:

> @ankur that's right :)
>
>
> On Sat, Jul 16, 2011 at 3:25 PM, Ankur Khurana 
> wrote:
>
>> answer for first should be
>> 2 22 23
>>
>> and for second
>> 2 222
>> 2
>> correct me if i am wrong.
>> On Sat, Jul 16, 2011 at 3:08 PM, Deoki Nandan  wrote:
>>
>>> what about this 
>>> printf("\n%d",printf("%d %d",2,2)&printf("%d%d ",2,2));
>>>
>>>
>>> On Sat, Jul 16, 2011 at 3:04 PM, swetha rahul 
>>> wrote:
>>>
>>>> 2
>>>>
>>>>
>>>> On Sat, Jul 16, 2011 at 2:51 PM, shiv narayan <
>>>> narayan.shiv...@gmail.com> wrote:
>>>>
>>>>> Printf(“%d”,printf(“%d %d”,2,2) & printf(“%d %d ”, 2, 2));
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> **With Regards
>>> Deoki Nandan Vishwakarma
>>>
>>> *
>>> *
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] X-AmazoN

2011-07-15 Thread varun pahwa
Read Dave solution
https://groups.google.com/forum/#!msg/algogeeks/nE3REQZ-YBc/Y02NVHYBhdkJ

On Fri, Jul 15, 2011 at 3:23 PM, SkRiPt KiDdIe wrote:

>
> If rand() generates equi-probable numbers within range [1 - n] and n is a
> multiple of 1000 then your above code will be correct.
>
> You should utilize the bit-generator  function.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] microsoft ques

2011-07-12 Thread varun pahwa
please ignore my previous post that solution is wrong.

On Wed, Jul 13, 2011 at 11:01 AM, sameer.mut...@gmail.com <
sameer.mut...@gmail.com> wrote:

> @kranthi :
>
> d solution u ve given is only for 2 continuous elements..
> wr as d question doesnt limit it to 2.. It can be d product of any no. of
> continuous elements.
> So if the array is 200, 5, -2, -3, -1
> den ans shd be 200*5*-2*-3 = 6000
>
> N if m workin ur algo in d right way, den it ll give 1000
>
> On Wed, Jul 13, 2011 at 10:52 AM, kranthi kumar 
> wrote:
>
>> I think this is the solution what u need U can do in O(n) time...
>>
>>
>>> #include
>>>> using namespace std;
>>>>
>>>> main()
>>>> {
>>>> int a[7] = { 0, 0, 0, 19, 380, -1, 2};
>>>> int prod, nprod;
>>>> bool x = false;
>>>>
>>>> for(int i=0;i<6;i++)
>>>> {
>>>> nprod = a[i] * a[i+1];
>>>> cout<>>> if( x == false)
>>>> {
>>>> x = true;
>>>> prod = nprod;
>>>> }
>>>> else if( x== true && prod < nprod )
>>>> prod = nprod;
>>>> }
>>>>
>>>> cout<<"\nResult: "<>>> }
>>>>
>>>
>>>
>> --
>> Regards:
>> ---
>> D Kranthi kumar
>> Computer Science & Engg.
>> 1st Mtech, IIT Madras.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] microsoft ques

2011-07-12 Thread varun pahwa
#include 

int main()
{
int n = 7;
int a[] = {0, -10, -12, 19, 20, -1, -2};
int max;
int small;
int co;
int pro = 1;
int i;

i = 0;
while(i < n)
{
while(i < n && a[i] == 0)
i++;
max = 1;
co = 0;
small = 2147483647;
while(i < n && a[i] != 0)
{
if(a[i] < 0)
{
co++;
if(small > (-a[i]))
small = -a[i];
}
max *= a[i];
i++;
}
if(co & 1)
max = (-max) / small;
if(pro < max)
pro = max;
}
printf("%d ",pro);
return 0;
}


On Wed, Jul 13, 2011 at 10:52 AM, kranthi kumar wrote:

> I think this is the solution what u need U can do in O(n) time...
>
>
>> #include
>>> using namespace std;
>>>
>>> main()
>>> {
>>> int a[7] = { 0, 0, 0, 19, 380, -1, 2};
>>> int prod, nprod;
>>> bool x = false;
>>>
>>> for(int i=0;i<6;i++)
>>> {
>>> nprod = a[i] * a[i+1];
>>> cout<>> if( x == false)
>>> {
>>> x = true;
>>> prod = nprod;
>>> }
>>> else if( x== true && prod < nprod )
>>> prod = nprod;
>>> }
>>>
>>> cout<<"\nResult: "<>> }
>>>
>>
>>
> --
> Regards:
> ---
> D Kranthi kumar
> Computer Science & Engg.
> 1st Mtech, IIT Madras.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C OUTPUT HELP

2011-07-11 Thread varun pahwa
problem 3. I think tag is a reference so its size is 4 bytes.

On Tue, Jul 12, 2011 at 1:29 AM, nicks  wrote:

> Guys plz help me in understanding the following output
>
> *PROBLEM 1>.*
> *
> *
> #include
> main()
> {
> int scanf=78;
>  //int printf=45;
> int getchar=6;
> printf("%d",scanf);
>  printf("\n%d",getchar);
> }
>
> *OUTPUT-*
> 78
> 6
>
> in this problem my problem is using printf and scanf as variable
> names.they are functions in the stdio.h then how are they available for
> variable name ??...generally what happens is that whenever we use some name
> for the function and then use that name for some variable then compiler
> gives error then why in this case error is not coming ??
>
> *PROBLEM 2>.*
>
> #include
> main()
> {
> int i=1;
> printf("\n%d %d",i^=1%2,i<<=1%2);  // does it evaluate the final value of i
> before printing ??
> **}
> *OUTPUT-*
> 3 3
>
> In gcc what i have observed is that arguments of printf are evaluated from
> right to left i.e i<<=1%2 is evaluated before i^=1%2...hence i first becomes
> 2 then 3 after XOR with 1now output according to me should be "3
> 1".but what actually is happening is that it us evaluating i and then
> printing it 3 3.can someone explain why this output is coming ?
>
> and the last problem
>
> *PROBLEM 3>.*
> *
> *
> #include
> main()
> {
> enum {low='a',high='b'}tag;
>  char try=low;
> printf("Size=%d",sizeof(tag));
> switch (try)
>  {
> case 'a':printf("aaa");break;
> case 'b':printf("bbb");
>  case 'c':printf("ccc");
> }
> //system("pause");
> }
>
> in this program size of enum comes out to be 4..help me in understanding
> the size of enum...how it is stored in memory??...does the size of enum
> depend on number of constant in it ?anyone link regarding that ??
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: find sol!!

2011-07-09 Thread varun pahwa
for the first expression.
summation (i = 1 to i = n ) on i * i ! gives ((n+1)! - 1). May be this may
help in solving the problem.
that is 1*1! = 2! - 1.
1*1! + 2*2! = 3! - 1.
similarly,
1*1! + 2*2! + 3*3! ... + 10*10! = 11! - 1.

On Sun, Jul 10, 2011 at 10:27 AM, Dave  wrote:

> For the expression, I don't see a simple way. The result is slightly
> less than 1.
>
> For the second problem, 1597 is the only odd prime in the list, so it
> could be the odd one out.
>
> Dave
>
> On Jul 9, 10:15 pm, Sriganesh Krishnan <2448...@gmail.com> wrote:
> > (1*1!+2*2!+3*3!+4*4!+10*10!)/11!
> > .
> > is there any shortcut methods to solve such problems?
> >
> > find the odd one out...
> >
> > 13700, 1597, 326, 65, 16 , 6 , 2
> >
> > and i have no clue to how to solve the second question
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] puzzle

2011-07-09 Thread varun pahwa
6,24,60,120,210,240..

On Sun, Jul 10, 2011 at 3:29 AM, Abhishek Soni wrote:

> is it
> 6,24,60,120,210,336,.. ?
>
>
> On Sat, Jul 9, 2011 at 4:03 AM, amit the cool wrote:
>
>> 6,24,60,120,_
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Spaghetti Sort

2011-07-05 Thread varun gupta
Can someone give me coding implementation of spaghetti sort in java or
c/c++. I know the steps but i wonder how it can be implemented.

http://en.wikipedia.org/wiki/Spaghetti_sort

-- 
Warm Regards,
Varun Kumar
Email Id: varun.gt...@gmail.com
Contact: +91-9711751235

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Interview Question

2011-07-02 Thread varun pahwa
@aditya. xor all elements mean that. take xor of each element of 1st array
store in a variable that take xor of variable and each element of the second
array if all elements are common then the variable will be 0 some where.
var = a[0];
for(i = 1; i < sizeof(a)/sizeof(a[0]); i++)
var = var ^ a[i];
for(i = 0; i < sizeof(b)/sizeof(b[0]); i++)
var = var ^ b[i];


On Sat, Jul 2, 2011 at 2:19 PM, aditya kumar
wrote:

> @mohit..:i dint get the logic behind XOR plz explain ..nd ya i dont think
> dat you can find second largest in less than O(n).
>
>
> On Sun, Jul 3, 2011 at 2:43 AM, mohit mittal wrote:
>
>> Dont think that the corresponding elements should be same.
>> XOR Should do it anyway.
>>
>> Btw other question "How would you find the second largest element in an
>> array using minimum no of comparisons?Any thing better than O(n)."?
>>
>>
>> On Sun, Jul 3, 2011 at 2:41 AM, aditya kumar <
>> aditya.kumar130...@gmail.com> wrote:
>>
>>> xor will only result if corresponding elements are same . what if in both
>>> the array set of integers are same but they arnt corresponding to each other
>>> ??
>>>
>>>
>>> On Sun, Jul 3, 2011 at 2:37 AM, Dumanshu  wrote:
>>>
>>>> xor all the elements of both arrays ==0
>>>> sum of 1st array == sum of 2nd array
>>>> no. of elements in 1st == no. of elements in 2nd
>>>> if the above conditions are met, they have the same set.
>>>> m i missin sth?
>>>> On Jul 3, 1:23 am, mittal  wrote:
>>>> > Given two arrays of numbers, find if each of the two arrays have the
>>>> same
>>>> > set of ntegers ? Suggest an algo which can run faster than NlogN
>>>> without
>>>> > extra space?
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Mohit Mittal
>> 4th year , Computer Engineering
>> Student-Coordinator , DTU WebTeam
>> Delhi Technological University
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: help..

2011-07-02 Thread varun pahwa
@sunny thnx for the correction.

On Sat, Jul 2, 2011 at 9:16 AM, varun pahwa wrote:

> @sunny ya  i wanted to write the while(k % m == 0)
>
>
> On Sat, Jul 2, 2011 at 3:47 AM, sameer.mut...@gmail.com <
> sameer.mut...@gmail.com> wrote:
>
>> n&n-1  is the expression to find out if n is a power of 2...If n&n-1
>> returns 0 its a power of 2 else its not.
>> And what sunny said is also ryt
>>
>>
>> On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal wrote:
>>
>>> @cegprakash
>>> Expression resets the least significant set bit
>>>
>>>
>>>  On Sat, Jul 2, 2011 at 3:20 PM, mohit goel 
>>> wrote:
>>>
>>>> May be this can work.give any counter example...
>>>> int count;
>>>> main()
>>>> {
>>>>   int l,rope,cuts;
>>>>   scanf("%d%d",&l,&rope);
>>>>   count =0;
>>>>
>>>>find_cuts(l,rope);
>>>>printf("cuts needed is %d",count);
>>>>getch();
>>>>return 0;
>>>>}
>>>>
>>>>  int find_cuts(int l,int rope)
>>>>
>>>>  {
>>>>
>>>> if(l==rope)
>>>> return count;
>>>>  count++;
>>>>  printf("%d",count);
>>>>  l=l/2;
>>>>  if(l==rope)
>>>>  return count;
>>>>  if(rope>l)
>>>>  rope =rope-l;
>>>>
>>>>  find_cuts(l,rope);
>>>>
>>>>
>>>>  }
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> Sunny Aggrawal
>>> B-Tech IV year,CSI
>>> Indian Institute Of Technology,Roorkee
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112 ,08011820777
> Official Email :: rit2008...@iiita.ac.in
> Another Email :: varunpahwa.ii...@gmail.com
>
> People who fail to plan are those who plan to fail.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: help..

2011-07-02 Thread varun pahwa
@sunny ya  i wanted to write the while(k % m == 0)

On Sat, Jul 2, 2011 at 3:47 AM, sameer.mut...@gmail.com <
sameer.mut...@gmail.com> wrote:

> n&n-1  is the expression to find out if n is a power of 2...If n&n-1
> returns 0 its a power of 2 else its not.
> And what sunny said is also ryt
>
>
> On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal wrote:
>
>> @cegprakash
>> Expression resets the least significant set bit
>>
>>
>> On Sat, Jul 2, 2011 at 3:20 PM, mohit goel wrote:
>>
>>> May be this can work.give any counter example...
>>> int count;
>>> main()
>>> {
>>>   int l,rope,cuts;
>>>   scanf("%d%d",&l,&rope);
>>>   count =0;
>>>
>>>find_cuts(l,rope);
>>>printf("cuts needed is %d",count);
>>>getch();
>>>return 0;
>>>}
>>>
>>>  int find_cuts(int l,int rope)
>>>
>>>  {
>>>
>>> if(l==rope)
>>> return count;
>>>  count++;
>>>  printf("%d",count);
>>>  l=l/2;
>>>  if(l==rope)
>>>  return count;
>>>  if(rope>l)
>>>  rope =rope-l;
>>>
>>>  find_cuts(l,rope);
>>>
>>>
>>>  }
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Sunny Aggrawal
>> B-Tech IV year,CSI
>> Indian Institute Of Technology,Roorkee
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: help..

2011-07-02 Thread varun pahwa
k -> rope of desired length.
l -> rope of given length
m = 2;
while(k % m)
m *= 2;
ans :: (log2(l) - log2(m) + 1).
ex.
k = 6,l = 8
so initially m = 2;
after 1st iteration m = 4;
then break;
so min = log2(8) - log2(4) + 1  = 3 -2 + 1 = 2.


On Sat, Jul 2, 2011 at 1:16 AM, cegprakash  wrote:

> nope
>
> On Jul 2, 1:14 pm, keyan karthi  wrote:
> > yup :)
> >
> > On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah <
> shalinisah.luv4cod...@gmail.com
> >
> > > wrote:
> > > i guess the no. of 1s in the binary representation of the number is the
> > > answer..for 6 its 2...
> >
> > > On Sat, Jul 2, 2011 at 1:32 PM, cegprakash 
> wrote:
> >
> > >> the length of the rope is l units.
> > >> I can only cut any rope into two halves.
> >
> > >> for example if the length of the rope is 8 and we need a length of
> > >> rope 6
> >
> > >> we first cut into two halves and we get 4, 4
> > >> now we cut any of the half again and we get 4,2,2
> >
> > >> now we can merge 4 and 2 and form a rope of length 6.
> >
> > >> in this example we need a minimum of 2 cuts to get the length of rope
> > >> 6 from 8
> >
> > >> assume that l is always a power of 2 and we need always a even length
> > >> of rope from it how to find the number of minimum cuts needed to get
> > >> the new rope?.
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Algorithm Geeks" group.
> > >> To post to this group, send email to algogeeks@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> > >> algogeeks+unsubscr...@googlegroups.com.
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/algogeeks?hl=en.
> >
> > >  --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algogeeks@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] please explain

2011-06-30 Thread varun pahwa
actually u r passing arr,and receiving arr[] which actually receives the
first element address. So arr will be a reference to first address. so its
size will be 4  bytes and arr size will also be 4 bytes. so ur len contains
only 1. so ur loop runs only once.i hope it clears.

On Thu, Jun 30, 2011 at 4:49 PM, ashwini singh  wrote:

> still it's not working
>
> On Thu, Jun 30, 2011 at 4:42 PM, Rujin Cao  wrote:
>
>> int maxdiff(int );
>> int maxdiff(int arr[]);
>>
>> The signatures of  maxdiff function are  not the same.
>>
>>
>> On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh wrote:
>>
>>> this code gives an error ([Warning] passing arg 1 of `maxdiff' makes
>>> integer from pointer without a cast) . Please explain the reasons.
>>>
>>>
>>> #include
>>> #include
>>> int maxdiff(int );
>>> main()
>>> {
>>>   int p,arr[]={2,4,1,6,23,4};
>>>   p=maxdiff(arr);
>>>   printf("\n MAX Diff is \t %d",p);
>>>   getch();
>>>   }
>>> int maxdiff(int arr[])
>>> {
>>> int diff=0,len,i,j;
>>> unsigned p;
>>> len=sizeof(arr)/sizeof(arr[0]);
>>> for(i=0;i>> {
>>>   for(j=i;j>>   {
>>>  p=arr[j]-arr[i];
>>>  if((p-diff)>0)
>>>  diff=p;
>>>   }
>>> }
>>> return diff;
>>> }
>>>
>>> --
>>> with regards,
>>> Ashwini kumar singh
>>> ECE Final yr.
>>> NIT Allahabad
>>> **
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> with regards,
> Ashwini kumar singh
> ECE Final yr.
> MNNIT Allahabad
> *Mobile: *7505519402
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Binary Tree

2011-06-29 Thread varun pahwa
I don't have any alternative solution till now.

On Wed, Jun 29, 2011 at 8:05 PM, varun pahwa wrote:

> @ankit: ur space complexity will be too high. i think it will be ultimately
> 2^n where n is the number of the nodes.
>
> On Wed, Jun 29, 2011 at 1:10 PM, ankit sambyal wrote:
>
>> The idea is to traverse the binary tree in post order and find out all
>> the path sums and store them. Use a hashtable or any other data
>> structure to store the possible paths rooted at a node and going
>> down-only. Now we can construct all paths going through a node from
>> itself and its childrens' paths.
>>
>> If the idea is not clear, I will post the detailed algo..
>>
>>
>>
>>
>> On Wed, Jun 29, 2011 at 9:16 AM, Akshata Sharma
>>  wrote:
>> > ya..there can be other paths, like the on you mentioned..
>> >
>> > On Wed, Jun 29, 2011 at 9:25 PM, Piyush Sinha > >
>> > wrote:
>> >>
>> >> 7+3 also give the sum to be 10???
>> >>
>> >> On 6/29/11, Akshata Sharma  wrote:
>> >> > How to find a path in a given binary tree which sums up to a given
>> >> > target
>> >> > value?
>> >> > for example if the given BT is
>> >> >
>> >> >5
>> >> >   / \
>> >> >  3   2
>> >> >  /
>> >> > 7
>> >> > and if the target is 10, then the path is  root(5) + left node(3)
>> +
>> >> > right node (2).
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "Algorithm Geeks" group.
>> >> > To post to this group, send email to algogeeks@googlegroups.com.
>> >> > To unsubscribe from this group, send email to
>> >> > algogeeks+unsubscr...@googlegroups.com.
>> >> > For more options, visit this group at
>> >> > http://groups.google.com/group/algogeeks?hl=en.
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >> *Piyush Sinha*
>> >> *IIIT, Allahabad*
>> >> *+91-8792136657*
>> >> *+91-7483122727*
>> >> *https://www.facebook.com/profile.php?id=10655377926 *
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "Algorithm Geeks" group.
>> >> To post to this group, send email to algogeeks@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> algogeeks+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/algogeeks?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Algorithm Geeks" group.
>> > To post to this group, send email to algogeeks@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > algogeeks+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/algogeeks?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112 ,08011820777
> Official Email :: rit2008...@iiita.ac.in
> Another Email :: varunpahwa.ii...@gmail.com
>
> People who fail to plan are those who plan to fail.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Binary Tree

2011-06-29 Thread varun pahwa
@ankit: ur space complexity will be too high. i think it will be ultimately
2^n where n is the number of the nodes.

On Wed, Jun 29, 2011 at 1:10 PM, ankit sambyal wrote:

> The idea is to traverse the binary tree in post order and find out all
> the path sums and store them. Use a hashtable or any other data
> structure to store the possible paths rooted at a node and going
> down-only. Now we can construct all paths going through a node from
> itself and its childrens' paths.
>
> If the idea is not clear, I will post the detailed algo..
>
>
>
>
> On Wed, Jun 29, 2011 at 9:16 AM, Akshata Sharma
>  wrote:
> > ya..there can be other paths, like the on you mentioned..
> >
> > On Wed, Jun 29, 2011 at 9:25 PM, Piyush Sinha 
> > wrote:
> >>
> >> 7+3 also give the sum to be 10???
> >>
> >> On 6/29/11, Akshata Sharma  wrote:
> >> > How to find a path in a given binary tree which sums up to a given
> >> > target
> >> > value?
> >> > for example if the given BT is
> >> >
> >> >5
> >> >   / \
> >> >  3   2
> >> >  /
> >> > 7
> >> > and if the target is 10, then the path is  root(5) + left node(3)
> +
> >> > right node (2).
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Algorithm Geeks" group.
> >> > To post to this group, send email to algogeeks@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > algogeeks+unsubscr...@googlegroups.com.
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/algogeeks?hl=en.
> >> >
> >> >
> >>
> >>
> >> --
> >> *Piyush Sinha*
> >> *IIIT, Allahabad*
> >> *+91-8792136657*
> >> *+91-7483122727*
> >> *https://www.facebook.com/profile.php?id=10655377926 *
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Statement Riddle

2011-06-27 Thread varun pahwa
*'Ferari driver' easily beats the 'force indain driver'.* *'force indain
drive' had outdone the 'ferari driver'. Now second statement says force
indian drive outdone the ferari driver (who is a man who must have
run/walked).*

On Mon, Jun 27, 2011 at 9:09 AM, Vishal Thanki wrote:

> this may be  a reverse race, who comes last will win..
>
> On Mon, Jun 27, 2011 at 6:22 PM, Dave  wrote:
> > Force indain driver finishes second in race. Ferari was next to last.
> >
> > Dave
> >
> >
> >
> > On Jun 27, 2:18 am, Lavesh Rawat  wrote:
> >> *Statement Riddle  - 27 june
> >>  *
> >> *
> >> *
> >> **
> >> *'Ferari driver' easily beats the 'force indain driver' in a two care
> >> race.How did Indian newspapers *
> >> *truthfully report so to look as 'force indain drive' had outdone the
> >> 'ferari driver'
> >> Think ??
> >> *
> >> *Update Your Answers at* : Click
> >> Here<
> http://dailybrainteaser.blogspot.com/2011/06/statement-riddle.html?la...>
> >>
> >> *Solution:*
> >> Will be updated after 1 day
> >>
> >> --
> >>
> >> "Never explain yourself. Your friends don’t need it
> and
> >> your enemies won’t believe it" .
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread varun pahwa
suppose k is the sum to be found.
@vaibhav: yes it will stop when crossing is there means (j must be greater
than i).initially sum = a[i] + a[j] (where i = 0 n j = n- 1) n we will
increase i when sum is less than k and decrease j when sum < k.stop if sum
== k. and  if no i , j found till j > i. then pairs not possible,

On Mon, Jun 27, 2011 at 8:28 AM, Bharath Soma wrote:

> @ankit, sorry i was mistaken its O(nlogn) for searching the two elements...
>
>
> On Mon, Jun 27, 2011 at 8:04 PM, Swathi  wrote:
>
>> Dave,
>>
>> Can you provide the psuedo code for this..
>>
>> Thanks,
>> Swathi
>>
>>
>> On Mon, Jun 27, 2011 at 7:30 PM, Dave  wrote:
>>
>>> @Sunny. Mea culpa. You are correct. Revised (and correct) algorithm.
>>> Do two inorder traversals, one in the usual (descend to the left
>>> before descendung to the right) direction and the other in the
>>> reversed(descend to the right before descending to the left)
>>> direction. Let u and r be the current nodee of the two traversals,
>>> respectively. If u + r < x, then advance the usual traversal and
>>> repeat the comparison. If u + r > x, advance the reverse traversal and
>>> repeat the comparison. If u + r = x, and if u != r, then terminate
>>> with success. If u = r, then terminate with failure.
>>>
>>> Dave
>>>
>>> On Jun 27, 7:53 am, sunny agrawal  wrote:
>>> > @Dave
>>> > i think your solution won't work
>>> > consider inorder traversal of a BST is 1 6 7 8 15 and x = 14
>>> > initially both u,v (1,1)
>>> > according to u your algorithm will proceed like
>>> > (1,1) -> (1,6) -> (1,7) -> (1,8) -> (1,15) -> (6,15)  ->
>>> (15,15)
>>> >
>>> > and clearly in second step of your solution if (u+v) > x after
>>> advancing u
>>> > still u+v will be greater than x
>>> > so something is wrong
>>> > I think your solution will work in case we need to find 2 nodes with
>>> > difference x.
>>> >
>>> > correct me if i am wrong.!!
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > On Mon, Jun 27, 2011 at 6:13 PM, Dave  wrote:
>>> > > @Nishant: No need to store the data in an array. Do two inorder
>>> > > traversals simultaneously. Let u and v be the current nodes of the
>>> two
>>> > > traversals, respectively. If u + v < x, then advance the "v"
>>> > > traversal. If u + v > x, advance the "u" traversal.
>>> >
>>> > > Dave
>>> >
>>> > > On Jun 27, 3:40 am, Nishant Mittal 
>>> wrote:
>>> > > > do inorder traversal of tree and store values in an array.
>>> > > > Now find pairs by applying binary search on array..
>>> >
>>> > > > On 6/27/11, manish kapur  wrote:
>>> >
>>> > > > > --
>>> > > > > You received this message because you are subscribed to the
>>> Google
>>> > > Groups
>>> > > > > "Algorithm Geeks" group.
>>> > > > > To post to this group, send email to algogeeks@googlegroups.com.
>>> > > > > To unsubscribe from this group, send email to
>>> > > > > algogeeks+unsubscr...@googlegroups.com.
>>> > > > > For more options, visit this group at
>>> > > > >http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text
>>> -
>>> >
>>> > > > - Show quoted text -
>>> >
>>> > > --
>>> > > You received this message because you are subscribed to the Google
>>> Groups
>>> > > "Algorithm Geeks" group.
>>> > > To post to this group, send email to algogeeks@googlegroups.com.
>>> > > To unsubscribe from this group, send email to
>>> > > algogeeks+unsubscr...@googlegroups.com.
>>> > > For more options, visit this group at
>>> > >http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > --
>>> > Sunny Aggrawal
>>> > B-Tech IV year,CSI
>>> > Indian Institute Of Technology,Roorkee- Hide quoted text -
>>> >
>>> > - Show quoted text -
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>&

Re: [algogeeks] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread varun pahwa
@ankit: no need to use hash table for that.
simply run two pointers one from 0 and second from n - 1.

On Mon, Jun 27, 2011 at 2:51 PM, ankit sambyal wrote:

> @Bharath : Cud u plz explain how r u searching the elements in O(n) time?
> Because if we use binary search, it will have O(n*log n )  worst case
> time complexity. One way in which I think it cud be made O(n) is that
> we can use a hash table, with a good hash function apart frm the
> array. And then for each element 'm' in the array, we cud search if
> there is an element (sum - m) in O(1) time by using hash table. Still
> we can't assure O(n) time complexity. Because coming up with a good
> hash function is not easy. Again, hash table takes more space
>
>
>
>
> On Mon, Jun 27, 2011 at 1:40 AM, Nishant Mittal
>  wrote:
> > do inorder traversal of tree and store values in an array.
> > Now find pairs by applying binary search on array..
> >
> > On 6/27/11, manish kapur  wrote:
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS question

2011-06-27 Thread varun pahwa
reverse all strings and then sort.

On Mon, Jun 27, 2011 at 2:28 PM, Nishant Mittal
wrote:

> WAP to sort an array of character strings on the basis of last
> character of each string
> eg:- {xxxc , yyya, zzzb} => {yyya , zzzb, xxxc}
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Sort - Consecutive Array in O(n)

2011-06-25 Thread varun pahwa
1 thing i forgot to mention in my above post that at first i will also check
max - min + 1 must be equal to n. then only move further else the array will
not be consecutive after sort.
I think it will give correct output. please tell if any counter example.

On Sat, Jun 25, 2011 at 2:29 AM, pacific :-)  wrote:

> My approach :
> 1. Find the median.
> 1.5 Check if the median is min  + (max - min ) / 2.
> 2. Partition the array into two sub arrays using the partition function of
> quicksort.
> 3. Check if the subarrays also satisfy the constraint.
>
> Complexity : T(n)  = 2 T(n/2) + O(1) :: O(nlogn)
>
>
>
>
> On Sat, Jun 25, 2011 at 12:15 PM, varun pahwa wrote:
>
>> will this work.
>> n size of array.
>> cal (a[i] - min(arr) + 1).
>> now cal sum of a[i], cal square sum of array as (a[i] * a[i]) , cal cube
>> sum of array as (a[i] * a[i] * a[i]). now if array elements are consecutive
>> then sum must be n * (n + 1) / 2. square sum must be (n * (n + 1) * (2n + 1)
>> )/ 6 and cube sum must be (n * (n + 1) / 2) ^ 2.
>>
>>
>>
>> On Fri, Jun 24, 2011 at 11:00 PM, Adarsh  wrote:
>>
>>> I think I got an work around for this if number of elements are
>>> not odd why not make them odd :)
>>> I variation to my prev algo
>>>
>>> int n = A.size();
>>> for (int i=0; i>>total += A[i];
>>> findMinMax(A[1...n]); //returns first smallest (fmin), second smallest
>>> (smin) and largest (max) element in array
>>>
>>> int fmean = (max+fmin)/2;
>>> int smean = (max+smin)/2;
>>> stotal = total - fmin;
>>> if ((total - n*fmean) == 0)
>>> {
>>>if ((stotal - n*smean) == 0)
>>>printf("consecutive\n");
>>>return;
>>> }
>>> printf("not consecutive\n");
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Varun Pahwa
>> B.Tech (IT)
>> 7th Sem.
>> Indian Institute of Information Technology Allahabad.
>> Ph : 09793899112 ,08011820777
>> Official Email :: rit2008...@iiita.ac.in
>> Another Email :: varunpahwa.ii...@gmail.com
>>
>> People who fail to plan are those who plan to fail.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> regards,
> chinna.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Binary Tree

2011-06-25 Thread varun pahwa
>> >>>>>>> Keep a buffer of all the leaf nodes..take two leaf nodes and
> find
> >> the
> >> >>>>>>> LCA..compute sum from root to LCA and subtract it from the sum
> of
> >> >>>>>>> nodes from
> >> >>>>>>> root to the leaves...store all the sums and find maximum out of
> >> it..
> >> >>>>>>>
> >> >>>>>>> On Tue, Jun 21, 2011 at 4:52 PM, Anantha Krishnan <
> >> >>>>>>> ananthakrishnan@gmail.com> wrote:
> >> >>>>>>>
> >> >>>>>>>> Hi All,
> >> >>>>>>>>
> >> >>>>>>>> Given a binary tree, find 2 leaf nodes say X and Y such that
> >> F(X,Y)
> >> >>>>>>>> is maximum where F(X,Y) = sum of nodes in the path from root to
> X
> >> +
> >> >>>>>>>> sum of
> >> >>>>>>>> nodes in the path from root to Y - sum of nodes in the common
> >> >>>>>>>> path
> >> >>>>>>>> from root
> >> >>>>>>>> to first common ancestor of the Nodes X and Y.
> >> >>>>>>>>
> >> >>>>>>>> Any ideas.
> >> >>>>>>>>
> >> >>>>>>>> Thanks & Regards
> >> >>>>>>>> Anantha Krishnan
> >> >>>>>>>>
> >> >>>>>>>> --
> >> >>>>>>>> You received this message because you are subscribed to the
> >> >>>>>>>> Google
> >> >>>>>>>> Groups "Algorithm Geeks" group.
> >> >>>>>>>> To post to this group, send email to
> algogeeks@googlegroups.com.
> >> >>>>>>>> To unsubscribe from this group, send email to
> >> >>>>>>>> algogeeks+unsubscr...@googlegroups.com.
> >> >>>>>>>> For more options, visit this group at
> >> >>>>>>>> http://groups.google.com/group/algogeeks?hl=en.
> >> >>>>>>>>
> >> >>>>>>>
> >> >>>>>>>
> >> >>>>>>>
> >> >>>>>>> --
> >> >>>>>>> *Piyush Sinha*
> >> >>>>>>> *IIIT, Allahabad*
> >> >>>>>>> *+91-8792136657*
> >> >>>>>>> *+91-7483122727*
> >> >>>>>>> *https://www.facebook.com/profile.php?id=10655377926 *
> >> >>>>>>>
> >> >>>>>>>  --
> >> >>>>>>> You received this message because you are subscribed to the
> Google
> >> >>>>>>> Groups "Algorithm Geeks" group.
> >> >>>>>>> To post to this group, send email to algogeeks@googlegroups.com
> .
> >> >>>>>>> To unsubscribe from this group, send email to
> >> >>>>>>> algogeeks+unsubscr...@googlegroups.com.
> >> >>>>>>> For more options, visit this group at
> >> >>>>>>> http://groups.google.com/group/algogeeks?hl=en.
> >> >>>>>>>
> >> >>>>>>
> >> >>>>>>
> >> >>>>>>
> >> >>>>>> --
> >> >>>>>> Sunny Aggrawal
> >> >>>>>> B-Tech IV year,CSI
> >> >>>>>> Indian Institute Of Technology,Roorkee
> >> >>>>>>
> >> >>>>>>
> >> >>>>>>  --
> >> >>>>>> You received this message because you are subscribed to the
> Google
> >> >>>>>> Groups "Algorithm Geeks" group.
> >> >>>>>> To post to this group, send email to algogeeks@googlegroups.com.
> >> >>>>>> To unsubscribe from this group, send email to
> >> >>>>>> algogeeks+unsubscr...@googlegroups.com.
> >> >>>>>> For more options, visit this group at
> >> >>>>>> http://groups.google.com/group/algogeeks?hl=en.
> >> >>>&

Re: [algogeeks] Re: Sort - Consecutive Array in O(n)

2011-06-24 Thread varun pahwa
will this work.
n size of array.
cal (a[i] - min(arr) + 1).
now cal sum of a[i], cal square sum of array as (a[i] * a[i]) , cal cube sum
of array as (a[i] * a[i] * a[i]). now if array elements are consecutive then
sum must be n * (n + 1) / 2. square sum must be (n * (n + 1) * (2n + 1) )/ 6
and cube sum must be (n * (n + 1) / 2) ^ 2.


On Fri, Jun 24, 2011 at 11:00 PM, Adarsh  wrote:

> I think I got an work around for this if number of elements are
> not odd why not make them odd :)
> I variation to my prev algo
>
> int n = A.size();
> for (int i=0; itotal += A[i];
> findMinMax(A[1...n]); //returns first smallest (fmin), second smallest
> (smin) and largest (max) element in array
>
> int fmean = (max+fmin)/2;
> int smean = (max+smin)/2;
> stotal = total - fmin;
> if ((total - n*fmean) == 0)
> {
>if ((stotal - n*smean) == 0)
>printf("consecutive\n");
>return;
> }
> printf("not consecutive\n");
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: strings

2011-06-22 Thread varun pahwa
nd email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
>
> Regards ,
>
> --
> Rohit Sindhu
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon - Longest palindrome in a string in O(n)

2011-06-22 Thread varun gupta
That is what ankit said.

Consider string: abcdecba
Reverse of above string: abcedcba
Longest common substring: abc and cba :

you are calculating longest common *subsequence* not substring. Substring in
continuous.


On Wed, Jun 22, 2011 at 10:48 PM, sunny agrawal wrote:

> LCS stands for Longest Common Substring
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Warm Regards,
Varun Kumar
Email Id: varun.gt...@gmail.com
Contact: +91-9711751235

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon - Longest palindrome in a string in O(n)

2011-06-22 Thread varun gupta
Does the question mean non-continuous substring? I think it should be
continuous substring which is palindrome with in the given string. LCS
wouldn't solve problem in this case.

On Wed, Jun 22, 2011 at 10:29 PM, sunny agrawal wrote:

> LCS is abcdcba or abcecba
> not abc or cba
>
>
> On Wed, Jun 22, 2011 at 10:15 PM, ankit mehta wrote:
>
>> Consider string: abcdecba
>> Reverse of above string: abcedcba
>> Longest common substring: abc and cba : Both not Palindromes!
>>
>> On Jun 22, 9:29 pm, sanjay ahuja  wrote:
>> > Suffix tree can solve longest common substring problem in o(n)
>> > and longest palindrome in string S is nothing but longest common
>> > substring between string s and its reverse.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Wed, Jun 22, 2011 at 9:31 PM, ankit mehta 
>> wrote:
>> > > You dont have to create longest palindrome, you have to find the
>> > > longest palindrome.
>> >
>> > > On Jun 22, 7:19 pm, SVIX  wrote:
>> > >> couldn't we just collect all the letters that occur more than twice
>> > >> and play them back even number of times symmetrically? and if there
>> > >> are more letters left, we can put one of them in the center...
>> >
>> > >> linear time need additional memory for some kind of hashing
>> >
>> > >> On Jun 21, 11:31 am, Swathi  wrote:
>> >
>> > >> > Does any one know how to return the "Longest palindrome in a string
>> in
>> > >> > O(n)".
>> > >> > From googling i found that we can use suffix trees but there is no
>> code. I
>> > >> > am looking for logic and also for running code.
>> >
>> > >> > Thanks,
>> > >> > Swathi
>> >
>> > > --
>> > > You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> > > To post to this group, send email to algogeeks@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> > > For more options, visit this group athttp://
>> groups.google.com/group/algogeeks?hl=en.
>> >
>> > --
>> > Sanjay Ahuja,
>> > Analyst, Financing Prime Brokerage
>> > Nomura Securities India Pvt. Ltd
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Warm Regards,
Varun Kumar
Email Id: varun.gt...@gmail.com
Contact: +91-9711751235

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [brain teaser ] Probability Riddle Loaded Revolver 13 june

2011-06-17 Thread varun pahwa
oose?
>>>> >>>>>
>>>> >>>>> Update Your Answers at : Click Here
>>>> >>>>>
>>>> >>>>> Solution:
>>>> >>>>> Will be updated after 1 day
>>>> >>>>>
>>>> >>>>>
>>>> >>>>>
>>>> >>>>> --
>>>> >>>>>
>>>> >>>>> "Never explain yourself. Your friends don’t
>>>> need it
>>>> >>>>> and your enemies won’t believe it" .
>>>> >>>>>
>>>> >>>>> --
>>>> >>>>> You received this message because you are subscribed to the Google
>>>> >>>>> Groups "Algorithm Geeks" group.
>>>> >>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> >>>>> To unsubscribe from this group, send email to
>>>> >>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> >>>>> For more options, visit this group at
>>>> >>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>> --
>>>> >>>> Sunny Aggrawal
>>>> >>>> B-Tech IV year,CSI
>>>> >>>> Indian Institute Of Technology,Roorkee
>>>> >>>>
>>>> >>>> --
>>>> >>>> You received this message because you are subscribed to the Google
>>>> >>>> Groups "Algorithm Geeks" group.
>>>> >>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> >>>> To unsubscribe from this group, send email to
>>>> >>>> algogeeks+unsubscr...@googlegroups.com.
>>>> >>>> For more options, visit this group at
>>>> >>>> http://groups.google.com/group/algogeeks?hl=en.
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >>> --
>>>> >>> Piyush Sinha
>>>> >>> IIIT, Allahabad
>>>> >>> +91-8792136657
>>>> >>> +91-7483122727
>>>> >>> https://www.facebook.com/profile.php?id=10655377926
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Piyush Sinha
>>>> >> IIIT, Allahabad
>>>> >> +91-8792136657
>>>> >> +91-7483122727
>>>> >> https://www.facebook.com/profile.php?id=10655377926
>>>> >>
>>>> >> --
>>>> >> You received this message because you are subscribed to the Google
>>>> Groups
>>>> >> "Algorithm Geeks" group.
>>>> >> To post to this group, send email to algogeeks@googlegroups.com.
>>>> >> To unsubscribe from this group, send email to
>>>> >> algogeeks+unsubscr...@googlegroups.com.
>>>> >> For more options, visit this group at
>>>> >> http://groups.google.com/group/algogeeks?hl=en.
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> Groups
>>>> > "Algorithm Geeks" group.
>>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>>> > To unsubscribe from this group, send email to
>>>> > algogeeks+unsubscr...@googlegroups.com.
>>>> > For more options, visit this group at
>>>> > http://groups.google.com/group/algogeeks?hl=en.
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> ---
>>>> Douglas Gameiro Diniz
>>>> Engenheiro de Computação - 2003 - UNICAMP
>>>>
>>>> Mobile: (19) 92158777
>>>> Gtalk: dgdiniz
>>>> Msn: thedougdi...@hotmail.com
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>
>>>
>>> --
>>> Sunny Aggrawal
>>> B-Tech IV year,CSI
>>> Indian Institute Of Technology,Roorkee
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards,
>> Arpit Sood
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread varun pahwa
t; wrote:
>>> >>>>>>
>>> >>>>>> In 1st program, 2nd printf requires one more argument. And
>>> basically
>>> >>>>>> %a is used for printing a double value in hex. see "man 3 printf".
>>> >>>>>>
>>> >>>>>> On Sat, Jun 11, 2011 at 5:29 PM, nicks <
>>> crazy.logic.k...@gmail.com>
>>> >>>>>> wrote:
>>> >>>>>> > Hello friends..plz help me in understanding the following C
>>> Output
>>> >>>>>> >
>>> >>>>>> > first one is --
>>> >>>>>> >
>>> >>>>>> > #include
>>> >>>>>> > #include
>>> >>>>>> > main()
>>> >>>>>> > {
>>> >>>>>> > int a=5;
>>> >>>>>> > printf("a=%d\n",a);
>>> >>>>>> > printf("%a=%d",a);
>>> >>>>>> > getch();
>>> >>>>>> > }
>>> >>>>>> > OUTPUT -
>>> >>>>>> > a=5
>>> >>>>>> > 0x1.2ff380p-1021=4199082
>>> >>>>>> >
>>> >>>>>> >
>>> >>>>>> > and the other one is --
>>> >>>>>> >
>>> >>>>>> > #include
>>> >>>>>> > # include 
>>> >>>>>> > int i=2;
>>> >>>>>> > main()
>>> >>>>>> > {
>>> >>>>>> >  void add();
>>> >>>>>> >  add(i++,--i);
>>> >>>>>> > printf("\ni=%d \n",i);system("pause");
>>> >>>>>> > }
>>> >>>>>> > void add(int a ,int b)
>>> >>>>>> > {
>>> >>>>>> >  printf("\na=%d b=%d",a,b);
>>> >>>>>> > }
>>> >>>>>> >
>>> >>>>>> >  OUTPUT -
>>> >>>>>> > a=1 b=1
>>> >>>>>> > i=2
>>> >>>>>> >
>>> >>>>>> > --
>>> >>>>>> > You received this message because you are subscribed to the
>>> Google
>>> >>>>>> > Groups
>>> >>>>>> > "Algorithm Geeks" group.
>>> >>>>>> > To post to this group, send email to algogeeks@googlegroups.com
>>> .
>>> >>>>>> > To unsubscribe from this group, send email to
>>> >>>>>> > algogeeks+unsubscr...@googlegroups.com.
>>> >>>>>> > For more options, visit this group at
>>> >>>>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >>>>>> >
>>> >>>>>>
>>> >>>>>> --
>>> >>>>>> You received this message because you are subscribed to the Google
>>> >>>>>> Groups "Algorithm Geeks" group.
>>> >>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> >>>>>> To unsubscribe from this group, send email to
>>> >>>>>> algogeeks+unsubscr...@googlegroups.com.
>>> >>>>>> For more options, visit this group at
>>> >>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>> >>>>>>
>>> >>>>>
>>> >>>>> --
>>> >>>>> You received this message because you are subscribed to the Google
>>> >>>>> Groups "Algorithm Geeks" group.
>>> >>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> >>>>> To unsubscribe from this group, send email to
>>> >>>>> algogeeks+unsubscr...@googlegroups.com.
>>> >>>>> For more options, visit this group at
>>> >>>>> http://groups.google.com/group/algogeeks?hl=en.
>>> >>>>
>>> >>>> --
>>> >>>> You received this message because you are subscribed to the Google
>>> >>>> Groups "Algorithm Geeks" group.
>>> >>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> >>>> To unsubscribe from this group, send email to
>>> >>>> algogeeks+unsubscr...@googlegroups.com.
>>> >>>> For more options, visit this group at
>>> >>>> http://groups.google.com/group/algogeeks?hl=en.
>>> >>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>>
>>> >>>   Regards
>>> >>> Himanshu Kansal
>>> >>>   Msc Comp. sc.
>>> >>> (University of Delhi)
>>> >>>
>>> >>> --
>>> >>> You received this message because you are subscribed to the Google
>>> Groups
>>> >>> "Algorithm Geeks" group.
>>> >>> To post to this group, send email to algogeeks@googlegroups.com.
>>> >>> To unsubscribe from this group, send email to
>>> >>> algogeeks+unsubscr...@googlegroups.com.
>>> >>> For more options, visit this group at
>>> >>> http://groups.google.com/group/algogeeks?hl=en.
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> Groups
>>> >> "Algorithm Geeks" group.
>>> >> To post to this group, send email to algogeeks@googlegroups.com.
>>> >> To unsubscribe from this group, send email to
>>> >> algogeeks+unsubscr...@googlegroups.com.
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Algorithm Geeks" group.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > algogeeks+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>>
>>>
>>>
>>> --
>>> Sanjay Ahuja,
>>> Analyst, Financing Prime Brokerage
>>> Nomura Securities India Pvt. Ltd
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [brain teaser ] Find next number in series 10 june

2011-06-10 Thread varun pahwa
may be 42,47. actually table of seven and a digit 7.

On Fri, Jun 10, 2011 at 3:29 AM, nicks  wrote:

> @ankur..how did you get that...explain..plz
>
> On Fri, Jun 10, 2011 at 3:11 AM, ankur aggarwal 
> wrote:
>
>> 42, 49
>>
>>
>> 2011/6/10 • » νιρυℓ « • 
>>
>>> 42, 47
>>> just guessing according to the pattern.
>>>
>>>
>>> On Fri, Jun 10, 2011 at 1:37 PM, Lavesh Rawat wrote:
>>>
>>>> *Find next number in series
>>>> * * ***
>>>> *
>>>> *
>>>> **
>>>> *What are the next two numbers in this sequence?
>>>>
>>>> 7, 14, 17, 21, 27, 28, 35, 37, ?, ?
>>>> * *
>>>> *
>>>>
>>>> *Update Your Answers at* : Click 
>>>> Here<http://dailybrainteaser.blogspot.com/2011/06/find-next-number-in-series-10-june.html?lavesh=lavesh>
>>>>
>>>>  Solution:
>>>> Will be updated after 1 day
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> "Never explain yourself. Your friends don’t need it
>>>> and your enemies won’t believe it" .
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Vipul
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> :)
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread varun pahwa
can anyone explain "Since there
are less than 2^32 numbers in the file there is bound to be one number
in the array that is less than 2^16." in dumanshu's solution.

On Fri, Jun 10, 2011 at 12:39 PM, varun pahwa wrote:

> @ankit :please explain by taking an example.
>
>
> On Fri, Jun 10, 2011 at 12:13 PM, Vetri Balaji wrote:
>
>> @ankit: pls explain the time complexity..
>> i dont think its O(log n)
>>
>>
>> On Thu, Jun 9, 2011 at 11:57 PM, ankit sambyal wrote:
>>
>>> @Dumanshu:  In each iteration, we r removing the smallest number. If
>>> at any iteration we can't find the next smallest no., it means that
>>> no. is missing.
>>>
>>>
>>>
>>> On Thu, Jun 9, 2011 at 10:54 AM, Dumanshu  wrote:
>>> > hey... we have 300 million (9- digit) numbers. So we have to print a
>>> > number which isn't already there in the file.
>>> > We are not given that number beforehand. You are saying to check "u
>>> > are going to check whether a number N exist ".
>>> >
>>> > On Jun 9, 4:46 pm, radha krishnan 
>>> > wrote:
>>> >> Ma approach is to xor the given number with all numbers in the file !!
>>> >> This takes O(n)
>>> >> I think we cant achieve a complexity >> >> we have to scan the file at least once
>>> >>
>>> >> Or move to this problem
>>> >> Instead of a file with numbers
>>> >> you have a stream of numbers
>>> >>
>>> >> Create a Trie and insert every number from the stream by reversing the
>>> >> digits of the number
>>> >> Now u have a Trie (left as 0 bit && right as 1 bit )
>>> >>
>>> >> u are going to check whether a number N exist
>>> >> reverse the bits of N
>>> >> search for appropriate bit in the Trie
>>> >> if all bit are matched then there is a number !!
>>> >> else No
>>> >>
>>> >> But Space Complexity Of Trie is high  we need (32 *(O(n)) assuming
>>> each
>>> >> integer is of 32 bits
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Thu, Jun 9, 2011 at 4:54 PM, Dumanshu  wrote:
>>> >> > Given a file containing roughly 300 million social security
>>> numbers(9-
>>> >> > digit numbers) find a 9-digit number that isnt there in the file.
>>> You
>>> >> > have unlimited drive space but only 2mb of RAM.
>>> >>
>>> >> > Solution is as follows:
>>> >> > In the first step, we build an array of 2^16 integers that is
>>> >> > initialized to 0 and for every number in the file we take its 16
>>> most
>>> >> > significant
>>> >> > bit to index into this array and increment that number. Since there
>>> >> > are less than 2^32 numbers in the file there is bound to be one
>>> number
>>> >> > in the array that is less than 2^16 . This tells us that there is at
>>> >> > least one number missing among the possible numbers with those upper
>>> >> > bits. In the second pass, we can focus only on the numbers that
>>> match
>>> >> > this criterion and use a bit-vector of size 2^16 to identify one of
>>> >> > the missing numbers.
>>> >>
>>> >> > Someone plz explain this solution( may be using some small values
>>> >> > numbers) or suggest another approach.
>>> >>
>>> >> > --
>>> >> > You received this message because you are subscribed to the Google
>>> Groups
>>> >> > "Algorithm Geeks" group.
>>> >> > To post to this group, send email to algogeeks@googlegroups.com.
>>> >> > To unsubscribe from this group, send email to
>>> >> > algogeeks+unsubscr...@googlegroups.com.
>>> >> > For more options, visit this group at
>>> >> >http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> algogeeks+u

Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread varun pahwa
@ankit :please explain by taking an example.

On Fri, Jun 10, 2011 at 12:13 PM, Vetri Balaji wrote:

> @ankit: pls explain the time complexity..
> i dont think its O(log n)
>
>
> On Thu, Jun 9, 2011 at 11:57 PM, ankit sambyal wrote:
>
>> @Dumanshu:  In each iteration, we r removing the smallest number. If
>> at any iteration we can't find the next smallest no., it means that
>> no. is missing.
>>
>>
>>
>> On Thu, Jun 9, 2011 at 10:54 AM, Dumanshu  wrote:
>> > hey... we have 300 million (9- digit) numbers. So we have to print a
>> > number which isn't already there in the file.
>> > We are not given that number beforehand. You are saying to check "u
>> > are going to check whether a number N exist ".
>> >
>> > On Jun 9, 4:46 pm, radha krishnan 
>> > wrote:
>> >> Ma approach is to xor the given number with all numbers in the file !!
>> >> This takes O(n)
>> >> I think we cant achieve a complexity > >> we have to scan the file at least once
>> >>
>> >> Or move to this problem
>> >> Instead of a file with numbers
>> >> you have a stream of numbers
>> >>
>> >> Create a Trie and insert every number from the stream by reversing the
>> >> digits of the number
>> >> Now u have a Trie (left as 0 bit && right as 1 bit )
>> >>
>> >> u are going to check whether a number N exist
>> >> reverse the bits of N
>> >> search for appropriate bit in the Trie
>> >> if all bit are matched then there is a number !!
>> >> else No
>> >>
>> >> But Space Complexity Of Trie is high  we need (32 *(O(n)) assuming each
>> >> integer is of 32 bits
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On Thu, Jun 9, 2011 at 4:54 PM, Dumanshu  wrote:
>> >> > Given a file containing roughly 300 million social security
>> numbers(9-
>> >> > digit numbers) find a 9-digit number that isnt there in the file. You
>> >> > have unlimited drive space but only 2mb of RAM.
>> >>
>> >> > Solution is as follows:
>> >> > In the first step, we build an array of 2^16 integers that is
>> >> > initialized to 0 and for every number in the file we take its 16 most
>> >> > significant
>> >> > bit to index into this array and increment that number. Since there
>> >> > are less than 2^32 numbers in the file there is bound to be one
>> number
>> >> > in the array that is less than 2^16 . This tells us that there is at
>> >> > least one number missing among the possible numbers with those upper
>> >> > bits. In the second pass, we can focus only on the numbers that match
>> >> > this criterion and use a bit-vector of size 2^16 to identify one of
>> >> > the missing numbers.
>> >>
>> >> > Someone plz explain this solution( may be using some small values
>> >> > numbers) or suggest another approach.
>> >>
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> Groups
>> >> > "Algorithm Geeks" group.
>> >> > To post to this group, send email to algogeeks@googlegroups.com.
>> >> > To unsubscribe from this group, send email to
>> >> > algogeeks+unsubscr...@googlegroups.com.
>> >> > For more options, visit this group at
>> >> >http://groups.google.com/group/algogeeks?hl=en.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> > To post to this group, send email to algogeeks@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS Interview

2011-06-09 Thread varun pahwa
2nd part can be done just take the xor of all the numbers same number xor
returns 0 so only seven will remain.
1st part can be done in O(n) because estimate sum -> n*(n+1)/2. now sub from
estimated sum each array element. the last value remained is the missing
number.
correct me if i am wrong.

On Thu, Jun 9, 2011 at 9:59 AM, Ershad K  wrote:

> On Thursday 09 June 2011 03:15 PM, Dumanshu wrote:
>
>> Q1. I  have a file in which there are supposed to be 4 billion
>> numbers,
>> starting from 1 to 4,000,000,000 but unfortunately one number is
>> missing,
>> i.e there are only 3,999,999,999 numbers, I need to find the missing
>> number.
>>
>
> Is the array sorted?
>
> --
> Sincerely,
> Ershad K
> http://ershadk.wordpress.com
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: finding whether sum of two numbers of array is equal to given number or not ? plz tell why my this is not working for x=10,11,13 values

2011-06-08 Thread varun pahwa
may be now it works for all. please correct me if i am wrong.you haven't put
termination in binary search.

#include
using namespace std;
void merge(int A[],int p,int q,int r)
{
int n1=q-p+1;int n2=r-q;
int L[n1];
int R[n2];
for(int i=0;iA[mid])
result=binary_search(A,mid+1,right,val);
else
result= mid;
return result;
}
return -1;
}


//main function
int main()
{
int A[]={3,2,4,6,1,2,4,5,7};
merge_sort(A,0,8);
for(int i=0;i<9;i++)
cout<>x;
int pos;int flag=0;int i;
for( i=0;i<10;i++)
{
 if((x-A[i])>0&&(pos=binary_search(A,i+1,9,x-A[i]))>=0)
{flag=1;break;}
}
if(flag)
{
cout<<"There are  two whose sum is equal to given number"<> --
>> **With Regards
>> Deoki Nandan Vishwakarma
>> IITR MCA
>> *
>> *
>>
>>
>
>
> --
> **With Regards
> Deoki Nandan Vishwakarma
> IITR MCA
> *
> *
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Difference btwn elements in a sorted array a-b=k

2011-06-07 Thread varun pahwa
t;> >>
>>> >>
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Algorithm Geeks" group.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > algogeeks+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> >
>>>
>>>
>>> --
>>> *Piyush Sinha*
>>> *IIIT, Allahabad*
>>> *+91-8792136657*
>>> *+91-7483122727*
>>> *https://www.facebook.com/profile.php?id=10655377926 *
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> *Piyush Sinha*
> *IIIT, Allahabad*
> *+91-8792136657*
> *+91-7483122727*
> *https://www.facebook.com/profile.php?id=10655377926 *
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112 ,08011820777
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

<<329.gif>>

Re: [algogeeks] Re: A Graph Problem

2011-06-05 Thread Varun Nagpal
Maybe this problem is related to pigeon hole problem

On Mon, May 30, 2011 at 8:44 AM, Aakash Johari wrote:

> No, won't work. :(
>
>
> On Sun, May 29, 2011 at 11:39 PM, Aakash Johari wrote:
>
>> Can this solution work?
>>
>> Create adjacency matrix where adj[i][j] representing person i doesnt like
>>> person j. Now toggle the relations (means now the adj[i][j] will represent
>>> person i and person j can live with each other) and find the no. of
>>> connected components. No. of connected components will be the number of
>>> rooms required.
>>>
>>
>>
>> On Sun, May 29, 2011 at 11:29 PM, Aakash Johari wrote:
>>
>>> yes, sorry.. i misunderstood the problem.
>>>
>>>
>>> On Sun, May 29, 2011 at 11:24 PM, anshu mishra <
>>> anshumishra6...@gmail.com> wrote:
>>>
 biaprtie graph is special case when we can color the whole graph just
 by two colors.

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>>
>>> --
>>> -Aakash Johari
>>> (IIIT Allahabad)
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> -Aakash Johari
>> (IIIT Allahabad)
>>
>>
>>
>>
>>
>
>
> --
> -Aakash Johari
> (IIIT Allahabad)
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Puzzle

2011-05-27 Thread varun pahwa
i think 11.

On Fri, May 27, 2011 at 3:06 PM, Arpit Mittal wrote:

> 8?
>
>
> On Fri, May 27, 2011 at 2:26 AM, anil chopra wrote:
>
>> 11
>>
>> On Fri, May 13, 2011 at 12:14 AM, amit  wrote:
>>
>>> Consider a series in which 8 teams are participating. each team plays
>>> twice with all other teams. 4 of them will go to the semi final.How
>>> many matches should a team win, so that it will ensure that it will go
>>> to semi finals.?
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> -Arpit Mittal
> 6th Semester,
> Indian Institute of Information Technology,Allahabad
> Email : arpitmittal.ii...@gmail.com
>rit2008...@iiita.ac.in
> Contact : +91-8853049787
>
> Let every man be respected as an individual and no man idolized.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Varun Pahwa
B.Tech (IT)
6th Sem.
Indian Institute Of Information Technology Allahabad(Amethi Campus)
Ph : 09793899112 ,07206833114
Official Email :: rit2008...@iiita.ac.in
Another Email :: varunpahwa.ii...@gmail.com

People who fail to plan are those who plan to fail.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] If anyone have this book please mail me Thanks in advance

2011-05-01 Thread Varun Nagpal
Please refrain from sharing such links and engaging in piracy.

I kindly request the admin of this forum to delete all such posts and to
warn the users on the forum for possible barring in case they are found to
use this forum for piracy and malpractices.

On Sat, Apr 30, 2011 at 12:09 PM, Charles Turner  wrote:

> This doesn't look legal to me. Has the author allowed you to redistribute
> their book? I can't see any such evidence.
>
> If you don't have permission to redistribute the book, you're breaking the
> law. This is a serious offence. You are lowering the reputation of this
> list.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] A SIMPLE C++ PROGRAM.

2011-04-29 Thread Varun Nagpal
I think these questions are stupid in the sense that no one would ever use
these constructs in their production code unless someone wants to write an
obscure obfuscated code in some competition. Many times similar expressions
are non-portable.

Anyways, to understand this and related concepts, please see iso c or c++
standard and try to understand operator precedence, operator associativity
and sequence points.

On Fri, Apr 29, 2011 at 3:06 PM, Nikhil Gupta wrote:

> 12
> 5
>
> because y=4+4+3+1
> and x is incremented to 5
>
>
> On Fri, Apr 29, 2011 at 2:01 PM, MANNU  wrote:
>
>> *Can anyone please explain me the output of this program:*
>>
>> int x=1;
>> int y=x++ + ++x + ++x + x++;
>> cout<> cout<>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Nikhil Gupta
> Senior Co-ordinator, Publicity
> CSI, NSIT Students' Branch
> NSIT, New Delhi, India
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Clock Algorithm

2011-03-04 Thread Varun Nagpal
I do know about event based simulation in digital circuit simulators..

It would be interesting to know.what exactly algorithms they use

On Fri, Mar 4, 2011 at 5:27 PM, Luciano Junior wrote:

> Hello,
>
> I need a clock algorithm to use with in a simulation system that I be
> creating.
>
> Someone have any Idea ?
> --
> 
> Luciano Soares Pinheiro Jr.
> Analista desenvolvedor Sr.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Parallel algorithms

2011-02-26 Thread Varun Nagpal
Practical - Good mix of theory and practice
1. The Art of Multiprocessor Programming" by Maurice Herlihy & Nir Shavit
2. Introduction to Parallel Computing, Second Edition. By Ananth Grama,
Anshul Gupta, George Karypis, Vipin Kumar
3. Herb Sutter's Blog on Concurrency

API Specific
4. Oreilly's Intel TBB.
5. Programming Massively Parallel Processors (CUDA)
6. Using OpenMP Portable Shared Memory Parallel Programming

Advanced and more theoretical
- Principles of Concurrent and Distributed Programming by M.Ben Ari

On Fri, Feb 18, 2011 at 3:07 PM, Umer Farooq  wrote:

> Hello,
>
> Can anyone suggest me a good book for parallel algorithms?
>
> --
> Umer
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Intel Question

2011-01-26 Thread Varun Nagpal
I understand the algorithm, but what is the question?

On Wed, Jan 26, 2011 at 10:10 AM, bittu  wrote:

> In order to make their newest microcontroller as cheap as possible,
> the ACME Widget Company designed it with a very simple cache. The
> processor is connected to a slow memory system that contains n bytes,
> numbered 0 to n - 1. The cache holds a copy of k of these bytes at a
> time, for fast access. It has a base address (referred to as base
> below), and it holds a copy of the bytes numbered base, base+1, ...,
> base+k-1. When a program reads a byte, the cache controller executes
> the following algorithm:
>
>   1. Find a new range of k bytes which contains the requested byte,
> such that the difference between the old and new base addresses is
> minimized. Note that if the requested byte was already in the cache,
> then the base address will not change.
>   2. Update the cache to the new range by reading from the memory
> system any bytes that are in the new range but not the old range, and
> discarding any bytes that were in the old range but not the new range.
>   3. Return the requested byte to the program.
>
> To analyze the performance of a program, you wish to know how many
> bytes are read from the memory system. The numbers of the bytes that
> the program reads are given in addresses, in the order that they are
> read. When the program starts, the base address is 0.
>
> Thanks & Regards
> Shashank
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Sorting algorithm

2010-08-23 Thread varun bhatia
Who said count sort does not uses extra space???

As faras I know, it does need extra space to need thr frequency of each and
every element within a given range..

Regards,

Varun Bhatia



On Mon, Aug 23, 2010 at 4:20 PM, Tanveer Asif wrote:

> Count sort..
>
>
> --
> *From:* Subhranil Banerjee 
> *To:* algogeeks@googlegroups.com
> *Sent:* Mon, August 23, 2010 3:36:12 AM
> *Subject:* [algogeeks] Sorting algorithm
>
> Can anyone suggest a sorting algorithm that sorts in linear time without
> using extra space.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] P ! = NP

2010-08-11 Thread Varun Nagpal
Yeah,,,...lets hope the next turing goes to this Indian. Its still being
verified.

On Thu, Aug 12, 2010 at 12:54 AM, Kishen Das  wrote:

>
> http://www.telegraph.co.uk/science/science-news/7938238/Computer-scientist-Vinay-Deolalikar-claims-to-have-solved-maths-riddle-of-P-vs-NP.html
>
> Check out this cool news.
>
> Kishen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Copy Constructor and reference

2010-08-06 Thread Varun Nagpal
As far as I know, one simple reason it takes reference to constant class
type is to make sure that the object being copied is not modified in copy
constructor. a object passed as non-const reference can be modified in copy
construcor.

If the formal argument of copy constructor is made as "T obj" instead of
usual "const T &obj", this simply involves copying the actual object in a
temporary object(created on the function stack), which again requires copy
constructor. In a way this is a recursive  call.

On Wed, Jul 21, 2010 at 9:08 AM, mallesh  wrote:

> In C++  Why is it that copy constructor uses only reference as
> parameter and not the actual class?
> I was given a hint that it has got something to do with stack. I think
> it has got something to do with reentrant functions.
>
> In C also., I think the same thing happens when we pass struct as
> parameter to a function, instead of copying the whole structure on to
> stack, it takes struct variable's address.
>
> Can you please explain why this is so?
>
> -Thanks and regards,
> Mallesh
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Google Interview Question

2010-07-14 Thread Varun Nagpal
First attempt: sort them and add the 2 largest numbers
2nd attempt: find 1st and 2nd largest number and add them.

On Wed, Jul 14, 2010 at 7:27 AM, Debajyoti Sarma
wrote:

> An array contains the set of positive integer. Find the largest number
> c such that c=a+b where a,b,c are distinct number of the set?
> [Consider , reducing complexity]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C++++

2010-07-11 Thread varun bhatia
public class sample
{
 const int a;

sample(int constValue):a(constvalue)
{

}

};

On Sun, Jul 11, 2010 at 8:17 AM, UMESH KUMAR wrote:

> Hello everybody
>
>   how to Assign Constant value in Class of C++
>Describe : Private,Protected, and Public Area in C++.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,

VARUN BHATIA

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



  1   2   >