Re: [algogeeks] Improve data store for this particular Code Chef problem to improve performance in time

2013-07-09 Thread abhishek sharma
Here is the link to problem - http://www.codechef.com/problems/COUNTARI

You can see my many unsuccessful attempts in All Submissions..

Ppl with successful submission have used a superb way to just use arrays to
solve this.. I hate those einsteins!


On Tue, Jul 9, 2013 at 5:56 PM, abhishek sharma wrote:

> @Tian tanx
>
>
> On Tue, Jul 9, 2013 at 5:55 PM, abhishek sharma 
> wrote:
>
>> Okay let me explain my approach -
>>
>> 1. Read numbers from the input stream and create an array of lists.. i
>> started with hashmaps and hashsets etc .. but they greatly killed
>> performance
>>
>> 2. Each index in the array holds the positions of that particular
>> index(in the stream) in a list..(I simply insert these positions in the
>> list at array[index]..)
>>
>> 3. Any such list (at any index in the array) is sorted at any given point
>> of time since the positions are only going to increase as we keep reading
>> input from stream..
>>
>> 4. Once the input is read, iterate over this data store in the following
>> manner -
>>
>> Let result holds the answer
>>
>> for i: 1 to 31 //>>>>>> Loop A
>> if(array[i].size > 2)
>> result += S(S-1)(S-2)/6
>> for(j: 2*i-1 to i+1)
>>  listRight = array[j]
>>  listLeft = array[i - (j-i)]
>>  for int x: array[i]
>>  //use Collections.binarySearch
>>  a = number of elements greater than x in listRight
>>  c = listRight.size - a
>>  b =  number of elements less than x in listLeft
>>  d = listLeft.Size - b
>>  result += a*b
>>  result += c*d// Explanation E
>>
>>  return result once Loop A is done..
>>
>> E = Suppose 6,.,4.,2 occur in the stream as well as 2...,4...,6
>> .. I need to capture both these as they both form an AP
>>
>> To improve time, it is recommended(on CodeChef, it uses SPOJ) to use
>> BufferedReader when reading long inputs from console.. Hence I am using
>> that ..
>>
>> My SkypeID: abhishekpc87iit.. Feel free to contact me .. always online..
>>
>>
>> On Tue, Jul 9, 2013 at 5:32 PM, Tian Guo  wrote:
>>
>>> Can you just briefly describe your algorithm and time complexity? Then
>>> we could know the problem and think about from which perspective to improve
>>> it.
>>>
>>> Thx!
>>>
>>>
>>> 2013/7/9 abhishek sharma 
>>>
>>>>
>>>>  Given *N* integers *A1, A2, …. AN*, Dexter wants to know how many
>>>> ways he can choose three numbers such that they are three consecutive terms
>>>> of an arithmetic progression.
>>>>
>>>> Meaning that, how many triplets *(i, j, k)* are there such that *1 ≤ i
>>>> < j < k ≤ N* and *Aj - Ai = Ak - Aj*.
>>>>
>>>> So the triplets (2, 5, 8), (10, 8, 6), (3, 3, 3) are valid as they are
>>>> three consecutive terms of an arithmetic progression. But the triplets (2,
>>>> 5, 7), (10, 6, 8) are not.
>>>> Input
>>>>
>>>> First line of the input contains an integer *N (3 ≤ N ≤ 10)*. Then
>>>> the following line contains *N* space separated integers *A1, A2, …, AN
>>>> * and they have values between *1* and *3* (inclusive).
>>>> Output
>>>>
>>>> Output the number of ways to choose a triplet such that they are three
>>>> consecutive terms of an arithmetic progression.
>>>> Example
>>>>
>>>> *Input:*
>>>> 10
>>>> 3 5 3 6 3 4 10 4 5 2
>>>> *Output:*
>>>> 9
>>>>
>>>> *I am attaching my solution..* I reached this solution after improving the 
>>>> performance 10 times.. but it is still not accepted as the time limit 
>>>> exceeds 3 seconds.
>>>>
>>>>
>>>>
>>>>
>>>> Can anyone please please suggest how to improve this ...
>>>> (I do not want a different approach .. I want to improve my approach)
>>>>
>>>> PS: This is a practice problem .. So I am not cheating :)
>>>>
>>>>
>>>> --
>>>> Nice Day
>>>>
>>>> Abhishek Sharma
>>>> Bachelor of Technology
>>>> IIT Kanpur (2009)
>>>>
>>>> --
>>>> 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.
>>>
>>>
>>>
>>
>>
>>
>> --
>> Nice Day
>>
>> Abhishek Sharma
>> Bachelor of Technology
>> IIT Kanpur (2009)
>>
>
>
>
> --
> Nice Day
>
> Abhishek Sharma
> Bachelor of Technology
> IIT Kanpur (2009)
>



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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] Improve data store for this particular Code Chef problem to improve performance in time

2013-07-09 Thread abhishek sharma
Okay let me explain my approach -

1. Read numbers from the input stream and create an array of lists.. i
started with hashmaps and hashsets etc .. but they greatly killed
performance

2. Each index in the array holds the positions of that particular index(in
the stream) in a list..(I simply insert these positions in the list at
array[index]..)

3. Any such list (at any index in the array) is sorted at any given point
of time since the positions are only going to increase as we keep reading
input from stream..

4. Once the input is read, iterate over this data store in the following
manner -

Let result holds the answer

for i: 1 to 31 //>>>>>> Loop A
if(array[i].size > 2)
result += S(S-1)(S-2)/6
for(j: 2*i-1 to i+1)
 listRight = array[j]
 listLeft = array[i - (j-i)]
 for int x: array[i]
 //use Collections.binarySearch
 a = number of elements greater than x in listRight
 c = listRight.size - a
 b =  number of elements less than x in listLeft
 d = listLeft.Size - b
 result += a*b
 result += c*d// Explanation E

return result once Loop A is done..

E = Suppose 6,.,4.,2 occur in the stream as well as 2...,4...,6 ..
I need to capture both these as they both form an AP

To improve time, it is recommended(on CodeChef, it uses SPOJ) to use
BufferedReader when reading long inputs from console.. Hence I am using
that ..

My SkypeID: abhishekpc87iit.. Feel free to contact me .. always online..


On Tue, Jul 9, 2013 at 5:32 PM, Tian Guo  wrote:

> Can you just briefly describe your algorithm and time complexity? Then we
> could know the problem and think about from which perspective to improve it.
>
> Thx!
>
>
> 2013/7/9 abhishek sharma 
>
>>
>>  Given *N* integers *A1, A2, …. AN*, Dexter wants to know how many ways
>> he can choose three numbers such that they are three consecutive terms of
>> an arithmetic progression.
>>
>> Meaning that, how many triplets *(i, j, k)* are there such that *1 ≤ i <
>> j < k ≤ N* and *Aj - Ai = Ak - Aj*.
>>
>> So the triplets (2, 5, 8), (10, 8, 6), (3, 3, 3) are valid as they are
>> three consecutive terms of an arithmetic progression. But the triplets (2,
>> 5, 7), (10, 6, 8) are not.
>> Input
>>
>> First line of the input contains an integer *N (3 ≤ N ≤ 10)*. Then
>> the following line contains *N* space separated integers *A1, A2, …, AN*and 
>> they have values between
>> *1* and *3* (inclusive).
>> Output
>>
>> Output the number of ways to choose a triplet such that they are three
>> consecutive terms of an arithmetic progression.
>> Example
>>
>> *Input:*
>> 10
>> 3 5 3 6 3 4 10 4 5 2
>> *Output:*
>> 9
>>
>> *I am attaching my solution..* I reached this solution after improving the 
>> performance 10 times.. but it is still not accepted as the time limit 
>> exceeds 3 seconds.
>>
>>
>> Can anyone please please suggest how to improve this ...
>> (I do not want a different approach .. I want to improve my approach)
>>
>> PS: This is a practice problem .. So I am not cheating :)
>>
>>
>> --
>> Nice Day
>>
>> Abhishek Sharma
>> Bachelor of Technology
>> IIT Kanpur (2009)
>>
>> --
>> 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.
>
>
>



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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] Improve data store for this particular Code Chef problem to improve performance in time

2013-07-09 Thread abhishek sharma
@Tian tanx


On Tue, Jul 9, 2013 at 5:55 PM, abhishek sharma wrote:

> Okay let me explain my approach -
>
> 1. Read numbers from the input stream and create an array of lists.. i
> started with hashmaps and hashsets etc .. but they greatly killed
> performance
>
> 2. Each index in the array holds the positions of that particular index(in
> the stream) in a list..(I simply insert these positions in the list at
> array[index]..)
>
> 3. Any such list (at any index in the array) is sorted at any given point
> of time since the positions are only going to increase as we keep reading
> input from stream..
>
> 4. Once the input is read, iterate over this data store in the following
> manner -
>
> Let result holds the answer
>
> for i: 1 to 31 //>>>>>> Loop A
> if(array[i].size > 2)
> result += S(S-1)(S-2)/6
> for(j: 2*i-1 to i+1)
>  listRight = array[j]
>  listLeft = array[i - (j-i)]
>  for int x: array[i]
>  //use Collections.binarySearch
>  a = number of elements greater than x in listRight
>  c = listRight.size - a
>  b =  number of elements less than x in listLeft
>  d = listLeft.Size - b
>  result += a*b
>  result += c*d// Explanation E
>
>  return result once Loop A is done..
>
> E = Suppose 6,.,4.,2 occur in the stream as well as 2...,4...,6 ..
> I need to capture both these as they both form an AP
>
> To improve time, it is recommended(on CodeChef, it uses SPOJ) to use
> BufferedReader when reading long inputs from console.. Hence I am using
> that ..
>
> My SkypeID: abhishekpc87iit.. Feel free to contact me .. always online..
>
>
> On Tue, Jul 9, 2013 at 5:32 PM, Tian Guo  wrote:
>
>> Can you just briefly describe your algorithm and time complexity? Then we
>> could know the problem and think about from which perspective to improve it.
>>
>> Thx!
>>
>>
>> 2013/7/9 abhishek sharma 
>>
>>>
>>>  Given *N* integers *A1, A2, …. AN*, Dexter wants to know how many ways
>>> he can choose three numbers such that they are three consecutive terms of
>>> an arithmetic progression.
>>>
>>> Meaning that, how many triplets *(i, j, k)* are there such that *1 ≤ i
>>> < j < k ≤ N* and *Aj - Ai = Ak - Aj*.
>>>
>>> So the triplets (2, 5, 8), (10, 8, 6), (3, 3, 3) are valid as they are
>>> three consecutive terms of an arithmetic progression. But the triplets (2,
>>> 5, 7), (10, 6, 8) are not.
>>> Input
>>>
>>> First line of the input contains an integer *N (3 ≤ N ≤ 10)*. Then
>>> the following line contains *N* space separated integers *A1, A2, …, AN*and 
>>> they have values between
>>> *1* and *3* (inclusive).
>>> Output
>>>
>>> Output the number of ways to choose a triplet such that they are three
>>> consecutive terms of an arithmetic progression.
>>> Example
>>>
>>> *Input:*
>>> 10
>>> 3 5 3 6 3 4 10 4 5 2
>>> *Output:*
>>> 9
>>>
>>> *I am attaching my solution..* I reached this solution after improving the 
>>> performance 10 times.. but it is still not accepted as the time limit 
>>> exceeds 3 seconds.
>>>
>>>
>>>
>>> Can anyone please please suggest how to improve this ...
>>> (I do not want a different approach .. I want to improve my approach)
>>>
>>> PS: This is a practice problem .. So I am not cheating :)
>>>
>>>
>>> --
>>> Nice Day
>>>
>>> Abhishek Sharma
>>> Bachelor of Technology
>>> IIT Kanpur (2009)
>>>
>>> --
>>> 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.
>>
>>
>>
>
>
>
> --
> Nice Day
>
> Abhishek Sharma
> Bachelor of Technology
> IIT Kanpur (2009)
>



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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] Improve data store for this particular Code Chef problem to improve performance in time

2013-07-09 Thread abhishek sharma
 Given *N* integers *A1, A2, …. AN*, Dexter wants to know how many ways he
can choose three numbers such that they are three consecutive terms of an
arithmetic progression.

Meaning that, how many triplets *(i, j, k)* are there such that *1 ≤ i < j
< k ≤ N* and *Aj - Ai = Ak - Aj*.

So the triplets (2, 5, 8), (10, 8, 6), (3, 3, 3) are valid as they are
three consecutive terms of an arithmetic progression. But the triplets (2,
5, 7), (10, 6, 8) are not.
Input

First line of the input contains an integer *N (3 ≤ N ≤ 10)*. Then the
following line contains *N* space separated integers *A1, A2, …, AN* and
they have values between *1* and *3* (inclusive).
Output

Output the number of ways to choose a triplet such that they are three
consecutive terms of an arithmetic progression.
Example

*Input:*
10
3 5 3 6 3 4 10 4 5 2
*Output:*
9

*I am attaching my solution..* I reached this solution after improving
the performance 10 times.. but it is still not accepted as the time
limit exceeds 3 seconds.

Can anyone please please suggest how to improve this ...
(I do not want a different approach .. I want to improve my approach)

PS: This is a practice problem .. So I am not cheating :)


-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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.




APTripletInStream.java
Description: Binary data


Re: [algogeeks] Re: CISCO Written Test ??

2012-08-29 Thread Abhishek Sharma
50 questions were there in written test ( aptitude (22), c, c++, signals,
networking, 8085, 8086)
I got 35/ 50 in written test.
In interviews, they asked questions like what is polymorphism, reverse a
linked list, explain quicksort etc.

On Mon, Aug 27, 2012 at 8:40 AM, apoorv gupta wrote:

> Der were many  questions from electronics part also..20 apti 20 electronic
> ques 10 c/netwrking ques..So computer science people will have a tough
> luck.So revise basics of electronics. ques like half wave rectifier
> efficiency were asked
>
>
> On Sun, Aug 26, 2012 at 10:24 PM, deepikaanand wrote:
>
>> written test will be  (apti + tech) no negative marking
>>
>> apti from time , speed and distance, probablity , mixtures , profit
>> and loss (easy)
>> 2 qs to infer from the passage given(critical reasoning)
>> 1 DI set (too simple)
>> and technical qs 2 simple C o/p qs
>> A large %age of qs was from digital logic design , OS , networking
>> only 1 qs(which layer guarantees reliable end to end transmission)
>> do practice the qs given on various sites,most of the qs are just
>> repeated...
>> Interview process :- resume based
>>
>> --
>> 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 Sincere Regards
> Apoorv Gupta
> Btech Final Year
> Computer Science And Engineering
> 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.



Re: [algogeeks] Fwd: Snapdeal placement proceedure

2012-08-29 Thread Abhishek Sharma
I appeared for snapdeal's exam on 27th.The question paper had 2
sections:aptitude and programming
In aptitiude,there were questions like
1) find time after 2pm, where two hands of clock intersect
2)find max of two numbers without using if,else or comparison operators
3)3 ants on vertices of triangle
4)delete duplicates from array
5)How many 7-digit numbers are there with digits in inc. order
6)2 aptitiude ques.
7)10 bottles with pills of weight 10g each.one bottle contains pill of
9g.find the bottle

In coding section,
1)check if a str is a rotation of other
2)all elements in array are present twice except a single element which is
present only once.find that element ?
3)one aptitude ques.
4)one question related to C output

On Tue, Aug 28, 2012 at 10:25 PM, sachin singh  wrote:

>
>
> -- Forwarded message --
> From: sachin singh 
> Date: Tue, Aug 28, 2012 at 10:23 PM
> Subject: Snapdeal placement proceedure
> To: algogeeks@googlegroups.com
>
>
>
> Can anyone tell about the recruitment process of snapdeal?
> I mean how to prepare for the written test?What kind of written test it
> would be?
> What are they asking in interview? And some pointers on what skills they
> are basically looking at when they come to hire at colleges
>
>  --
> 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] Local Minima in Unsorted Array

2012-08-09 Thread Abhishek Sharma
http://courses.csail.mit.edu/6.006/spring11/lectures/lec02.pdf

On Mon, Aug 6, 2012 at 12:19 AM, dheeraj chawla  wrote:

> hello guys, check this code n tell me if i m worng
>
> int localminima(int a[],int start,int end)
> {int mid;
>
> while(start {
>   mid=(start+end)/2;
> if(a[start]return(1);
> else if(a[end-1]   return(1);
>   else if(a[mid]end=mid-1;
>else
>start=mid+1;
> }
>
> if(start>end)
>   return 0;
>
> return -1;
> }
>
> On Mon, Aug 6, 2012 at 12:15 AM, payal gupta  wrote:
>
>> this could help although not true for many cases as said above
>>
>> http://ideone.com/w5gjK
>>
>>
>>
>> On Sun, Aug 5, 2012 at 8:40 AM, Ashish Goel  wrote:
>>
>>> can you give an example of what do you mean by "Local" minima?
>>> From Dave's example, it looks like the minima of the whole array..
>>>
>>> Best Regards
>>> Ashish Goel
>>> "Think positive and find fuel in failure"
>>> +919985813081
>>> +919966006652
>>>
>>>
>>> On Fri, Aug 3, 2012 at 10:32 PM, shady  wrote:
>>>
 Hi,
 Can anyone tell how to find local minima in an unsorted array ?
 Recommended solution : O(log(n))

 Shady.

 --
 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.
>

-- 
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] directi paper pattern

2012-08-02 Thread Abhishek Sharma
please mail me too. Directi is coming for written test on this 8th in our
college.
Thanks in advance..

On Tue, Jul 31, 2012 at 11:48 PM, amit singh  wrote:

>  hi shaukat Ali ,it will be really kind if you can forward me that paper
> of directi
> my ID:amitsingh...@gmail.com
>
>
> On Tuesday, 31 July 2012 21:42:43 UTC+5:30, md shaukat ali wrote:
>>
>>
>>
>> On Tue, Jul 31, 2012 at 7:37 PM, deepikaanand wrote:
>>
>>> can anyone tell me the pattern (selection procedure )followed by directi
>>> this year
>>>
>>> --
>>> 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/-/uaKshpROlGoJ
>>> .
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to algogeeks+unsubscribe@**
>>> googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/algogeeks?hl=en .
>>>
>> i have mailed u recently asked question by direct i in nit
>> allahabad..make a view on it
>>
>>  --
> 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/-/e2nPukFWEpQJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Anagram problem

2012-07-18 Thread Abhishek Sharma
sort each word in the list,then sort the whole list.
Now,sort the input word(string).
and then use binary search to find the word.

On Wed, Jul 18, 2012 at 8:59 PM, Bhupendra Dubey wrote:

> Sort each of the word and form a trie , if any words comes again you get
> one sch case.
>
>
> On Wed, Jul 18, 2012 at 2:12 PM, vindhya chhabra  > wrote:
>
>> yes,sorry count sort will be O(n) so better.thanks
>>
>> On Wed, Jul 18, 2012 at 1:43 PM, saurabh singh wrote:
>>
>>> ^sorting a string would be o(n^2logn) if u use q.sort.count sort would
>>> be better.
>>> Saurabh Singh
>>> B.Tech (Computer Science)
>>> MNNIT
>>> blog:geekinessthecoolway.blogspot.com
>>>
>>>
>>>
>>> On Wed, Jul 18, 2012 at 1:08 PM, vindhya chhabra <
>>> vindhyachha...@gmail.com> wrote:
>>>
>>>> sort the list,sort the word(use quick sort(nlogn  time))- and den
>>>> search using binary search(logn time)
>>>> or we can evn do by hashing-hash the word,den for every word keep
>>>> decreasing the counter,if the hash array is zero ,anagram,else reset the
>>>> hash array for given input for the checking the next word.
>>>>
>>>>
>>>> On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar 
>>>> wrote:
>>>>
>>>>> Assuming a preexisting list of 100 words, how would you efficiently
>>>>> see if a word received from input is an anagram of any of the 100 words?
>>>>>
>>>>> --
>>>>> 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/-/5kuxjymYEc4J.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Vindhya Chhabra
>>>>
>>>>
>>>>
>>>>
>>>>  --
>>>> 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.
>>>
>>
>>
>>
>> --
>> Vindhya Chhabra
>>
>>
>>
>>  --
>> 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 & regards
> Bhupendra
>
>
>
>  --
> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] Finds all the elements that appear more than n/3 times

2012-07-17 Thread Abhishek Sharma
I think it can be done by using some randomized algorithm.
Divide the array into subarrays of equal size and then pick a random
element from each group.Do it 3-4 times,if random number comes out equal
for most of the times,return that element.
I haven't tried it.

On Fri, Jul 13, 2012 at 10:53 AM, Ganesh M wrote:

> I guess the 
> link<http://valis.cs.uiuc.edu/~sariel/research/CG/applets/linear_prog/median.html>talks
>  about modified quick sort approach. Remember, if your choise of pivot
> is bad everytime, this will have a worst case performance of O(n). You
> should refer to Selection 
> Algorithm<http://en.wikipedia.org/wiki/Selection_algorithm>for better worst 
> case performance.
>
> On Wednesday, July 11, 2012 3:12:07 PM UTC+8, Navin Kumar wrote:
>
>> @sachin:
>>
>> http://valis.cs.uiuc.edu/~**sariel/research/CG/applets/**
>> linear_prog/median.html<http://valis.cs.uiuc.edu/~sariel/research/CG/applets/linear_prog/median.html>
>>
>> On Wed, Jul 11, 2012 at 12:28 PM, sachin goyal > > wrote:
>>
>>> To Mr. B
>>> how will you find median in O(n) time? please elaborate.
>>>
>>>
>>> On Wednesday, July 11, 2012 4:01:43 AM UTC+5:30, Mr.B wrote:
>>>>
>>>> I found a similar solution looking somewhere else.
>>>>
>>>> The solution for this problem is:
>>>> a. There can be atmost 3 elements (only 3 distinct elements with each
>>>> repeating n/3 times) -- check for this and done. -- O(n) time.
>>>> b. There can be atmost 2 elements if not above case.
>>>>
>>>> 1. Find the median of the input. O(N)
>>>> 2. Check if median element is repeated N/3 times or more -- O(n) - *{mark
>>>> for output if yes}*
>>>> 3. partition the array based on median found above. - O(n)  --
>>>> {partition is single step in quicksort}
>>>> 4. find median in left partition from (3). - O(n)
>>>> 5. check if median element is repeared n/3 times or more - O(n)  *{mark
>>>> for output if yes}*
>>>> 6. find median in right partition from (3). - O(n)
>>>> 7.  check if median element is repeared n/3 times or more - O(n)  *{mark
>>>> for output if yes}*
>>>>
>>>> its 7*O(N) => O(N) solution. Constant space.
>>>>
>>>> we need not check further down or recursively. {why? reason it.. its
>>>> simple}
>>>>
>>>>
>>>> On Wednesday, 27 June 2012 18:35:12 UTC-4, Navin Kumar wrote:
>>>>>
>>>>>
>>>>> Design an algorithm that, given a list of n elements in an array,
>>>>> finds all the elements that appear more than n/3 times in the list. The
>>>>> algorithm should run in linear time
>>>>>
>>>>> ( n >=0 ).
>>>>>
>>>>> You are expected to use comparisons and achieve linear time. No
>>>>> hashing/excessive space/ and don't use standard linear time deterministic
>>>>> selection algo.
>>>>>
>>>>>  --
>>> 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/-/PxIJd3So3tkJ<https://groups.google.com/d/msg/algogeeks/-/PxIJd3So3tkJ>.
>>>
>>>
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to algogeeks+unsubscribe@**
>>> googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/algogeeks?hl=en <http://groups.google.com/group/algogeeks?hl=en>.
>>>
>>
>>  --
> 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/-/lZKI47459WgJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: Traverse a 2-D array of strings

2012-07-15 Thread Abhishek Sharma
@atul007, but that doesn't work for extreme cases like
".sdlf.sfd.sd.f" and "sdf..sfdsf.sfddf"

On 7/15/12, atul anand  wrote:
> 1) you can count "." in the input string +1 = number of tokens
> 2) you can pass by reference a variable to mystrtok(string,delim,&len);
> in your function at the end you can store count *len=count;
> and this len can be used in the loop.
>
> for(i=0;i
> On 7/15/12, Abhi  wrote:
>> @atul007, number of rows represent number of tokenized strings.How do i
>> know the number of tokenized strings? It depends upon input string and
>> delimiter
>>
>> On Saturday, 14 July 2012 22:45:46 UTC+5:30, Abhi wrote:
>>>
>>> I have written a mystrtok function which takes a string and a delimiter
>>> as
>>>
>>> argument and returns an array of tokenized strings.But i don't know how
>>> to
>>>
>>> traverse that array
>>> Here is my code:-
>>> char string[50] = "asdf.sdf.sdf.sdf.wer.sfd.df";
>>> char delim = '.';
>>> char **result = mystrtok( string , delim);
>>>
>>> for (int i=0; ??? ; i++)  //what to write in condition part
>>> printf("%s",result[i]);
>>>
>>
>> --
>> 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/-/exXJLYEOcXwJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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.
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] flipkart question

2012-07-07 Thread Abhishek Sharma
@Raj: trace karke dekh na yaar when u have 3 0s and 3 6s.. the sum
distribution would look like this:

given below are the possibilities:

Combination of 1,2,3,4,5,6 with 0
1+0 = 1
2+0 = 2
3+0 = 3

OR

4+0 = 4
5+0 = 5
6+0 = 6

Combination of 1,2,3,4,5,6 with 6

1+6 = 7
2+6 = 8
3+6 = 9

OR

4+6 = 10
5+6 = 11
6+6 = 12

ho gye na evenly distribute :)

On Sat, Jul 7, 2012 at 10:24 PM, Prakhar Jain  wrote:

> Label 3 of the faces with 0 and other 3 faces with 6.
>
>
> --
> Prakhar Jain
> IIIT Allahabad
> B.Tech IT 3rd Year
> Mob no: +91 9454992196
> E-mail: rit2009...@iiita.ac.in
>   jprakha...@gmail.com
>
>
>
> On Sat, Jul 7, 2012 at 12:52 AM, Hraday Sharma wrote:
>
>> You are given 2 dice. Both are fair. One of the dice has no numbers
>> printed on it. You have to label the unmarked dice such that when both the
>> dice are thrown, the sum on the faces is evenly distributed between 1 and 12
>>  .
>>
>>
>>  --
>> 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/-/uXBWN7DSu_gJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] Help about compile in LISP

2012-07-07 Thread Abhishek Sharma
whats your purpose behind that ??

a) u want to understand the algorithm ? then go through backtracking and
then try to solve the problem
b) u want to learn LISP ?? then this is not the right place... u may want
to go through LIPS tutorials and then have a look at at this problem again


On Sun, Jul 8, 2012 at 12:15 AM, Victor Manuel Grijalva Altamirano <
kavic1.mar...@gmail.com> wrote:

> The next code, it's about the problem Eight Queens, i found it in
> internet, but i'm new in LISP and i don´t know how to compile it...
> Can you help me?
>
> (defun find-queen (arr p d)
>   (destructuring-bind ((px py) (dx dy)) (list p d)
> (do ((x px (+ x dx))
>  (y py (+ y dy)))
> ((not (array-in-bounds-p arr x y)))
>   (when (= (aref arr x y) 1) (return t)
>
> (defun queen-in-row (board row)
>   (find-queen board (list row 0) '(0 1)))
>
> (defun queen-in-col (board col)
>   (find-queen board (list 0 col) '(1 0) ))
>
> (defun queen-in-diags (board x y)
>   (member t (mapcar (lambda (p)
> (find-queen board (list x y) p))
>   '((1 1) (-1 -1) (1 -1) (-1 1)
>
> (defun queen-in-range (board x y)
>   (or (queen-in-row board x)
>   (queen-in-col board y)
>   (queen-in-diags board x y)))
>
> (defun backtracking (pred explore node)
>   (if (funcall pred node) (list node)
> (mapcan (lambda (n) (backtracking pred explore n))
> (funcall explore node
>
> (defun count-queens (board)
>   (loop for i below (array-total-size board)
> for box = (row-major-aref board i)
> count (> box 0)))
>
> (defun solutionp (board)
>   (and board (= 8 (count-queens board
>
> (defun put-queens (board)
>   (loop for i below 8
> when (not (queen-in-row board i))
> return
> (loop for j below 8
>   for b = (copy-array board)
>   when (not (queen-in-range board i j))
>do (setf (aref b i j) 1)
>and collect b)))
>
> (defun 8-queens ()
>   (backtracking #'solutionp #'put-queens board))
>
> (defvar board (make-array '(8 8) :initial-element 0))
>
>
> --
> Victor Manuel Grijalva Altamirano
> Universidad Tecnologica de La Mixteca
>
> --
> 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] Finding intersection of 2 linked lists

2012-07-05 Thread Abhishek Sharma
@nishant, you wrote "until both the distance becomes equal".Which distances
? Could you please elaborate ?

On Thu, Jul 5, 2012 at 12:52 PM, Ashish Goel  wrote:

> struct node* intersection( struct node *pL1, struct node* pL2)
> {
>if ((!pL1) || (!pl2)) return NULL;
>struct node * pL3 = NULL;
>struct node* pL3Tail = NULL;
>while(pL1)&&(pL2) {
> if (pL1->data< pL2->data) pL1=pL1->next;
> else if  (pL1->data > pL2->data) pL2=pL2->next;
> else {
>struct node *pNew = (struct node*)malloc(sizeof(struct node));
>if !pNew return NULL; //scary
>pNew->data = pL1->data; pNew->next = NULL;
>if ( !pL3) pL3= pNew;
>else pL3Tail->next = pNew;
>pL3Tail = pNew;
>}
>return pL3;
> }
>
>
>
>
> }
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
> On Wed, Jul 4, 2012 at 10:41 PM, Abhi  wrote:
>
>> Any efficient algorithm to find intersection of two linked lists.Example:
>> Linked List 1)  1 -> 2 -> 3 -> 4 -> 5 -> 6
>> Linked List 2)  3 -> 4 -> 5
>>
>> Intersection 4 -> 5 -> 6
>>
>> --
>> 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/-/-8_lnGA-ZhgJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] Finding intersection of 2 linked lists

2012-07-04 Thread Abhishek Sharma
3 -> 4 -> 5, sorry for that silly mistakes

On Wed, Jul 4, 2012 at 10:54 PM, Abhishek Sharma wrote:

> it was 4 -> 5, not 4 -> 5 -> 6
>
>
> On Wed, Jul 4, 2012 at 10:41 PM, Abhi  wrote:
>
>> Any efficient algorithm to find intersection of two linked lists.Example:
>> Linked List 1)  1 -> 2 -> 3 -> 4 -> 5 -> 6
>> Linked List 2)  3 -> 4 -> 5
>>
>> Intersection 4 -> 5 -> 6
>>
>> --
>> 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/-/-8_lnGA-ZhgJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Abhishek Sharma
> Under-Graduate Student,
> PEC University of Technology
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] Finding intersection of 2 linked lists

2012-07-04 Thread Abhishek Sharma
it was 4 -> 5, not 4 -> 5 -> 6

On Wed, Jul 4, 2012 at 10:41 PM, Abhi  wrote:

> Any efficient algorithm to find intersection of two linked lists.Example:
> Linked List 1)  1 -> 2 -> 3 -> 4 -> 5 -> 6
> Linked List 2)  3 -> 4 -> 5
>
> Intersection 4 -> 5 -> 6
>
> --
> 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/-/-8_lnGA-ZhgJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] simple FILE reading problem.

2012-07-04 Thread Abhishek Sharma
Please ignore the last post


Fetch a character.
if isdigit( current_character )
 add it to temp string
 flag =1
else if current_character is any character except space
 flag = 0
   while current_char  is not space
  current_char_position ++
else if current_char is space and flag = 1
   fetch last word (temp string)

On Wed, Jul 4, 2012 at 10:51 PM, Abhishek Sharma wrote:

> Fetch a character.
> if isdigit( current_character )
>   flag =1
> else if current_character is any character except space
>
>  while current_char  is not space
>   current_char_position ++
>
>
> On Wed, Jul 4, 2012 at 10:44 PM, Navin Kumar wrote:
>
>> Suppose a file.txt contains : 50 40 30 # # 5 # 10 # #
>>
>> i want to fetch only integers. How should i fetch it. I tried with fgetc
>> and fscanf but it was too complicated.
>>
>> My approach: fetched one word at a time and put it into separate string
>> and then i converted that string to integer(if each character of that
>> string was between '0' to '9').
>>
>> Is there any simple way to do this.
>>
>>
>> --
>> 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/-/btvudXnBrAIJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Abhishek Sharma
> Under-Graduate Student,
> PEC University of Technology
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] simple FILE reading problem.

2012-07-04 Thread Abhishek Sharma
Fetch a character.
if isdigit( current_character )
  flag =1
else if current_character is any character except space

 while current_char  is not space
  current_char_position ++

On Wed, Jul 4, 2012 at 10:44 PM, Navin Kumar wrote:

> Suppose a file.txt contains : 50 40 30 # # 5 # 10 # #
>
> i want to fetch only integers. How should i fetch it. I tried with fgetc
> and fscanf but it was too complicated.
>
> My approach: fetched one word at a time and put it into separate string
> and then i converted that string to integer(if each character of that
> string was between '0' to '9').
>
> Is there any simple way to do this.
>
>
> --
> 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/-/btvudXnBrAIJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] Permuatation of string in caase of duplicte string it shouldnt print duplicates permutation .

2012-07-04 Thread Abhishek Sharma
http://stackoverflow.com/questions/1900197/generating-variations-without-repetitions-permutations-in-java/


On Wed, Jul 4, 2012 at 8:16 PM, Nishant Pandey  wrote:

> the code works fine only in case of duplicates , but if we consider
> string to be non duplicates like say :"abc" then all permutation cant be
> obtainned .
>
>
> On Wed, Jul 4, 2012 at 12:31 PM, atul anand wrote:
>
>> you can use flag[256];
>>
>> now you just need to check
>> loop:
>> if (flag[str[i]]==0)
>> {
>>  //swap()
>>  //permute function call
>>  //swap()
>>  flag[str[i]=1;
>> }
>> done
>>
>>
>> On 7/4/12, atul anand  wrote:
>> > you can use flag[256];
>> >
>> > now you just need to check
>> > loop:
>> > flag[str[i]]==0)
>> > {
>> >  //swap()
>> >  //permute function call
>> >  //swap()
>> >  flag[str[i]=1;
>> > }
>> > done
>> >
>> > On 7/3/12, Nishant Pandey  wrote:
>> >> 1) Find all permutations of a string.
>> >> 2) Improve it so that the permutations are not repeated, Eg=> string is
>> >> ""
>> >> Answer should be just  once not 4! times.
>> >>
>> >> i want suggestion to improve the recursive code in case of 2) case .
>> >>
>> >> --
>> >> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: adobe

2012-07-03 Thread Abhishek Sharma
what s silly mistake. @Rahul thanks for correcting me.

On Tue, Jul 3, 2012 at 3:41 PM, rahul ranjan wrote:

> @abhishek its wrong as arr1 is just a pointer o int and sizeof(arr1)
> will always be 4 bytes(size of a pointer) regardless of number of bytes
> allocated to it on heap
>
>
> On Tue, Jul 3, 2012 at 3:14 PM, Abhishek Sharma wrote:
>
>> arr1 = (int *)malloc(sizeof(int) * ncols);// memory allocated for 1st
>> row
>> arr2 = (int **)malloc(sizeof(arr1) * nrows);
>>
>> I haven't tried it.So,please correct me if i am wrong
>>
>>
>> On Mon, Jul 2, 2012 at 12:55 PM, Rishabh Agarwal wrote:
>>
>>>
>>> nrows: number of rows
>>> ncols: number of columns
>>>
>>> int **arra = (int **)malloc( sizeof(int*) * nrows );
>>> int *ar = (int *)malloc( sizeof(int) * nrows * ncols );
>>> for( int a = 0; a < nrows; a ++ ) {
>>> arra[a] = ar + ncols * a;
>>> }
>>>
>>> now index of array i and j can be accessed as arra[i][j]
>>>
>>>
>>>
>>> On Friday, June 29, 2012 4:46:18 PM UTC+5:30, rahul r. srivastava wrote:
>>>>
>>>> implement a 2d matrix using only 2 mallocs.
>>>>
>>>  --
>>> 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/-/Pr2cEtta_LsJ.
>>>
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Abhishek Sharma
>> Under-Graduate Student,
>> PEC University of Technology
>>
>>  --
>> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: adobe

2012-07-03 Thread Abhishek Sharma
arr1 = (int *)malloc(sizeof(int) * ncols);// memory allocated for 1st
row
arr2 = (int **)malloc(sizeof(arr1) * nrows);

I haven't tried it.So,please correct me if i am wrong

On Mon, Jul 2, 2012 at 12:55 PM, Rishabh Agarwal wrote:

>
> nrows: number of rows
> ncols: number of columns
>
> int **arra = (int **)malloc( sizeof(int*) * nrows );
> int *ar = (int *)malloc( sizeof(int) * nrows * ncols );
> for( int a = 0; a < nrows; a ++ ) {
> arra[a] = ar + ncols * a;
> }
>
> now index of array i and j can be accessed as arra[i][j]
>
>
>
> On Friday, June 29, 2012 4:46:18 PM UTC+5:30, rahul r. srivastava wrote:
>>
>> implement a 2d matrix using only 2 mallocs.
>>
>  --
> 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/-/Pr2cEtta_LsJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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 asked in Amazon Online Test

2012-06-29 Thread Abhishek Sharma
convert prefix to infix,then convert infix to postfix.Now, to convert
prefix to infix, push numbers in one stack and operators in other.Then use
this<http://www.velocityreviews.com/forums/t445633-prefix-to-infix-conversion.html>
algo
to perform this.Then do the same for infix to postfix.It works with simple
operators,but difficult to implement with parenthesis.

On Sat, Jun 30, 2012 at 12:21 AM, rahul ranjan wrote:

> oh bhai mere. kewal preorder use karke kaise tree bana dega???
>
>
> On Fri, Jun 29, 2012 at 11:23 PM, amrit harry wrote:
>
>> @bhaskar ur algo fails on this case (5+3)-(2+(3/6))
>> -+53+2/36
>> 63/2+35-+
>> showing that 6/3 but actually it is 3/6
>> so i think it could be done by folowing algo
>> make a binary tree of given expression in O(n)  then do postorder
>> traversal take O(n) so problem can be solved in O(n). and take O(2*n+1)
>> space
>>
>> On Fri, Jun 29, 2012 at 9:13 PM, Bhaskar Kushwaha <
>> bhaskar.kushwaha2...@gmail.com> wrote:
>>
>>> I think just reversing the prefix notation converts it to postfix
>>> notation
>>>
>>>
>>> On Fri, Jun 29, 2012 at 7:46 PM, Gobind Kumar Hembram <
>>> gobind@gmail.com> wrote:
>>>
>>>> Given an integer expression in a prefix format (i.e. the operator
>>>> precedes the number it is operating on) ,  print the expression in the
>>>> post fix format .
>>>>
>>>> Example: If the integer expression is in the prefix format is *+56-78,
>>>> the postfix format expression is 56+78-*. Both of these
>>>> correspond to the expression (5+6)*(7-8).
>>>>
>>>> --
>>>> 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,
>>> Bhaskar Kushwaha
>>> Student
>>> Final year
>>> CSE
>>> M.N.N.I.T.  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.
>>>
>>
>>
>>
>> --
>> Thanks & Regards
>> Amritpal singh
>>
>>  --
>> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] can anyone tell me

2012-06-28 Thread Abhishek Sharma
naa noone can tell you.. haha.. just kidding...

for OS refer the prescribed text. I studied from Silberschatz, Galvin,
Gagne: *Operating System Concepts.. *
amazing book.. just understand the basics.. like process shceduling
algorithms, page shceduling algorithms, threads, context switching, virtual
memory, paging, thrashing, deadlocks etc...

On Thu, Jun 28, 2012 at 10:49 PM, Rahul verma
 wrote:

> can anyone tell me how to prepare OS subject for placement and interview
>
> which type of question interviewer will ask?
>
> which website will i prefer ?
>
> plzzz tell me ...
>
> --
> 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] Programming Question

2012-06-22 Thread Abhishek Sharma
make a hashtable where,
 key is the first character of each word and,
 value is a list which contains index of each word starting with that
character.
Now, sort that hash table wrt keys.
Now print each each key and words corresponding to that key ( given by
arr[index1], arr[index2] )

On Fri, Jun 22, 2012 at 5:55 PM, Ashot Madatyan  wrote:

> 1. read the file one char at a time, and tokenize the standalone words
> (stop
> char is either space or comma or eol)
> 2. put each parsed word in a structure "map >", where
> the char is the key (the first letter of each scanned word). You are
> basically creating a hash table here.
> 3. now print the hash table content using the formatting of your choice.
>
> Rgds,
> Ashot
>
> -Original Message-
> From: algogeeks@googlegroups.com [mailto:algogeeks@googlegroups.com] On
> Behalf Of Gobind Kumar Hembram
> Sent: Friday, June 22, 2012 2:01 PM
> To: algogeeks@googlegroups.com
> Subject: [algogeeks] Programming Question
>
> I was asked this question in one company Programming Round.Please help
> me in solving this,I tried with array of pointers ,2-D array and by
> buffering.
>
> You have a file with names of brands separated by comma. Write a
> program (in language of your choice) to group them by their starting
> letter.
>
> For example, if the input file is this:
> Reebok, Puma, Adidas, Clarks, Catwalk, Converse, FILA, Lotto, Newfeel,
> Nike, Numero Uno, New Balance, ASICS, Carlton London, Crocs
>
> The program should print the following:
> A
>  ASICS, Adidas
>
> C
>  Carlton London, Catwalk, Clarks, Converse, Crocs
>
> F
>  FILA
>
> L
>  Lotto
>
> N
>  New Balance, Newfeel, Nike, Numero Uno
>
> P
>  Puma
>
> R
>  Reebok
>
> --
> 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.
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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]

2012-06-21 Thread Abhishek Sharma
@umer
it's not random,but biased


On Wed, Jun 20, 2012 at 11:16 AM, Umer Farooq  wrote:

> Hmmm, true. That's what I expected in this solution. Similarly, we can get
> 3 by (3,3) (1,2)
>
> However, did you take a look at the other solution I proposed? I guess
> that solves the problem to some extent.
>
>
> On Tue, Jun 19, 2012 at 7:18 PM, Sourabh Singh 
> wrote:
>
>> @Umer and Navin :
>> 1 is generated by (1,3) only.
>> 2 is generated by (1,1) and (2,3).
>>
>> so given solution is wrong
>>
>>
>> On Tue, Jun 19, 2012 at 5:17 AM, Sourabh Singh 
>> wrote:
>>
>>> @ *ALL*
>>>
>>> please. post along with your method .
>>> proof than it make's equal distribution over the given range.
>>>
>>> On Tue, Jun 19, 2012 at 4:47 AM, Navin Kumar 
>>> wrote:
>>>
>>>> @Umer:
>>>>
>>>> rand(5) + (rand(5)%2): => it will never give 6 because for rand(7)
>>>> range will be 0-6.
>>>> So better try this: rand(5) + (rand(5)%3).
>>>>
>>>>
>>>> On Tue, Jun 19, 2012 at 2:45 PM, Umer Farooq wrote:
>>>>
>>>>> rand(5) + (rand(5)%2);
>>>>>
>>>>>
>>>>> On Tue, Jun 19, 2012 at 12:30 PM, Sourabh Singh <
>>>>> singhsourab...@gmail.com> wrote:
>>>>>
>>>>>> @ sry
>>>>>> condition should be:
>>>>>>
>>>>>> if(20*prob <= 500/7) :-)
>>>>>>
>>>>>>
>>>>>> On Tue, Jun 19, 2012 at 12:26 AM, Sourabh Singh <
>>>>>> singhsourab...@gmail.com> wrote:
>>>>>>
>>>>>>> @ALL
>>>>>>>
>>>>>>> Given a random number generator say r(5) generates number between
>>>>>>> 1-5 uniformly at random , use it to in r(7) which should generate a 
>>>>>>> random
>>>>>>> number between 1-7 uniformly at random
>>>>>>>
>>>>>>> i have seen this on many site's but not a single correct solution.
>>>>>>> all solution's posted got rejected by someone else.:
>>>>>>> plz.. suggest some algo :
>>>>>>>
>>>>>>> my aprroach:
>>>>>>>
>>>>>>> let's assume a rectangle :
>>>>>>>
>>>>>>> 100  |___
>>>>>>> |___|__
>>>>>>> 500/7   |  ||
>>>>>>> |  ||
>>>>>>> |___|__|
>>>>>>> 0 1  2  3 4  5 67
>>>>>>> now :
>>>>>>>
>>>>>>> let : num  = rand(5);
>>>>>>>prob = rand(5);
>>>>>>>
>>>>>>>if(prob <= rand(5))
>>>>>>> print  num
>>>>>>>else
>>>>>>> print  5 + num*(2/5)
>>>>>>>
>>>>>>>
>>>>>>>  --
>>>>>>> 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] Microsoft Interview Question

2012-06-21 Thread Abhishek Sharma
find the element nearest to zero.make it pivot element.then apply one pass
of quicksort over the array.this is O(n)
On Thu, Jun 21, 2012 at 12:27 AM, Akshat Sapra wrote:

> void make_group( int a[], int size) {
>   int j = 0;
>
>  for ( int i = 0; i < size; i++ ) {
>  if ( a[i] < 0 ) {
> swap(a[i],a[j]);
> j++;
>  }
> }
> }
>
>
> --
>
>
> Akshat Sapra
> Under Graduation(B.Tech)
> IIIT-Allahabad(Amethi Campus)
> *--*
> sapraaks...@gmail.com
> akshatsapr...@gmail.com
> rit20009008@ iiita.ac.in
>
> --
> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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 question

2012-06-21 Thread Abhishek Sharma
refer to this link <http://www.ics.uci.edu/~eppstein/161/960130.html>.
or Using quicksort , it can be done in O(n).
One more way to do this is to make min heap of size-k. Then insert elements
from the original array.If element is greater than root of the heap,swap
them.In the Last, root of the heap would be the kth smallest element

On Wed, Jun 20, 2012 at 8:47 PM, ajeet  wrote:

> Hi,
>
> It looks like, The interviewer is expecting MinHeap from you,
>
> If modification to array is permitted just build the heap in place (from
> end bubbleUp  n-1 time) and extract K elements in sorted order
> Otherwise you need minimum O(K) memory
>
> Again if you want to use the quick-sort, I would prefer only using
> partition part of quick sort..
> 1. Select any pivot 'P'
> 2. Partition the array..
> 3. position of the pivot p
> 4. if p < k ( kth min lies on left part) repeat again for k
> 5 if p > k ( kth min lies on right part) repeat again for k-p
> 6 if p = k ( You are lucky) exit
>
> Again in worst case it is o(N2)
>
> -Ajeet
>
> Thanks
> -A
>
>
> On Wednesday, 20 June 2012 00:56:36 UTC+5:30, adarsh kumar wrote:
>>
>> This can be done using the concept of median of medians, wherein we can
>> achieve linear time complexity in the worst case.
>> This is a concept used in parallel algorithms too, check it out.
>>
>> On Mon, Jun 18, 2012 at 5:38 PM, Prem Nagarajan 
>> wrote:
>>
>>> @enchantress : This problem can be solved using quicksort in O(nlogn).
>>> No need to go for selection sort.
>>> But O(n) solution is needed.
>>>
>>>
>>> On Mon, Jun 18, 2012 at 2:50 PM, enchantress wrote:
>>>
>>>>
>>>> Hi all,
>>>> A variation of selection sort can be used which takes O(nk) time.
>>>>
>>>> for i 1 to k
>>>>   min_index = i
>>>>   for j i+1 to n
>>>>  if a[j] < a[min_index]
>>>> min_index = j
>>>>   swap(a[i],a[min_index])
>>>>
>>>> required element : a[k]
>>>>
>>>> On Sunday, 17 June 2012 08:13:18 UTC+5:30, Prem Nagarajan wrote:
>>>>
>>>>> Give an array of unsorted elements, find the kth smallest element in
>>>>> the array.
>>>>>
>>>>> The expected time complexity is O(n) and no extra memory space should
>>>>> be used.
>>>>>
>>>>> Quickselect algorithm can be used to obtain the solution. Can anyone
>>>>> explain how quickselect works?
>>>>>
>>>>  --
>>>> 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/-/FABBRabzVqMJ<https://groups.google.com/d/msg/algogeeks/-/FABBRabzVqMJ>
>>>> .
>>>>
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to algogeeks+unsubscribe@**
>>>> googlegroups.com .
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/algogeeks?hl=en <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+unsubscribe@**
>>> googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/algogeeks?hl=en <http://groups.google.com/group/algogeeks?hl=en>.
>>>
>>
>>  --
> 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/-/sBvT2ztJpoUJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: Reverse Queue

2012-06-20 Thread Abhishek Sharma
using recursion,

reverse(queue,front,rear) {
   if( front < rear ) {
 swap( queue[front], queue[rear] );
 reverse( queue, front+1, rear-1);
  }
}

On Wed, Jun 20, 2012 at 11:53 PM, Sreeprasad Govindankutty <
sreeprasad...@gmail.com> wrote:

> Just a query :
>
> If the queue is implemented as an array, then is it not possible to swap
> the elements from the last and first position onwards until you reach
> middle point.  Wont this use O(1) space and O(n/2) time.
>
>
>
> On Wed, Jun 20, 2012 at 1:56 PM, Hassan Monfared wrote:
>
>> void Reverse(std::queue &pQ)
>> {
>> if(pQ.empty())
>> return;
>>  int item=pQ.front();
>> pQ.pop();
>> Reverse(pQ);
>>  pQ.push(item);
>> }
>> Regards
>>
>> On Wed, Jun 20, 2012 at 9:41 PM, enchantress wrote:
>>
>>> Queues are basically linked lists with head and tail pointers. It is
>>> possible to reverse the list by change of pointers in O(n) time n O(1)
>>> space.
>>> PS: Not considering queue ADT with enqueue dequeue operations.
>>>
>>>
>>> On Wednesday, 20 June 2012 18:34:46 UTC+5:30, Navin Kumar wrote:
>>>>
>>>> How to reverse a Queue .
>>>>
>>>> Constraints: Time complexity O(n). space complexity: O(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/-/syRXPuMjBpkJ.
>>>
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-18 Thread Abhishek Sharma
In a stack, you can't access any element directly, except the top one.

On Mon, Jun 18, 2012 at 11:33 AM, Rituraj  wrote:

> My  iterative approach
>
> /*code in c*/
> #include
> int main()
> {
>  int stack[]={1,2,3,4,5,6,7,8},top=7;//
>  int i,j,temp;
>
>  for(i=1;i<=top;i++)
>  {
>   temp=stack[i];
>
>   for(j=i;j>0;j--)
> stack[j]=stack[j-1];
>
>   stack[0]=temp;
>  }
>
>  for(i=0;i<=top;i++)
>printf("%d ",stack[i] );
>
>  return 0;
> }
>  /*
>
>
> Rituraj
> 2nd Yr.
> B.tech CSE
> NIT -Trichy
>
> --
> 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/-/n1OE58e8B7IJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: Power(n^n)

2012-06-07 Thread Abhishek Sharma
Ignore the last post.
Updated:
You don't need to use BigNum or long int for this program.
Both n & k should be less than 1000.
you need bignum only if there would be no restriction on k.
Since both n,k are restricted, you don't need bignum.
if n>5( 5^5 > 1000), simply reject the input and return false


On Fri, Jun 8, 2012 at 11:49 AM, Abhishek Sharma wrote:

> You don't need to use BigNum or long int for this program.
> Both n & k should be less than 1000.
> Since there is no restriction on k,you don't need Bignum
> Since both n,k are restricted,you don't need bignum.
> if n>5, simply reject the input and return false
>
>
> On Fri, Jun 8, 2012 at 11:01 AM, Dave  wrote:
>
>> @victor: But if K <= 1000, then the largest N you have to deal with is 4,
>> since 4^4 < 1000 but 5^5 > 1000. So your code looks like this:
>>
>> int IsNtoNEqualK( int N, int K)
>> {
>> return (N==1)&&(K==1) || (N==2)&&(K==4) || (N==3)&&{K==27) ||
>> (N==4)&&(K==256);
>> }
>>
>>
>> On Thursday, June 7, 2012 5:14:00 PM UTC-5, Victor Manuel Grijalva
>> Altamirano wrote:
>>
>>> Hi, everybody!!!
>>> I have the follow quest...
>>>
>>> I have two numbers N and K,  i need to check that N^N = K.
>>> for example:
>>>   if N=2 and K=4 , 2^2 = 4 so return true;
>>>   if N=3 and K=26 ,   3^3 != 26 so return false
>>> But 0<=N , K<=1000 so N^N could be have 1000 digits.
>>>
>>> I program in C++, and i can use Bignum (array manipulation) + fast
>>> power(binary power) but i want to know if exist a mathematical property.
>>>
>>>
>>> --
>>> Victor Manuel Grijalva Altamirano
>>> Universidad Tecnologica de La Mixteca
>>>
>>  --
>> 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/-/s6ahKx0Sxe8J.
>>
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Abhishek Sharma
> Under-Graduate Student,
> PEC University of Technology
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: Power(n^n)

2012-06-07 Thread Abhishek Sharma
You don't need to use BigNum or long int for this program.
Both n & k should be less than 1000.
Since there is no restriction on k,you don't need Bignum
Since both n,k are restricted,you don't need bignum.
if n>5, simply reject the input and return false


On Fri, Jun 8, 2012 at 11:01 AM, Dave  wrote:

> @victor: But if K <= 1000, then the largest N you have to deal with is 4,
> since 4^4 < 1000 but 5^5 > 1000. So your code looks like this:
>
> int IsNtoNEqualK( int N, int K)
> {
> return (N==1)&&(K==1) || (N==2)&&(K==4) || (N==3)&&{K==27) ||
> (N==4)&&(K==256);
> }
>
>
> On Thursday, June 7, 2012 5:14:00 PM UTC-5, Victor Manuel Grijalva
> Altamirano wrote:
>
>> Hi, everybody!!!
>> I have the follow quest...
>>
>> I have two numbers N and K,  i need to check that N^N = K.
>> for example:
>>   if N=2 and K=4 , 2^2 = 4 so return true;
>>   if N=3 and K=26 ,   3^3 != 26 so return false
>> But 0<=N , K<=1000 so N^N could be have 1000 digits.
>>
>> I program in C++, and i can use Bignum (array manipulation) + fast
>> power(binary power) but i want to know if exist a mathematical property.
>>
>>
>> --
>> Victor Manuel Grijalva Altamirano
>> Universidad Tecnologica de La Mixteca
>>
>  --
> 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/-/s6ahKx0Sxe8J.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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 any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread Abhishek Sharma
yes,it is helpful,but read it only if u have fully understood "Introduction
to algorithms" or if u have strong foundation of algorithms/data structures

On Thu, Jun 7, 2012 at 12:37 PM, BUBUN SHEKHAR  wrote:

> Guys is this book useful for cracking interviews??
>
> On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya wrote:
>
>> If any one have algorithms for interviews by adnan aziz ebook... Please
>> mail ...
>> Thanks
>>
>> --
>> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: What would be the output for the following code fragment?

2012-06-07 Thread Abhishek Sharma
oh ,now i see. 300 = 000100101100
first 8 bits = 0001
last 8 bits = 00101100

in case of big-endian machine, when we assign 2 to next location, last 8
bits become 0010 (2 in decimal), first 8 bits remain same.
in case of little-endian machine, when we assign 2 to next location, last 8
bits become 0010 (2 in decimal), last 8 bits remain same.

Am i right ?

On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma wrote:

> @prem, i don't get it.could you please elaborate the interesting part of
> this solution ?
>
>
> On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma wrote:
>
>> Is there any online compiler which gives output for both little/big
>> endian machines ?
>> or it is fine to convert value from one form to another using a small c
>> program ?
>>
>> On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra wrote:
>>
>>> 556 if the machine is little endian
>>> 258 if machine is big endian
>>>
>>> On Jun 6, 11:57 pm, g4ur4v  wrote:
>>> > main()
>>> > {
>>> > int i=300;
>>> > char *ptr = &i;
>>> > *++ptr=2;
>>> > printf("%d",i);
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > }
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> Abhishek Sharma
>> Under-Graduate Student,
>> PEC University of Technology
>>
>>
>
>
> --
> Abhishek Sharma
> Under-Graduate Student,
> PEC University of Technology
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: What would be the output for the following code fragment?

2012-06-07 Thread Abhishek Sharma
@prem, i don't get it.could you please elaborate the interesting part of
this solution ?


On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma wrote:

> Is there any online compiler which gives output for both little/big endian
> machines ?
> or it is fine to convert value from one form to another using a small c
> program ?
>
> On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra wrote:
>
>> 556 if the machine is little endian
>> 258 if machine is big endian
>>
>> On Jun 6, 11:57 pm, g4ur4v  wrote:
>> > main()
>> > {
>> > int i=300;
>> > char *ptr = &i;
>> > *++ptr=2;
>> > printf("%d",i);
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > }
>>
>> --
>> 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.
>>
>>
>
>
> --
> Abhishek Sharma
> Under-Graduate Student,
> PEC University of Technology
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: What would be the output for the following code fragment?

2012-06-06 Thread Abhishek Sharma
Is there any online compiler which gives output for both little/big endian
machines ?
or it is fine to convert value from one form to another using a small c
program ?

On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra  wrote:

> 556 if the machine is little endian
> 258 if machine is big endian
>
> On Jun 6, 11:57 pm, g4ur4v  wrote:
> > main()
> > {
> > int i=300;
> > char *ptr = &i;
> > *++ptr=2;
> > printf("%d",i);
> >
> >
> >
> >
> >
> >
> >
> > }
>
> --
> 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.
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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 for the following code fragment?

2012-06-06 Thread Abhishek Sharma
http://ideone.com/Zz7ET

On Thu, Jun 7, 2012 at 12:27 AM, g4ur4v  wrote:

>
>
> main()
> {
> int i=300;
> char *ptr = &i;
> *++ptr=2;
> printf("%d",i);
> }
>
> --
> 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.
>
>


-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] 2 Dim array as parameter

2012-06-06 Thread Abhishek Sharma
check the return value of malloc.
on success,it returns the pointer to that memory
on error, it returns NULL
..
if( (char*)malloc(10)==NULL)
{
printf("Not Enough memory available");
exit(1);
}


On Wed, Jun 6, 2012 at 7:20 PM, Ashish Goel  wrote:

> Hi,
>
> traditional C style of passing 2D array to a C func is for example, void
> func(char **pArr, int m, int n).
> Like we validate a pointer before accessing it if it is valid, how do we
> verify that the array provided indeed has got memory allocated to it before
> accessing it
>
>
> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] Abhishek Sharma wants to chat

2012-06-06 Thread Abhishek Sharma
---

Abhishek Sharma wants to stay in better touch using some of Google's coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-f2b6967bf6-d78b18cba1-gqPKMkil32YfIMUTyJpM7kfmucY
You'll need to click this link to be able to chat with Abhishek Sharma.

To get Gmail - a free email account from Google with over 7,500 megabytes of
storage - and chat with Abhishek Sharma, visit:
http://mail.google.com/mail/a-f2b6967bf6-d78b18cba1-gqPKMkil32YfIMUTyJpM7kfmucY?pc=en-rf---a

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into "conversations"
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and it's yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

-- 
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] implementation of dijkstra

2012-06-04 Thread Abhishek Sharma
how to implement dijkstra algorithm using fibonacci heaps ?thanks 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.



[algogeeks] importance of heaps

2012-06-04 Thread Abhishek Sharma
can anyone please tell me how important are heaps as compared to other data
structures (from interview's point of view). i am not talking about simple
min/max heaps, but advanced ones like fibonacci heaps and binomial heaps

-- 
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 interview questions

2012-06-04 Thread Abhishek Sharma
I think it can be done by modifying the h-array and by making some changes
in KMP-algorithm

On Mon, Jun 4, 2012 at 9:35 AM, Jeevitesh wrote:

> i have not implemented it but i can you an idea how to approach it.
>
> Go to Each suffix in suffix or suffix array(I would prefer suffix array as
> it is easier) traverse the each suffix till you encounter the first letter
> of the suffix you are traversing and check to see this suppose i is the
> index you found out the starting letter then check
> s.substring(0,i)==s.substring(i,2i).
>
> I hope you get the idea.
>
>
> On Mon, Jun 4, 2012 at 9:14 AM, utsav sharma wrote:
>
>> @jeevitesh :- yes i am also thinking of suffix tree,
>>  but i am facing problem in implementing it. did you implement it ??
>>
>>
>> On Mon, Jun 4, 2012 at 9:11 AM, utsav sharma wrote:
>>
>>> @hassan :- it will not work for many strings as you are checking from
>>> the mid of strings. try out "ababcdef","aabc".
>>> @atul :- it should be done in O(n).
>>>
>>>
>>> On Sun, Jun 3, 2012 at 11:54 PM, Hassan Monfared wrote:
>>>
>>>> yes it's not valid
>>>>
>>>>
>>>> On Sun, Jun 3, 2012 at 5:36 PM, anugrah wrote:
>>>>
>>>>> So any string with two same characters is not valid??
>>>>>
>>>>> for example :
>>>>>
>>>>> GEEK has E followed by E.
>>>>>
>>>>> So GEEK is also invalid?
>>>>>
>>>>> On Jun 3, 1:49 pm, Hassan Monfared  wrote:
>>>>> > bool IsValid(string s)
>>>>> > {
>>>>> >  for(int len=0;len>>>> >  {
>>>>> >int start1=0,start2=len+1;
>>>>> >while(start2>>>> >{
>>>>> >   for(int i=0;i>>>> > s[start1+i]=s[start2+i];i++);
>>>>> >   if(i==len)
>>>>> >return false; //"not valid"
>>>>> >   start1++;
>>>>> >   start2++;
>>>>> > }
>>>>> >  }
>>>>> > return true; // valid
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> > }
>>>>> > On Sun, Jun 3, 2012 at 12:52 PM, atul anand 
>>>>> wrote:
>>>>> > > can be done with O(n^2) time complexity..
>>>>> >
>>>>> > > can it be done with O(n) complexity ???
>>>>> >
>>>>> > > On 6/3/12, utsav sharma  wrote:
>>>>> > > > given a string tell wether it is valid or not.
>>>>> > > > string is valid if there is no substring which have the same
>>>>> substring
>>>>> > > > following it.
>>>>> >
>>>>> > > > these strings are not valid:- "stringstring","geek123123rt",
>>>>> > > > "abcadabcad","strngstingstrngsting"
>>>>> >
>>>>> > > > --
>>>>> > > > 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.
>>>>

Re: [algogeeks] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-04 Thread Abhishek Sharma
mailing you the link for same

On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya wrote:

> If any one have algorithms for interviews by adnan aziz ebook... Please
> mail ...
> Thanks
>
> --
> 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.
>



-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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 where the two list connect

2012-05-01 Thread Abhishek Sharma
@Bhupendra: your approach is correct but in case the linked lists contain
millions of nodes then this might be an overhead.

Another approach could be:

- Start with the head of of both the lists.
- Store (Hash) the addresses to which the current nodes are pointing to, in
a hashtable.
- while storing (Hashing) also check if the address already exists (for
both of them). In case it exists in the hashtable, this address (or node)
is the required node else, increment the pointers to the next nodes.

This algo will not require traversing the whole lists and will save time.

Regards,
AB

On Tue, May 1, 2012 at 9:36 PM, Umer Farooq  wrote:

> You don't have to traverse the nodes of two lists simultaneously.
>
> You have to check if the every node of list one matches with the address
> of any node of list two. The first matching address will be the output.
>
> The worst case running time of this algo will be O(n^2)
>
>
> On Tue, May 1, 2012 at 8:47 PM, rafi  wrote:
>
>> i dont understan if i look in the pic i attached then the length of
>> the first list is 5 and the length of the second list is 6.
>> what should i do now?
>> if i traverse the long list 5,6 nodes i dont get to the red node.
>> what am i missing?
>>
>> On 1 מאי, 18:04, Bhupendra Dubey  wrote:
>> > start from head of both and  as soon as one of the list is empty means
>>  you
>> > hit null
>> > start counting the remaining number of nodes in the other list till that
>> > gets empty.
>> >
>> > Now the number obtained  above is the difference in length of the two
>> list
>> > prior to the first common node (the red node). Now again traverse the
>> > longer list corresponding to the above count and then start  traversing
>> the
>> > other list .Stop when two nodes become equal. Home!:)
>> >
>> > On Tue, May 1, 2012 at 7:55 PM, רפי וינר  wrote:
>> > > you have two linked lists that some where combine in to one list.
>> > > pic attached to illustrate
>> > >  [image: Inline image 1]
>> > > you need to find where the two list collide. (in the pic the red node)
>> >
>> > > --
>> > > 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.
>> >
>> > --
>> > bhupendra dubey
>> >
>> >  Untitled.png
>> > 14Kהצגהורדה
>>
>> --
>> 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.
>>
>>
>
>
> --
> 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] Re: MS QUESTION_LINKED LIST

2012-03-24 Thread Abhishek Sharma
@Atul: after u sort the list the head pointer will automatically point to
the smallest element so u actually return the head of the list.

@Sambhavna:

here is the Pseudoccode (More or less similar to, doing merge sort for
arrays):

Mersgesort(node ** list){
if( head==NULL or head-> next == NULL) return;

//split the list into 2 halves (lets say *a and *b)
  split(list, a , b);

//sort the two halves individually
   mergesort(a);
   mergesort(b);

   //merge the two halves and return the smallest (first) element
   *head = sortedMerge(a,b);
}

for merging u can use recursion:
Merge(node *a, node *b){

  struct node *temp;
   if (a== NULL ) return b;
   if(b==NULL) return a;

  if(a-> data <= b-> data)
   temp = a;
   temp-> next = Merge(a->next, b);
 else
   temp = b;
   temp-> next = Merge(a, b-> next);
  return;
}





On Sat, Mar 24, 2012 at 1:55 PM, Sambhavna Singh wrote:

> can anyone explain vividly how we can use merge sort here. thank you.
>
>
> On Sat, Mar 24, 2012 at 1:54 PM, Sambhavna Singh 
> wrote:
>
>> @atul: we always need to point at the next larger node..so that is ruled
>> out.
>>
>> On Sat, Mar 24, 2012 at 10:14 AM, Atul Singh wrote:
>>
>>> I couldn't understand the meaning of " *return the pointer to smallest*
>>> "
>>> Is it that that the pointer of largest node will point to smallest node.
>>>
>>>
>>>
>>> ATul Singh | Final Year  | Computer Science & Engineering | NIT
>>> Jalandhar  | 9530739855 |
>>>
>>> --
>>> 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: MS QUESTION_LINKED LIST

2012-03-23 Thread Abhishek Sharma
@don: inplace Mergesort can be used. Complexity would be O(nlogn).
@Ashish: Heapsort is reliable but unstable and also, slower.

On Sat, Mar 24, 2012 at 1:49 AM, Don  wrote:

> A merge sort will be O(n*log n) and not use the extra memory required
> for a heap.
> Don
>
> On Mar 23, 3:11 pm, Ashish Goel  wrote:
> > actually, multimap can be avoided, each element of heap is key,value
> where
> > key is the element and value is address and build heap on key.
> > Best Regards
> > Ashish Goel
> > "Think positive and find fuel in failure"
> > +919985813081
> > +919966006652
> >
> >
> >
> > On Sat, Mar 24, 2012 at 1:40 AM, Ashish Goel  wrote:
> > > don't know if i am complicating..assumption,
> >
> > > build a multimap of values and the corresponding node address as well
> as a
> > > heap from the given nodes in first pass.
> >
> > > now from minheap pick one by one and set the second pointer of previous
> > > picked min element to this element using multimap(remove from multimap
> in
> > > parallel while updating the second pointers).
> >
> > > Best Regards
> > > Ashish Goel
> > > "Think positive and find fuel in failure"
> > > +919985813081
> > > +919966006652
> >
> > > On Sat, Mar 24, 2012 at 12:50 AM, Atul Singh  >wrote:
> >
> > >> Given a linked list with each node having two pointers : one pointing
> to
> > >> next node & other to null;
> > >> how will u point the second pointer to next larger no. and return the
> > >> pointer to smallest node
> >
> > >> --
> > >> ATul Singh | Final Year  | Computer Science & Engineering | NIT
> > >> Jalandhar  | 9530739855 |
> >
> > >> --
> > >> 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.



Re: [algogeeks] MS QUESTION_LINKED LIST

2012-03-23 Thread Abhishek Sharma
It is basically sorting the linked list. Do not change the first pointer of
nodes and use the second pointer for sorting. return the pointer to the
smallest element. That's it.

On Sat, Mar 24, 2012 at 12:50 AM, Atul Singh wrote:

> Given a linked list with each node having two pointers : one pointing to
> next node & other to null;
> how will u point the second pointer to next larger no. and return the
> pointer to smallest node
>
>
>
> --
> ATul Singh | Final Year  | Computer Science & Engineering | NIT Jalandhar
>  | 9530739855 |
>
> --
> 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.



[algogeeks] Given a String with unnecessary spaces, compact it in place

2011-10-10 Thread abhishek sharma
Can in place compaction be done without left shifts?



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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] subset of an array

2011-10-10 Thread abhishek sharma
yea DP will be O(given no * n) if all array entries are positive and the
given no is non negative.

On Mon, Oct 10, 2011 at 11:09 PM, anshu mishra wrote:

> the simplest code could be for this question is
>
> void printAllSubsetSum(int ar[], int n, int x)
> {
> for (i = 0; i < (1< {
> int sum = 0;
>  for (j = 0; j < n; j++)
>  {
> if ( (1 << j) && i) sum += ar[j];
>  }
>  if (sum == x)
>  {
> for (j = 0; j < n; j++)
>{
>if ( (1 << j) && i) printf("%d ", ar[j]);
>}
>   printf("\n");
>  }
> }
> }
>
> Time complexity O(2^n)
>
> this can be solved using DP in O(n * given number);
>
>  --
> 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.
>



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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: All valid dictionary words must be found and printed.

2011-10-04 Thread abhishek sharma
if we use brute force we have sum(n + n-1 + .. n-r .. + 1) = n*n words which
are to be checked. Therefore O(n-sq).

now, if i can use a dictionary interface to reject some prefix altogether,
than i need not check some words, o/w with the given interface we cannot do
it any better than quadratic time.

On Tue, Oct 4, 2011 at 6:23 PM, Navneet  wrote:

> What is the source of this question?
>
> On Sep 20, 4:49 am, Ankur Garg  wrote:
> > nice find bhanu..though i didnt get much :P on first read :D :D
> >
> > On Tue, Sep 20, 2011 at 4:34 AM, Bhanu Kishore  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > See this algorithm:
> > >http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_alg.
> ..
> >
> > > --
> > > 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.
>
>


-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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: Sudoku

2011-10-04 Thread abhishek sharma
Hi Don,

How is your method better than backtracking?

i hope you are implementing a sudoku solver..

Let me know.

Regds.

On Tue, Oct 4, 2011 at 10:42 PM, Don  wrote:

> When you say "Simulate" Sudoku, do you mean solve a given Sudoku
> problem?
>
> Here is an overview of how I did that:
>
> I used an array of 81 integers to represent the board.
> Then I built a 27x9 table of all the groups: 9 rows, 9 columns, and 9
> squares.
> Then I built a 81x3 map which relates each location on the board to
> the 3 groups it belongs to.
> I maintain an array of 27 integers called "avail" whose bits indicate
> which values are still needed in that group.
>
> Read in the given values and update avail accordingly.
>
> Then repeatedly do the following until the problem is solved
>   For each empty cell
>   Compute the bitwise AND of the avail values for the 3 groups it
> belongs to.
>   If the AND is zero, no value can go there. Return failure.
>   If exactly one value can go there, put it there and update the
> avail values for the 3 groups
>   If the loop above did not fill in any cells, then do the following
>   Loop at each of the 27 groups
>   For each value missing in that group, count the locations
> where it could go
>   If it could go in exactly one location, put it there
>   If it cannot go in any location, return failure.
>   If the neither method above filled in any cells, then do the
> following:
>   Pick the empty cell with the fewest possible values
>   Try the possible values in that cell until you find one which
> allows the puzzle to be completed
>
> If the puzzle is solvable, this will solve it in a fraction of a
> second.
>
> Don
>
> On Oct 4, 9:21 am, himanshu kansal 
> wrote:
> > can anybody give me the steps you need to check while writing a
> > program to simulate sudoku
> >
> > i don't want the exact codejust algorithm would me more than
> > sufficient.
> >
> > suggest also the suitable languages for implementing that..VB or
> > java or any other
>
> --
> 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.
>
>


-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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-09-18 Thread abhishek sharma
for your question -


On Sun, Sep 18, 2011 at 3:44 PM, abhishek sharma wrote:

> hi prasanth,
>
> i was asked a similar ques but with the condition that path shud terminate
> at a leaf node & u just have to return true if you are able to find a path.
>
> what i did was,
> - do an inorder traversal (u have to pass a parameter that represents
> sum as well along with treenode pointer)
> - at every leaf check the value of cumulative sum of all the parents'
> data and the current node's data
>
> for printing paths u can use a stack
>
>
>
>
> On Sun, Sep 18, 2011 at 2:26 PM, prasanth n  wrote:
>
>> You are given a binary tree in which each node contains a value. Design an
>> ALGORITHM to print all paths which sum up to that value. Note that it can be
>> any path in the tree - it does not have to start at the root.
>>
>> --
>> *prasanth*
>>
>> --
>> 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.
>>
>
>
>
> --
> Nice Day
>
> Abhishek Sharma
> Bachelor of Technology
> IIT Kanpur (2009)
>



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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-09-18 Thread abhishek sharma
hi prasanth,

i was asked a similar ques but with the condition that path shud terminate
at a leaf node & u just have to return true if you are able to find a path.

what i did was,
- do an inorder traversal (u have to pass a parameter that represents
sum as well along with treenode pointer)
- at every leaf check the value of cumulative sum of all the parents'
data and the current node's data

for printing paths u can use a stack



On Sun, Sep 18, 2011 at 2:26 PM, prasanth n  wrote:

> You are given a binary tree in which each node contains a value. Design an
> ALGORITHM to print all paths which sum up to that value. Note that it can be
> any path in the tree - it does not have to start at the root.
>
> --
> *prasanth*
>
> --
> 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.
>



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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] Elitmus test Help

2011-08-24 Thread Abhishek Sharma
similar to CAT though the level is little low... no technical questions are
asked..

On Wed, Aug 24, 2011 at 11:50 PM, Akanksha .  wrote:

> It is  a general aptitude test.. they ask u ques on quant, verbel n
> problems solving skills.. prepare well if u r planning to take this
> test as ques r tough..
>
> On Wed, Aug 24, 2011 at 11:45 PM, rohit  wrote:
> > Is anybody have any idea about pattern of elitmus test , Is It a C
> > programming test or General aptitude test?
> >
> > --
> > 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] Puzzle

2011-08-18 Thread Abhishek Sharma
M (hint: replace ü and û with their actual meaning.. u 'll understand)

On Fri, Aug 19, 2011 at 4:10 AM, payal gupta  wrote:

> was there anything more specified
> Regards,
> PAYAL GUPTA
>
>
> On Fri, Aug 19, 2011 at 3:29 AM, Aditya Virmani 
> wrote:
>
>> If ü - Married
>> û - Not Married and
>> M-ü N-û
>> N-ü L-û
>> L-û M-ü
>> Who is married?
>>
>> qn was put up in this way, asked in Deloitte 2004.
>>
>> --
>> 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: exit() vs. _exit()

2011-08-18 Thread Abhishek Sharma
exit() calls clean up codes (flushing the buffer etc) while _exit() does
not..

FYI- pls use google for such questions.

Regards,
Abhishek

On Thu, Aug 18, 2011 at 3:26 PM, Amol Sharma  wrote:

> anyone ??
>
> --
>
>
> Amol Sharma
> Third Year Student
> Computer Science and Engineering
> MNNIT Allahabad
>
>
>
>
> On Thu, Aug 18, 2011 at 10:40 AM, Amol Sharma wrote:
>
>> what is the difference between exit() and _exit
>>
>> http://ideone.com/MCzGy
>>
>> http://ideone.com/SxbwT
>>
>> when i am using exit() hello world is printed but with _exit() nothing
>> gets printed though it ran successfully.plz explain why is so happening
>> ??
>>
>>
>> --
>>
>>
>> Amol Sharma
>> Third Year Student
>> Computer Science and Engineering
>> 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.



Re: [algogeeks] Coding..........

2011-07-21 Thread Abhishek Sharma
small change in the pseudocode..

for (i=0 until i+ a[].length){

if (*leftptr % 2 == 0)
 A2[i] = *leftptr ;

else if (*rtptr % 2 == 0)
 A2[i+a[].length-1] = *rtptr ;

leftptr++;
rtptr--;

}

-- 
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] Coding..........

2011-07-21 Thread Abhishek Sharma
scan the array from both the ends..i.e use two pointers to scan the array..
left pointer points at the beginning and right one one at the end..
left pointer can be used to find whether an element is even or not until it
reaches end while right pointer can be used to find whthr a no is odd until
it reaches the starting of the array..

for (i=0 until i+ a[].length){

if (*leftptr % 2 == 0)
 A2[i] = *leftptr ;
else
 leftptr++;
if (*rtptr % 2 == 0)
 A2[i+a[].length-1] = *rtptr ;
else
 rtptr--;
}


On Thu, Jul 21, 2011 at 11:32 PM, UMESH KUMAR wrote:

> Hi
>  Given an array A[], write a function to separate even and odd numbers
> (i.e., put all even numbers first than odd numbers) and stability is also
> maintain for the elements in the Array.
>
> Eg.
> input:
>
> A[] = {12, 34, 45, 9, 8, 90, 3}
>
> output:
> A[] = {12, 34, 8, 90, 45, 9, 3}**
>
>
>
>
> Thanks
>
> --
> 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: sbtration

2011-07-11 Thread Abhishek Sharma
@sunny: +1

On Tue, Jul 12, 2011 at 11:11 AM, Vishal Thanki wrote:

> z = x + (-y)
>
> :)
>
> On Tue, Jul 12, 2011 at 10:58 AM, Sunny T  wrote:
> > i would say.. implementing subtraction using division and modulus is more
> > costly and complicated. bit manipulation is the fastest among all
> > these techniques.
> >  x=a-b = (a/b)*b + a%b
> > .here u are performing... totally 4 operations..1 division,1
> > multiplication,1 modulus and 1 addition..
> >
> > it can be easily done by...
> >
> > x=a+(~b+1). this solution takes less number of operation than
> > ur solution and involve less costly operators.
> >
> > On Tue, Jul 12, 2011 at 10:29 AM, Dave  wrote:
> >>
> >> @Chandy: Let a = 5 and b = 3. Then x = 5 - 3 = (5/3)*3 + 5%3 = 1*3 + 2
> >> = 5. Check?
> >>
> >> Dave
> >>
> >> On Jul 11, 11:38 pm, chandy jose paul  wrote:
> >> > Y are u guys complicating things.Its as simple as this
> >> >
> >> >  x=a-b = (a/b)*b + a%b
> >> >
> >> >
> >> >
> >> > On Tue, Jul 12, 2011 at 1:18 AM, Dave 
> wrote:
> >> > > @Aditya: Since 124 is a 3-digit number, I think it would make more
> >> > > sense to use the 3-digit 10's complement of 46, i.e., 954. Then 124
> +
> >> > > 954 = 1078. Since we are working in 3-digit numbers, the 1
> represents
> >> > > an overflow, which you ignore. Thus, the answer is 78.
> >> >
> >> > > Dave
> >> >
> >> > > On Jul 11, 2:42 pm, aditya pratap 
> wrote:
> >> > > > suppose u want to do 124 - 46
> >> >
> >> > > > step1 : write 10's complement of 46 i.e. 53 (9's complement) +1 =
> 54
> >> > > > step2: add 124 + 54 = 178
> >> > > > step3: neglect 1 from 178 and answer will be 78.
> >> >
> >> > > > correct me if i am wrong.
> >> >
> >> > > > On Tue, Jul 12, 2011 at 12:54 AM, Anika Jain
> >> > > > 
> >> > > wrote:
> >> > > > > how to do subtraction of two integers widout using subtractn??
> >> >
> >> > > > > --
> >> > > > > 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
> >> > > > Aditya Pratap
> >> > > > MCA II
> >> >
> >> > > --
> >> > > 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.
> >>
> >
> >
> >
> > --
> > Warm Regards,
> > Sunny 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.
> >
>
> --
> 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] sbtration

2011-07-11 Thread Abhishek Sharma
x-y = add(x, add(~y, 1)) 
here add(~y,1) refers to the Two's complement of y...

On 7/12/11, Anika Jain  wrote:
> how to do subtraction of two integers widout using subtractn??
>
> --
> 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] os

2011-06-22 Thread Abhishek Sharma
@rahul: buddy, u can ignore the mail if u don't want to answer (no offense).
Lets not discourage someone from asking questions...

On Tue, Jun 21, 2011 at 11:23 PM, rahul  wrote:

> If u want us to solve the GATE paper, please attach the paper, we will post
> the solution.
>
> regards.
>
>
> On Tue, Jun 21, 2011 at 11:21 PM, Akshata Sharma <
> akshatasharm...@gmail.com> wrote:
>
>> The atomic fetch-and-set x, y instruction unconditionally sets the memory
>> location x to 1 and fetches the old value of x n y without allowing any
>> intervening access to the memory location x. consider the following
>> implementation of P and V functions on a binary semaphore S.
>>
>> void P (binary_semaphore *s)
>>   unsigned y;
>>   unsigned * = &(s—>value);
>>   do
>> fetch—and—set x, y;
>>   while (y)
>>
>> void V (binary_semaphore *s)
>>S—>value = 0;
>> Which one of the following is true?
>> (A) The implementation may not work if context switching is disabled in P
>> (B) Instead of using fetch-and —set, a pair of normal load/store can be
>> used
>> (C) The implementation of V is wrong
>> (D) The code does not implement a binary semaphore
>>
>> --
>> 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] Online Jobs for Students

2011-04-15 Thread Abhishek Sharma
Our all candidates of batch Sept 10 - Jan 11 got placed in top MNC companies
with very lucrative salary like earlier batches. Most of the candidates had
multiple job offers with min Rs. 15000/-  in hand per month salary. Jan 11 -
May 11 batch placement is running and almost 50% students has already got
placed with average salary of Rs. 17,500/- per month.  After a huge
recommendations and orders from many MNC and Pvt. Ltd companies, we are
going to start a new batch April 2011 of iphone/Android Application and game
development namely,

*1. "Flab Java -* Android Application and 2D/ 3D Game Development" course
for six months. You will be trained completely on Advance Android
application development, Device driver programming and 2D/3D Game
development.

*2. "Flab Macintosh -* iphone/ipad Application and 2D/3D Game Development"
course for six months. You will be trained completely on Advance iphone/ipad
application development, Device driver programming for Macintosh and 2D/3D
Game development.

*Placement at FresherLab*

The quality of training at FresherLab has reflected in its student’s
extraordinary performance in Placement session. All trained students have
been placed in top MNC companies within fifteen days of start of placement
session. Around 80% students had multiples job offer from different MNC
companies. FresherLab provides high quality placement services to its
trained candidates.

The average salary offered to FresherLab's trained candidate of earlier
batches was 2.2 Lac per Annum with INR 16,000 per month in hand. The list of
the trained candidates from FresherLab who was offered the placement in MNC
and Pvt. Limited companies in the batch of Sept.10- Jan.11 can be viewed by
*clicking this link
*

Based on the quality training and getting deserving candidates from
FresherLab, companies have tied up with FresherLab for a long term placement
and need trained professional from us. So again, FresherLab is back with the
training as per company's order. There are huge requirements of iphone/ipad
and Android application developer in  India and abroad.

*Please click here to download complete placement detail and List of
companies who recruit our students.

*

*No one can promise in written document, but we will give you written
agreement for 100% job guarantee:*
We are providing 100% job guarantee with this course. In case you couldn't
get placed in four  months after course completion, we will refund your
money back. We will give the agreement in written.

*Course syllabus*

We are attaching the complete course syllabus with this email. In brief, you
will be trained like this.

 1. First Two Months: Complete application development from scratches with
three live projects.

 2. Third Month : Live project based on training done in first two months.

 3. Forth Month: 2D Game Development with one live project .

 4. Fifth Month: 3D Game Development with one live project.

 5. Sixth Month : Game development Live project.

 This Six Months course has been designed such a way that you will get
experience equivalent to 1.5 years in the industries with minimum 5 live
projects.

*You can download the detailed course syllabus from the following links.*

 1. iphone/ipad application and game development : *click here to
download course
syllabus
 *

 2. Android application and game development : *click here to download
course  **
syllabus *

*Certification *

We are offering following certifications with this course.

1. Expert Rating certified Android Application Developer

2. Expert Rating certified iphone/ipad Application Developer

3. Fresher Lab Certified Android Application Developer

4. Fresher Lab Certified iphone/ipad Application Developer

5. Fresher Lab Certified 2D Game Developer

6. Fresher Lab Certified 3D Game Developer

This course has been specially designed to qualify above certifications
which will be giving value to your future career.

*Fees
*
The course fee for this course is Rs. 65000/- .
We are offering installment option as well. Following is the installment
option.
 1. Lumpsum: Rs. 65000/-
 2. Two Installments: Rs. 35,000/- each
*Join us
*
 We are making a batch of only 16 candidates in iphone/ipad and 9 candidates
in Android batch, As we have got order from many MNC and Pvt. Limited
companies to provide Android and iphone/ipad trained Freshers, That is the
reason, we are starting this batch with 100% job guarantee. The enrollment
for the batch has been started.
*
 *
For any enquiry, you can call us at following numbers:
*Mobile No. : +91- 9241051869, 9241581071, 9241409209, 9241867775
 *
If you are Interested, you can enroll on or 

Re: [algogeeks] Are U a Student Must Read this Frwd This Please If u Like We R student like You TOO

2011-04-06 Thread Abhishek Sharma
@Carl: the one at the bottom works..

On Fri, Apr 1, 2011 at 1:17 AM, hary rathor  wrote:

> everybody want to be mark.
>
> --
> 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: 28march

2011-04-06 Thread Abhishek Sharma
@sourabh: could u please elaborate how u came to that conclusion.
Dave's logic seems to be right..

On Thu, Mar 31, 2011 at 11:00 AM, sourabh jakhar wrote:

> answer is 6 races
>
>
>
> On Mon, Mar 28, 2011 at 11:53 PM, Dave  wrote:
>
>> 7 races.
>>
>> For the first five races, divide the horses into groups of five and
>> record the win, place, and show finishers of each race.
>>
>> For the sixth race, run the winners of the first five races.
>>
>> Now, only six horses remain in contention for the fastest three:
>>   The winner of the sixth race and the place and show horses of his
>> first race,
>>   The place horse in the sixth race and the place horse in his first
>> race.
>>   The show horse in the sixth race.
>>   Three of these horses are known to be faster than all other horses.
>>
>> The winner of the sixth race is known to be the fastest horse. Run the
>> other five contenders in race 7 and choose the fastest two.
>>
>> Dave
>>
>> On Mar 28, 2:54 am, Lavesh Rawat  wrote:
>> > *Horse Race Problem Solution*
>> > *
>> > *Ok, so there are 25 horses and the race track only allows 5 horses to
>> race
>> > at a given time. Given that there is no stop watch available your task
>> is to
>> > determine the fastest 3 horses. Assume that each horses speed is
>> constant in
>> > different races, what is the minimum number of races to determine the
>> > fastest 3?
>> >
>> > Update Your Answers at : Click
>> > Here<
>> http://dailybrainteaser.blogspot.com/2011/03/28march.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.
>>
>>
>
>
> --
> SOURABH JAKHAR,(CSE)(3 year)
> ROOM NO 167 ,
> TILAK,HOSTEL
> 'MNNIT ALLAHABAD
>
> The Law of Win says, "Let's not do it your way or my way; let's do it the
> best way."
>
>  --
> 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] interview

2011-03-27 Thread Abhishek Sharma
*@Shady:* buddy lets not discourage som1 interested in learning :) this is
the purpose of this group..
*
@harry:* as some1 has said: "there is no shortcut to success".. first go
through any good Datastructures/algorithms book.. try to code those
algorithms on ur own..once u feel u r comfortable with the basics u can go
through the previous posts of this group and implement the algos for more
practice..


On Mon, Mar 28, 2011 at 12:22 AM, shady  wrote:

> what kind of question is this ?
> the quality of this group is degrading day by day :(
>
>
> On Sun, Mar 27, 2011 at 10:44 PM, hary rathor wrote:
>
>> hello friends
>> pls suggest me that which algorithm problem i should implement  that are
>> ask  in most in interviews
>>
>> --
>> 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] Print Hello infinite..................

2011-03-15 Thread Abhishek Sharma
@nidhi: yup.. u r rite.. sorry..my bad...

On Thu, Mar 10, 2011 at 11:58 AM, Nishant Agarwal <
nishant.agarwa...@gmail.com> wrote:

> #include
> void print1();
> void print2()
> {
> printf("Hello\n");
> print1();
> }
> void print1()
> {
> printf("Hello\n");
> print2();
> }
> int main()
> {
> print1();
>
> }
>
>
> On Thu, Mar 10, 2011 at 11:47 AM, nidhi jain 
> wrote:
>
>>
>>
>> @abhishek:isn't it 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.
>>
>
>
>
>
>  --
> 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] Print Hello infinite..................

2011-03-15 Thread Abhishek Sharma
thanks a ton for the info... we didnt know about that :P...
btw for ur info.. we are not supposed to use loops as well..

On Fri, Mar 11, 2011 at 7:10 PM, Abhishek Mallick <
abhishek.mallick2...@gmail.com> wrote:

> #include 
> int main()
> {
> while(printf("Hello"));
> return 0;
> }
>
> On Thu, Mar 10, 2011 at 11:58 AM, Nishant Agarwal <
> nishant.agarwa...@gmail.com> wrote:
>
>> #include
>> void print1();
>> void print2()
>> {
>> printf("Hello\n");
>> print1();
>> }
>> void print1()
>> {
>> printf("Hello\n");
>> print2();
>> }
>> int main()
>> {
>> print1();
>>
>> }
>>
>>
>> On Thu, Mar 10, 2011 at 11:47 AM, nidhi jain 
>> wrote:
>>
>>>
>>>
>>> @abhishek:isn't it 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.
>>>
>>
>>
>>
>>
>>  --
>> 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] Link list Problem

2011-03-15 Thread Abhishek Sharma
modifying balaji's approach and adding few more things:

traverse until u find the node...then
loop
   copy data from the next node
until u reach the last node
then delete the last node.

Ex:

Consider the SLL:
1 -> 2 -> 3 -> 4 -> 5

Suppose the head pointer is lost and is currently pointing to '2'.

1) if u want to delete 3:
the scenario is like this:

1 -> 2 -> 3 -> 4 -> 5
   |
lost_head_ptr

declare another ptr pointing to the location of lost_head_ptrtraverse
until u find 3...

1 --> 2 --> 3 -> 4 -> 5
|   |
lost_head_ptr  temp_iter

then apply the algorithm...

1 -> 2 -> 4 -> 4 -> 5
 |
temp_iter

1 -> 2 -> 4 -> 5 -> 5
   |
 temp_iter


1 -> 2 -> 4 -> 5


2) If u want to delete 1: there exists no way(since its SLL and header is
lost)..unless u can find out the location of the byte pointing to 2(this can
be done btw...little complex though)...but for now we assume we can't delete
1.



1 -> 2 -> 4 -> 4 -> 5
  *


On Sun, Mar 13, 2011 at 10:27 PM, abhijith reddy
wrote:

> copy data from the next node and then delete that next node.
>
> Say you need to delete 3
>
> 1 -> 2 -> 3 -> 4 -> 5
>
> 1 -> 2 -> 4 -> 4 -> 5
>   *
> Now delete node which is next to '*'.
>
>
> On Sun, Mar 13, 2011 at 10:23 PM, UMESH KUMAR wrote:
>
>> hi
>>
>>  Given a singly Link list but Head of the List is
>>  unknown so my question is that 
>>
>>   How to delete a given node from the 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.
>

-- 
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] Print Hello infinite..................

2011-03-09 Thread Abhishek Sharma
#include headers

int main(){

printf("Hello");
main();
}


On Mon, Mar 7, 2011 at 7:38 AM, Terence  wrote:

>  system("yes Hello");
> (on Linux)
>
>
> On 2011-3-7 2:09, sudheer kumar wrote:
>
> use GOTO
>
> On Sun, Mar 6, 2011 at 10:49 PM, UMESH KUMAR wrote:
>
>> How to print Hello Infinite times without using
>> Loop and Recursion 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.
>>
>
>
>
> --
> Thanks and Regards
> chigullapallysudh...@gmail.com
> Sudheer
>
> --
> 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] Interview questions for multithreading in Java

2011-03-08 Thread Abhishek Sharma
what do u mean by multi-threading :P

On Tue, Mar 8, 2011 at 7:37 PM, vaibhav agrawal wrote:

> Hi,
>
> What interview questions one would expect for multi-threading?
>
> Thanks,
> Vaibhav
>
> --
> 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] Interview questions for multithreading in Java

2011-03-08 Thread Abhishek Sharma
u can go through the following questions...not sure about the answers...:

1) What are the two types of multitasking?

Ans : 1.process-based

2.Thread-based

2) What are the two ways to create the thread?

Ans : 1.by implementing Runnable

2.by extending Thread

3) What is the signature of the constructor of a thread class?

Ans : Thread(Runnable threadob,String threadName)

4) What are all the methods available in the Runnable Interface?

Ans : run()

5) What is the data type for the method isAlive() and this method is

available in which class?

Ans : boolean, Thread

6) What are all the methods available in the Thread class?

Ans : 1.isAlive()

2.join()

3.resume()

4.suspend()

5.stop()

6.start()

7.sleep()

8.destroy()

7) What are all the methods used for Inter Thread communication and what is
the class in which these methods are defined?

Ans :1. wait(),notify() & notifyall()

2. Object class

8) What is the mechanisam defind by java for the Resources to be used by
only one Thread at a time?

Ans : Synchronisation

9) What is the procedure to own the moniter by many threads?

Ans : not possible

10) What is the unit for 1000 in the below statement?

ob.sleep(1000)

Ans : long milliseconds

11) What is the data type for the parameter of the sleep() method?

Ans : long

12) What are all the values for the following level?

max-priority

min-priority

normal-priority

Ans : 10,1,5

13) What is the method available for setting the priority?

Ans : setPriority()

14) What is the default thread at the time of starting the program?

Ans : main thread

15) The word synchronized can be used with only a method.

True/ False

Ans : False

16) Which priority Thread can prompt the lower primary Thread?

Ans : Higher Priority

17) How many threads at a time can access a monitor?

Ans : one

18) What are all the four states associated in the thread?

Ans : 1. new 2. runnable 3. blocked 4. dead

19) The suspend()method is used to teriminate a thread?

True /False

Ans : False

20) The run() method should necessary exists in clases created as subclass
of thread?

True /False

Ans : True

21) When two threads are waiting on each other and can't proceed the
programe is said to be in a deadlock?

True/False

Ans : True

22) Which method waits for the thread to die ?

Ans : join() method

23) Which of the following is true?

1) wait(),notify(),notifyall() are defined as final & can be called only
from with in a synchronized method

2) Among wait(),notify(),notifyall() the wait() method only throws
IOException

3) wait(),notify(),notifyall() & sleep() are methods of object class

1
2
3
1 & 2
1,2 & 3
Ans : D
24) Garbage collector thread belongs to which priority?

Ans : low-priority

25) What is meant by timeslicing or time sharing?

Ans : Timeslicing is the method of allocating CPU time to individual threads
in a priority schedule.

26) What is meant by daemon thread? In java runtime, what is it's role?

Ans : Daemon thread is a low priority thread which runs intermittently in
the background doing the garbage collection operation for the java runtime
system

On Tue, Mar 8, 2011 at 9:16 PM, Abhishek Sharma wrote:

> what do u mean by multi-threading :P
>
>
> On Tue, Mar 8, 2011 at 7:37 PM, vaibhav agrawal wrote:
>
>> Hi,
>>
>> What interview questions one would expect for multi-threading?
>>
>> Thanks,
>> Vaibhav
>>
>> --
>> 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] [brain teaser ] 1march

2011-03-01 Thread Abhishek Sharma
beetle :P

On Tue, Mar 1, 2011 at 2:01 PM, Ankur pratik  wrote:

> beetle
>
>  --
> 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] Maths

2011-02-22 Thread Abhishek Sharma
This is simple..

Find the values for f(n) for n=1,2,3,4,... n-1 which are 0, 1, 2, 3, ... n-2
respectively. (Solve the equation for n=2,3, etc to get the values).

>From the pattern you can easily find out that f(n+1)= n.

On Wed, Feb 16, 2011 at 9:15 PM, Vikas Kumar  wrote:

> f(n)=n-1.
>
>
> On Wed, Feb 16, 2011 at 7:39 PM, Akshata Sharma  > wrote:
>
>> please help..
>>
>> if f(n+1) = max{ f(k) + f(n-k+1) + 1} for 1 <= k <= n; f(1)  = 0.
>> Find f(n+1) in terms of n.
>> Eg: f(4) = ? n = 3; 1<= k <= 3; f(4) = max{f(1) + f(3) + 1, f(2) +
>> f(2)+1, f(3) + f(1) +1}
>>
>> --
>> 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] can i know the best way to learn programming??

2011-02-02 Thread Abhishek Sharma
dude... Practice is the only solution to ur problem...

U can try any one of the following: topcoder, spoj, (already mentioned in
the thread) codechef etc...

U can also refer to previous posts in this group and try to code those
problems on your own and then refer to the solutions to check where you can
improve..U can always come back to us in case of any difficulty..

Happy Coding :)

-- 
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] Sites for Interview Questions

2011-01-21 Thread Abhishek Sharma
Programming Interviews Exposed is a good one..

On Tue, Jan 18, 2011 at 9:27 PM, Yellow Sapphire wrote:

> Hi,
>
> Can someone suggest good books/websites/blogs for interview related
> questions.
>
>
> thanks--
> YS
>
> --
> 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.



[algogeeks] Algorithm

2010-07-05 Thread Abhishek Sharma
You are given a set of phrases (let us call them keywords), each of
1-4 words. Group the keywords into clusters (groups of keywords) by
picking keywords which are similar to each other.

There are multiple ways to cluster(group) them
1) using single keyword as the cluster name. Eg cluster name "gifts" -
this cluster should have all keywords which has gift in it, christmas
- should have all keywords which have christmas in it and so on
2) considering 2 words as the cluster name: gift ideas, gifts,
christmas, craft. All keywords which have the 2 word cluster name
appearing in sequence (phrase matching) in the keyword fall into that
cluster

To pick the cluster name: Pick the most popular 1 word and 2 word
sequence from the given keyword set


Eg input set of keywords:
best dad gifts
best gifts
birthday gift ideas
birthday gifts
boss gift ideas
boyfriend gift ideas
christmas craft ideas
christmas for dad
christmas gifts for dad
christmas gift ideas
christmas gifts
christmas gifts dad
cool gifts
craft gift ideas
craft ideas
craft room ideas
crafts

Sample Clusters:
gifts: best dad gifts, best gifts, birthday gifts, christmas gifts for
dad, christmas gifts, christmas gifts dad, cool gifts
gift: birthday gift ideas, boss gift ideas, boyfriend gift
ideas,christmas gift ideas, craft gift ideas
christmas: "christmas craft ideas", "christmas for dad", "christmas
gifts for dad", "christmas gift ideas", christmas gifts, christmas
gifts dad
gift ideas: "birthday gift ideas", "boyfriend gift ideas", "christmas
gift ideas", "craft gift ideas"

and so on

-- 
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] Amazon: sort array

2010-07-02 Thread Abhishek Sharma
I think its similar to the merge operation which is used in merge sort...

correct me if I am wrong..

Regards,
Abhishek

On Sat, Jul 3, 2010 at 12:00 AM, ANKUR BHARDWAJ wrote:

> Given an array of n elements and an integer k where k {a[0].a[k] and a[k+1].a[n] are already sorted. Give an
> algorithm to sort in O(n) time and O(1) 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.



Re: [algogeeks] Amazon: sort array

2010-07-02 Thread Abhishek Sharma
@Anand: good one

On Sat, Jul 3, 2010 at 2:02 AM, Anand  wrote:

> This is an example of bitonic sequence if we reverse the bottom half of the
> array.
> Sequence is called Bitonics if the sequence of number first
> increases(ascending order) and then decrease(descending order).
>
> 1. We need to reverse the bottom half the array to make it bitonic.
> 2. Appy Bitonic Merge to get the final sorted array.: Complexity.O(n)
>
> In the below code, I have implemented sorting n/w to sort any kind of array
> but for bitonic sequence we only bitonic merge function call which take
> O(n).
> Refer section Sorting network from Corman for more details
>
> http://codepad.org/ZhYEBqMw
>
>
>
>
> On Fri, Jul 2, 2010 at 11:30 AM, ANKUR BHARDWAJ wrote:
>
>> Given an array of n elements and an integer k where k> {a[0].a[k] and a[k+1].a[n] are already sorted. Give an
>> algorithm to sort in O(n) time and O(1) 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] Project on finding an optimal route given a map.

2010-07-02 Thread Abhishek Sharma
@Anand:
> Let me know your input we can modify it accordingly.
I have already mentioned it in previous posts.. for your sake I ll do it
again..
Input is a a map of a small area..(some college campus)..it can be in the
form of an image, osm format (www.openstreetmap.org) or in the kml format (
maps.google.com) for that particular region...
So creating distance matrix is the problem.. I do not want to do it
manually(ie finding the distance of each node/dept from other nodes manually
and then updating the distance matrix).. so i was thinking of writing an
algorithm which takes the input and creates the distance matrix... which is
the main challenge in this project.
I request you to join the group..(http://groups.google.co.in/group/*
optiroute*  ) so that we discuss
about this there..instead of spamming this group..

@Sidhartha: we will face following problems if we use open Route Service:
  1) we ll have to zoom in to the place everytime we
open/refresh the page.
  2) and the main thing is it works only for Europe.
thanks for the help by the way. why dont you also join the group..
http://groups.google.co.in/group/*optiroute*

-- 
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] crazy

2010-06-29 Thread Abhishek Sharma
yeah its 1/2

On Tue, Jun 29, 2010 at 12:37 PM, ankur aggarwal
wrote:

> i think it shud be 1/2.. i will try to prove it...
>
>
> On Mon, Jun 28, 2010 at 8:52 AM, sharad kumar wrote:
>
>> Problem :- A line of 100 airline passengers is waiting to board a plane.
>> They each hold a ticket to one of the 100 seats on that flight. (For
>> convenience, let's say that the nth passenger in line has a ticket for the
>> seat number n.)
>> Unfortunately, the first person in line is crazy, and will ignore the seat
>> number on their ticket, picking a random seat to occupy. All of the other
>> passengers are quite normal, and will go to their proper seat unless it is
>> already occupied. If it is occupied, they will then find a free seat to sit
>> in, at random.
>> What is the probability that the last (100th) person to board the plane
>> will sit in their proper seat (#100)?
>>
>> --
>> 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.
>>
>
>
>
> --
> With Regards
>
> Ankur Aggarwal
>
>
>  --
> 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] Project on finding an optimal route given a map.

2010-06-28 Thread Abhishek Sharma
@senthil: thanks for the interest.. I did that purposely..(just wanted to
see if any1 is interested or not).. here are the details...

I have a map..of a small area (say a college campus).. in OSM(openstreetmap)
format or it could also be in kml (google map) format..
Now the application is supposed to take two points on the map as input and
display the optimal/shortest route between them..
For ex: consider any college campus.. user enters ITY dept as the source and
CSE Dept as the destination.. then our application is supposed to display
the shortest/optimal path.
We can also take into account the modee of transport..
Right now.. I am going through the OSM maps.. my idea is to classify the map
into nodes, ways etc.. then applying the algorithm to find the shortest
path..
The problem which i am facing is to classify the map into nodes, ways,
finding out the distance between each node..
some of you might be having a better idea in implementing this... I request
you to share it here..

Guys we have discussed lot of algos here.. but this requires the application
of whatever we have learned...so please come forward and lets implement
this...
hoping for a positive response...

Regards,
Abhishek

-- 
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] Re: O(n)

2010-06-28 Thread Abhishek Sharma
may be to figure out the range while reading the numbers or taking the mos
as input... we can have two variables (min and max) that contains the
minimum and maximum elements encountered so far respectively...
i.e. whenever we read a no n we compare it with min and max...
if nmax then max = n;

so the range would lie between min and max..

correct me if I am wrong..

On Mon, Jun 28, 2010 at 2:20 PM, nisha goyal wrote:

> @abhirup: range is required in counting sort how can you decide that??
> please elaborate
>
> On Mon, Jun 28, 2010 at 12:01 PM, Abhirup Ghosh wrote:
>
>> We can sort the array in O(n) time using counting sort. And then take
>> the difference of consecutive elements in O(n) time to get the minimum
>> one.
>>
>> -Abhirup
>>
>>
>>
>> On Mon, Jun 28, 2010 at 10:36 AM, Jagadish M 
>> wrote:
>> > In the general case, we can reduce Element-Distinctness(ED) problem to
>> > this problem. Since ED has a lower bound of Omega(n log n), we cannot
>> > get an O(n) algorithm for this problem.
>> >
>> > http://en.wikipedia.org/wiki/Element_distinctness_problem
>> >
>> >
>> > -Jagadish
>> > http://www.cse.iitb.ac.in/~jagadish
>> >
>> >
>> >
>> > On Jun 27, 5:55 pm, sharad kumar  wrote:
>> >> How to find the two numbers whose difference is minimum among the set
>> of
>> >> numbers
>> >
>> > --
>> > 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.
>

-- 
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] Re: O(n)

2010-06-28 Thread Abhishek Sharma
@abhirup: I agree with ur idea of sorting and then finding out the
difference for the consecutive elementsbut counting sort takes the range
into account.. I dont think range is given...

On Mon, Jun 28, 2010 at 12:01 PM, Abhirup Ghosh  wrote:

> We can sort the array in O(n) time using counting sort. And then take
> the difference of consecutive elements in O(n) time to get the minimum
> one.
>
> -Abhirup
>
>
>
> On Mon, Jun 28, 2010 at 10:36 AM, Jagadish M  wrote:
> > In the general case, we can reduce Element-Distinctness(ED) problem to
> > this problem. Since ED has a lower bound of Omega(n log n), we cannot
> > get an O(n) algorithm for this problem.
> >
> > http://en.wikipedia.org/wiki/Element_distinctness_problem
> >
> >
> > -Jagadish
> > http://www.cse.iitb.ac.in/~jagadish
> >
> >
> >
> > On Jun 27, 5:55 pm, sharad kumar  wrote:
> >> How to find the two numbers whose difference is minimum among the set of
> >> numbers
> >
> > --
> > 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.



[algogeeks] Project on finding an optimal route given a map.

2010-06-27 Thread Abhishek Sharma
Hi friends,

I am doing a project on finding an optimal route between two points given on
a map (well just started with it...). The map can be in OSM/ kml format or
it can be an image as well (for now i have ruled out this option..since this
will involve image processing and i doubt the accuracy..OSM / KML formats
will be much easier to handle..i guess.).

I am not able to move forward.  I request you guys to help me out with this.
Any kind of suggestion/help will be truly appreciated.

Also, if anyone is interested in joining me in this project.. you are most
welcome :)
here is the link to the group i created specially for this project..
http://groups.google.co.in/group/*optiroute*


Thanking You
Abhishek

-- 
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 book

2010-06-19 Thread Abhishek Sharma
If you know  the basics and want to make your base strong then i would
suggest u to read "The C programming language" by Brian
Kernighanand Dennis
Ritchie .


On Sun, Jun 20, 2010 at 1:21 AM, vishard sankhyan wrote:

> hii pls suggest me a book for c, i just want to make my base strong..
>
> --
> 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] Can you solve this?

2010-05-30 Thread Abhishek Sharma
Correction: Team2:7, 10, 11, 12, 15

On Sun, May 30, 2010 at 11:45 PM, Abhishek Sharma wrote:

> @sharad: if you find the subarrays of equal sum then the number of players
> might differ in the team... also can you tell me how will you do
> that..according to me time cmoplexity will be higher..
>
> According to me:
> sort the palyers based on skill points (O(nlogn) --mergesort) then assign
> the players one by one to each team (O(n))
>
> Ex: Consider 10 players to be assigned to two teams.
>skill points: 12, 12, 7, 8, 15, 19, 11, 14, 5, 10.
>
> Ans:
> after sorting: 5, 7, 8, 10, 11, 12, 12, 14, 15, 19.
> Team1: 5, 8, 12, 14, 19
> Team2: 7, 11,12,15.
>
> This is not exactly even but i think is the closest approach.
> correct me if I am wrong..
>
> Regards,
> Abhishek
>
>
> On Sun, May 30, 2010 at 8:21 PM, sharad kumar wrote:
>
>> sort the players based on skill point and get the subarray of equal
>> sum..
>>
>>
>> On Sun, May 30, 2010 at 6:58 PM, Veer Sharma 
>> wrote:
>>
>>> Hi Friends,
>>>
>>> This is my first post to this forum. A "Hi" to all of you and here is
>>> my first problem...
>>>
>>> Giiven int n, the total number of players and their skill-point.
>>> Distribute the players on 2 evenly balanced teams.
>>>
>>> Lets see who gives the best solution (least space complexity / least
>>> time complexity or both...)
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> yezhu malai vaasa venkataramana Govinda Govinda
>>
>>  --
>> 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] Can you solve this?

2010-05-30 Thread Abhishek Sharma
@sharad: if you find the subarrays of equal sum then the number of players
might differ in the team... also can you tell me how will you do
that..according to me time cmoplexity will be higher..

According to me:
sort the palyers based on skill points (O(nlogn) --mergesort) then assign
the players one by one to each team (O(n))

Ex: Consider 10 players to be assigned to two teams.
   skill points: 12, 12, 7, 8, 15, 19, 11, 14, 5, 10.

Ans:
after sorting: 5, 7, 8, 10, 11, 12, 12, 14, 15, 19.
Team1: 5, 8, 12, 14, 19
Team2: 7, 11,12,15.

This is not exactly even but i think is the closest approach.
correct me if I am wrong..

Regards,
Abhishek

On Sun, May 30, 2010 at 8:21 PM, sharad kumar wrote:

> sort the players based on skill point and get the subarray of equal
> sum..
>
>
> On Sun, May 30, 2010 at 6:58 PM, Veer Sharma wrote:
>
>> Hi Friends,
>>
>> This is my first post to this forum. A "Hi" to all of you and here is
>> my first problem...
>>
>> Giiven int n, the total number of players and their skill-point.
>> Distribute the players on 2 evenly balanced teams.
>>
>> Lets see who gives the best solution (least space complexity / least
>> time complexity or both...)
>>
>> --
>> 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.
>>
>>
>
>
> --
> yezhu malai vaasa venkataramana Govinda Govinda
>
>  --
> 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.



[algogeeks] Re: How to dived 2 integer number using bitwise opreration

2008-03-09 Thread abhishek sharma
refer to computer
arithmetic<http://en.wikipedia.org/wiki/Division_%28digital%29>
this is how division is done through hardware

On Sun, Mar 9, 2008 at 2:52 PM, Amritanshu Agrawal <[EMAIL PROTECTED]>
wrote:

>
> Hi All,
> I gave to divide 2 integer number using bitwise opreator.
>
> For Exmaple:
> 12 divided by 6 =  2 quotient
>
> Thnaks in advance
>
> Amritanshu Agrawal
>
> >
>


-- 
regards

Abhishek Sharma
Student
BTECH-INFORMATION TECHNOLOGY
NSIT,DWARKA
NEW 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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---