Re: [algogeeks] Re: how to convert JSONObject object to java object ??

2015-06-19 Thread Ankit Agarwal
You can use Object Mapper, provided by com.fasterxml.jackson.core.

There is a readValue which can convert string type object to any class
object which you want.

Check this maven repo
http://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core/2.6.0-rc2
for
the jar


Thanks  Regards

On Fri, Jun 19, 2015 at 2:43 AM, Nand Kumar Singh nandkuma...@gmail.com
wrote:

 Rest Url : 
 http://localhost:8080//rest/hotel?{location:28.666045,77.185059,longitube:null,latitude:null,pincode:null,childrens:0,adults:1,dateCheckIn:143468460,dateCheckOut:143472420,searchedString:Sarai
 Rohilla Railway Station, Railway Officers Colony, New Delhi,
 India,marker:1,city:Delhi,rooms:0}


 On Friday, 19 June 2015 02:24:27 UTC+5:30, Nand Kumar Singh wrote:

 How am i trying till now .

 @RequestMapping(value = /rest/hotel, method = RequestMethod.GET)
 @Produces(application/json)
 @Consumes(application/json)
 public @ResponseBody ListHotelBO search(JSONObject inputJsonObj) throws 
 ParseException, IOException {

 Gson gson = new Gson();
 GsonBuilder builder = new GsonBuilder();
 Search vc = gson.fromJson(inputJsonObj.toString(), Search.class);
   *}*


 *but its not working any idea ?*

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




-- 

*Ankit Agarwal*
*Software Engineer*
*Seller **Platform*
*Flipkart Internet Pvt. Ltd.*
*Ph. No. +91-8095470278*

-- 
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] Job openings in Limetray

2015-02-12 Thread Ankit Agarwal
Hey there,
Limetray has a lot of openings in its Delhi office. Following is the list
of current positions. If anything interests you, please send your resume to
h...@hyring.com with the position you want to apply for as subject.For
example: LeadMobile@limetray in case you want to apply for Lead Mobile.
Likewise for others.
Do share along.
Position:Mobile Developer: 7-14LPAFront end Developer: 7-14LPABackend
Developer: 7-14LPAJava Developer: 7-14LPALead Mobile: 14-20 LPA Lead Front
End: 14-20 LPALead Backend(PHP): 14-20 LPALead Java: 14-20 LPAVP
Engineering: upto 35LPAProduct Manager: upto 25 LPA
Experience:Developer positions: 1-3 years experienceLead position: Atleast
3+ years experience in relevant field.VP Engineering: Atleast 6-7+ years of
experience in building world class products.Product Manager: 3-6 years of
relevant experience
About Limetray:Limetray is a young product focused start-up which provides
web-presence and online marketing solutions to FB businesses. The founding
team consists of ISB, NSIT alumni  has strong-domain knowledge having
built the biggest online food ordering portal in the past. LimeTray counts
very successful internet entrepreneurs as its angel investors  advisors.
Limetra has recently raised funds from Matrix Partners, a 2.4 billion
dollar global Venture Capital firm.Know more about limetray at
http://www.angel.co/limetray

-- 
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] Re: Highest reminder

2013-05-30 Thread Ankit Agarwal
Hi,

23 = 11 X 1 + 12. Thus 12  would the highest remainder. Not 11



On Thu, May 30, 2013 at 10:24 AM, Sreenivas Sigharam sighar...@gmail.comwrote:

 Dave's explanation was clear..and informative.. Thank you Dave..

 Thank you , Soumya Prasad, for a simple but nice topic..

 Thank you,
 Sigharam.


 On Thu, May 30, 2013 at 10:16 AM, Sanjay Rajpal sanjay.raj...@live.inwrote:

 Hi Ankit,

 for 23, how can the remainder be 12 ? Can you elaborate more ?

 *Regards,*
 *Sanjay Kumar*
 *Software Engineer(Development)*
 *Winshuttle Softwares(India) Pvt. Ltd.*
 *Mobile +91-89012-36292, +91-80535-66286*
 *Email: sanjay.ku...@winshuttle.com*
 *
 ***

 * *

 **
 *
 *


 On Thu, May 30, 2013 at 9:40 AM, Ankit Agarwal ankuagarw...@gmail.comwrote:

 @Dave:

 For N = 23, the highest remainder is 12, not 11


 On Thu, May 30, 2013 at 5:02 AM, Dave dave_and_da...@juno.com wrote:

 The highest remainder when dividing n by a number less than n is
 floor((n-1)/2).
 For n = 11, floor((11-1)/2) = floor(10/2) = floor(5) = 5.
 For n = 17, floor((17-1)/2) = 8
 For n = 23, floor((23-1)/2) = 11

 For n = 12, floor((12-1)/2) = floor(11/2) = floor(5.5) = 5.
 Etc.

 Dave


 On Wednesday, May 29, 2013 1:36:13 PM UTC-5, Ankit wrote:

 Hi,

 Number 23: =  11 * 1 + 12   Number/2 = 11.5

 Number 17: = 9 * 1 + 8   Number/2 = 8.5

 So, its neither floor(n/2) +- 1, nor ceil(n/2) +- 1


 On Wed, May 29, 2013 at 2:19 PM, Ankit Sambyal 
 ankitsam...@gmail.comwrote:

 Hi Nikhil,

 Highest remainder can't be floor(n/2) - 1.
 If n = 11, highest remainder would be 5 when it is divided by 6, but
 your formula gives 4.



 On Mon, May 27, 2013 at 8:16 PM, Nikhil Kumar niksin...@gmail.comwrote:

 Since we need to divide so the quotient should be at least 1, and we
 need greatest remainder, so we need the least no. which will give the
 quotient 1 upon dividing and that would be the no. you described.
 Also you would have noted the greatest remainder would be
  floor(n/2)-1 .


 On Thursday, 16 May 2013 13:56:40 UTC+5:30, Soumya Prasad Ukil wrote:


 For a given number when divided by a number between 1 and n. I
 figured out that highest reminder can be got if I divide the number by
 (⌊(n/2)⌋+1) .Can anyone give me pointers ?

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




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






 --

 *Ankit Agarwal*


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






 --

 *Ankit Agarwal*
 *Software Engineer*
 *Datacenter  Cloud Division*
 *Citrix RD India Pvt. Ltd.*
 *Ph. No. +91-8095470278*

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




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




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






-- 

*Ankit Agarwal*

-- 
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] Re: Highest reminder

2013-05-29 Thread Ankit Agarwal
Hi,

Number 23: =  11 * 1 + 12   Number/2 = 11.5

Number 17: = 9 * 1 + 8   Number/2 = 8.5

So, its neither floor(n/2) +- 1, nor ceil(n/2) +- 1


On Wed, May 29, 2013 at 2:19 PM, Ankit Sambyal
ankitsambyal1...@gmail.comwrote:

 Hi Nikhil,

 Highest remainder can't be floor(n/2) - 1.
 If n = 11, highest remainder would be 5 when it is divided by 6, but your
 formula gives 4.



 On Mon, May 27, 2013 at 8:16 PM, Nikhil Kumar niksingha...@gmail.comwrote:

 Since we need to divide so the quotient should be at least 1, and we need
 greatest remainder, so we need the least no. which will give the quotient 1
 upon dividing and that would be the no. you described.
 Also you would have noted the greatest remainder would be  floor(n/2)-1 .


 On Thursday, 16 May 2013 13:56:40 UTC+5:30, Soumya Prasad Ukil wrote:


 For a given number when divided by a number between 1 and n. I figured
 out that highest reminder can be got if I divide the number by (⌊(n/2)⌋+
 1) .Can anyone give me pointers ?

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






-- 

*Ankit Agarwal*

-- 
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] Re: Highest reminder

2013-05-29 Thread Ankit Agarwal
@Dave:

For N = 23, the highest remainder is 12, not 11


On Thu, May 30, 2013 at 5:02 AM, Dave dave_and_da...@juno.com wrote:

 The highest remainder when dividing n by a number less than n is
 floor((n-1)/2).
 For n = 11, floor((11-1)/2) = floor(10/2) = floor(5) = 5.
 For n = 17, floor((17-1)/2) = 8
 For n = 23, floor((23-1)/2) = 11

 For n = 12, floor((12-1)/2) = floor(11/2) = floor(5.5) = 5.
 Etc.

 Dave


 On Wednesday, May 29, 2013 1:36:13 PM UTC-5, Ankit wrote:

 Hi,

 Number 23: =  11 * 1 + 12   Number/2 = 11.5

 Number 17: = 9 * 1 + 8   Number/2 = 8.5

 So, its neither floor(n/2) +- 1, nor ceil(n/2) +- 1


 On Wed, May 29, 2013 at 2:19 PM, Ankit Sambyal ankitsam...@gmail.comwrote:

 Hi Nikhil,

 Highest remainder can't be floor(n/2) - 1.
 If n = 11, highest remainder would be 5 when it is divided by 6, but
 your formula gives 4.



 On Mon, May 27, 2013 at 8:16 PM, Nikhil Kumar niksin...@gmail.comwrote:

 Since we need to divide so the quotient should be at least 1, and we
 need greatest remainder, so we need the least no. which will give the
 quotient 1 upon dividing and that would be the no. you described.
 Also you would have noted the greatest remainder would be  floor(n/2)-1
 .


 On Thursday, 16 May 2013 13:56:40 UTC+5:30, Soumya Prasad Ukil wrote:


 For a given number when divided by a number between 1 and n. I figured
 out that highest reminder can be got if I divide the number by (⌊(n/2)
 ⌋+1) .Can anyone give me pointers ?

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




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






 --

 *Ankit Agarwal*


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






-- 

*Ankit Agarwal*
*Software Engineer*
*Datacenter  Cloud Division*
*Citrix RD India Pvt. Ltd.*
*Ph. No. +91-8095470278*

-- 
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] inplace merge of 2 sorted parts of an array

2013-05-26 Thread Ankit Agarwal
The first pass is not necessary. We can finding the middle element as
follows:

N = even,  Range [ 0 - (N/2 - 1) ]  [ N/2 - (N - 1) ]

N = odd,
  if (A[N/2]  A[N/2 -1])  Range [ 0 - N/2 ]  [ (N/2 + 1) - (N
- 1) ]

 else if ( A[N/2]  A[N/2 + 1]) Range [ 0 - (N/2 - 1) ]  [ N/2
- (N - 1) ]





On Sun, May 26, 2013 at 8:28 PM, Nishant Pandey 
nishant.bits.me...@gmail.com wrote:

 The solution could be given in this way.

 1) In one pass get the end index of both array says e1 and e2.
 2) now in next pass compare elements at e1 and e2 .
a) if a(e1)  a(e2) swap the elements and then decreament e1 and e2
 both.
b) if a(e1)  a(e2) decreament e2.
c) if a(e1) == a(e2) then swap a(e1) with a(e2-1) and then decrement e1
 by1 and e2 by 2.

 After this pass there may be one or two element not at coret position, so
 their position can be placed just by shifting in elements in another pass.

 So as a total it would be O(n) but it requires 3 passes.


 If some one is having something better tan this, please suggest.



 On Sun, May 26, 2013 at 6:46 PM, bharat b bagana.bharatku...@gmail.comwrote:

 An array is given, first and second half are sorted .. Make the array
 sorted inplace... Need an algo better than O(n^2)..
 If the length of the array is odd.. middle is either in first half or
 second half.
 Ex:
 1. Arr[] = {2,3,6,8,-5,-2,3,8} -- output : Arr[]={-5,-2,2,3,3,6,8,8};
 2. Arr[] = {2,3,6,8,-5,-2,3} --  output : Arr[]={-5,-2,2,3,3,6,8};
 3. Arr[] ={2,3,6,-5,-2,3,8} --  output : Arr[]={-5,-2,2,3,3,6,8};

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






-- 

*Ankit Agarwal*

-- 
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] Re: Binary tree to BST

2011-11-05 Thread ankit agarwal
I think it's the only way as you need to traverse the entire binary
tree to do it.

On Oct 31, 9:45 pm, Ankuj Gupta ankuj2...@gmail.com wrote:
 How to convert a Binary tree to BST ? Naive way is to create each node
 of  Binary tree one by one and keep on creating the BST.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Median of 2D matrix

2011-11-04 Thread ankit agarwal
Hi,

I think the median will always lie on the diagonal
a[n][1]  a[1][n]
because the elements on the LHS making the upper triangle will
always be less than or equal to the elements on the diagonal
and the RHS, elements in the lower triangle will be greater than or
equal to them.

so sort the diagonal and find the middle element, that will be the
median.

Thanks
Ankit Agarwal

On Nov 5, 1:29 am, Gene gene.ress...@gmail.com wrote:
 Here's an idea.  Say we pick any element P in the 2D array A and use
 it to fill in an N element array X as follows.

 j = N;
 for i = 1 to N do
   while A(i, j)  P do
      j = j - 1;
   end;
   X(i) = j;
 end;

 This algorithm needs O(N) time.

 The elements of X split each row with respect to P. That is, for each
 i = 1 to N,

   A(i, j) = P if 0  j = X(i),    A(i,j)  P if X(i)  j = N.

 Now the strategy is to create two length N arrays a = [0,0,...0]; and
 b = [N,N,...]. We'll maintain the invariant that a[i]  Median = b[i]
 for some i.  I.e, they bracket the median.

 We define functions L(a) = sum_i( a(i) ) and R(b) = sum_i( N -
 b(i) ).  These tell us how many elements there are left and right of
 the bracket.

 Now reduce the bracket as in binary search:  Guess a value P, compute
 X.  If L(X) = R(X), set b = X else set a = X.

 Keep guessing new P values in a way that ensures we reduce the number
 of elements between a and b by some fixed fraction.  If we can do
 that, we'll get to 1 element in O(N log N) time.

 The remaining problem is picking good P's. Certainly the first time is
 easy. Just take A(N/2, N/2). This has approximately (at least) N^2/4
 elements larger than it and N^2/4 smaller due to the sorted rows and
 columns.  This is what we need to get O(N log N) performance.

 But after the first split, things get trickier. The area between a and
 b takes on the shape of a slash / /, so you can't just pick a P that
 moves a and b together by a fixed fraction of remaining elements.

 Not to worry!  You can quickly look up the (at most) N row medians in
 the bracket, i.e.

   { A(i, (a[i] + b[i] + 1) / 2) | a[i]b[i] , i = 1 to N }

 and use the well known O(N) median selection algorithm to get a median
 of this. This has the quality we want of being somewhere roughly in
 the middle half of the remaining elements. The logic is the same as
 the selection algorithm itself, but in our case the rows are pre-
 sorted.

 In all, each partitioning step requires O(N), and a fixed fraction
 (about 1/2) of the elements will be eliminated from the bracket with
 each step. Thus O(log n) steps will be needed to bring the bracket to
 size 1 for an overall cost of O(N log N).

 I don't doubt that there's a simpler way, but this one seems to work.
 Anyone see problems?

 On Nov 3, 3:41 pm, sravanreddy001 sravanreddy...@gmail.com wrote:







  any better solution than O(N^2) in worst case?
  How do we take advantage of sorting and find in O(N lg N)

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



Re: [algogeeks] Re: informatica pattern and question of interview

2011-09-14 Thread Ankit Agarwal
2  question

numbers are (a1+1)*a2*a3... an = a1*a2*a3...an + a2*a3...an
the first term is same...
for second term is (a1*a2...an)/(a1)
now we have to find max of ( ((a1*a2..an)/a1),  (a1*a2...an)/a2)
so the question of max becomes min of( a1, a2, a3... an)


-- 
Ankit Agarwal
Computer Science  Engg.
Integrated Dual Degree, V yr
Department of Electronics  Computer Engineering
Indian Institute of Technology Roorkee
Ph. no. +91-9580098805

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Exchanging bit values in a number

2011-09-13 Thread Ankit Agarwal
let x = 2^j + 2 ^i
new number after swapping the digits is x XOR n

eg n =  1101
j = 6 i = 2
x = 0100 0100
 new number = x XOR n = 0100 1001


-- 
Ankit Agarwal
Computer Science  Engg.
Integrated Dual Degree, V yr
Department of Electronics  Computer Engineering
Indian Institute of Technology Roorkee
Ph. no. +91-9580098805

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] String Reverse

2011-08-29 Thread Ankit Agarwal
void function(int start, int end){
if (start  end) return;
int x= a[end]-a[start];
a[start] = a[start] + x;
a[end] = a[end] - x;
function(start+1, end-1);
}

main(){
scanf(%s, a[0]);
int len = strlen(a);
function(0,len-1);
printf(%s\n, a);
}



-- 
Ankit Agarwal
Computer Science  Engg.
Integrated Dual Degree, V yr
Department of Electronics  Computer Engineering
Indian Institute of Technology Roorkee
Ph. no. +91-9580098805

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



Re: [algogeeks] Re: puzzle

2011-06-26 Thread Ankit Agarwal
3

think in binary.. :)


On Mon, Jun 27, 2011 at 12:56 AM, Arpit Sood soodfi...@gmail.com wrote:

 4
 @amit what's the answer ?


 On Mon, Jun 27, 2011 at 12:40 AM, shiv narayan 
 narayan.shiv...@gmail.comwrote:

 can u please explain how is it 3?

 On Jun 26, 11:18 pm, D.N.Vishwakarma@IITR  deok...@gmail.com
 wrote:
  3 mice .
 
  On Sun, Jun 26, 2011 at 6:13 PM, ArPiT BhAtNaGaR 
 
 
 
 
 
 
 
 
 
  arpitbhatnagarm...@gmail.com wrote:
   3
 
   On Mon, Jun 27, 2011 at 2:10 AM, amit the cool 
 amitthecoo...@gmail.comwrote:
 
   There are 6 beer bottle nd one is poisoned. we have mice who will die
   within 14 hrs after drinkin poisned beer. In 24 hrs we have to find
   poisoned beer bottle. How many no of mice we require to find out
   poisoned bottle.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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
 
   Arpit Bhatnagar
   (Computer Engineering)
   (MNIT JAIPUR)
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  **With Regards
  Deoki Nandan Vishwakarma
  IITR MCA
  *
  *

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




 --
 Regards,
 Arpit Sood

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




-- 
Ankit Agarwal
B.Tech. Senior Year
Computer Science  Engineering
IIT Rajasthan

*Be the change that you want to see in the world... :)*
*- Gandhiji*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 code help

2011-06-23 Thread Ankit Agarwal
1) p1[-3] is an invalid address and thereby, it is giving 0.

2) p1[3]='e' having 101 as ASCII value, thus -p1[3]=-101 as integer.

On Thu, Jun 23, 2011 at 5:36 PM, Anika Jain anika.jai...@gmail.com wrote:

 1)
 int main()
 {
 char *p1=cquestionbank;
 printf(%d,p1[-3]);
 return 0;
 }


 why is it giving 0??


 2)
 int main()
 {
 char *p1=cquestionbank;
 printf(%d,-3[p1]);
 return 0;
 }

 why is this giving -101??

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




-- 
Ankit Agarwal

*Be the change that you want to see in the world... :)*
*- Gandhiji*

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



Re: [algogeeks] Re: sort the array

2011-06-22 Thread Ankit Agarwal
This problem can also be done by using Merging function as in the merge
sort.
1. Copy the sorted elements of the first half in one array (arr L) and
second half in another (arr R). Original array N.
2. count vary from 1 to n.

if (L[i]  R[j] ) { N[count] = L[i], i++}
   else { N[count] = R[j] , j++}
   count++

3. copy the rest of the elements from the remaining (either L or R whichever
is remaining)

Time complexity  O(n)

Plz correct me if I m wrong.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] C Output

2011-05-29 Thread Ankit Agarwal
#includestdio.h

int main(void)
{
float a=0.08;
if(a0.08)
printf(Hello\n);
else
printf(Hii\n);
return 0;
}

The o/p is: *Hello *   why

-- 
Ankit Agarwal

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



Re: [algogeeks] C Output

2011-05-29 Thread Ankit Agarwal
Thank u guys :) :)

On Mon, May 30, 2011 at 10:40 AM, arjoo kumar 2009ar...@gmail.com wrote:

 when u store 0.08 on the float variable a then it does not store exactly
 0.08 on 'a'
 actually it store 0.7999
 that's why after comparition it make less quantity with 0.08
 i.e 'if ' condition is true and print it HELLO

 On Sun, May 29, 2011 at 9:21 AM, Ankit Agarwal ankitgeniu...@gmail.comwrote:

 #includestdio.h

 int main(void)
 {
 float a=0.08;
 if(a0.08)
 printf(Hello\n);
 else
 printf(Hii\n);
 return 0;
 }

 The o/p is: *Hello *   why

 --
 Ankit Agarwal


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 
Ankit Agarwal

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] c program output

2011-02-07 Thread ankit agarwal
#includestdio.h

int main()
{
float a=11.202;
if(a11.202)
printf(Hiii!!!\n);
else
printf(Hello!!!\n);
return 0;
}

output: Hiii!!!

why does this output comes???



Ankit Agarwal

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 program output

2011-02-07 Thread ankit agarwal
But is the bug in the given program



On Mon, Feb 7, 2011 at 8:32 PM, Shalini Sah shalinisah.luv4cod...@gmail.com
 wrote:

 try dis :

 #includestdio.h
 int main()
 {
 float a=11.202;
 if((a-11.202)==0)

 printf(Hiii!!!\n);
 else
 printf(Hello!!!\n);
 return 0;
 }
 you will get :
 Hello!!!

 On Mon, Feb 7, 2011 at 8:22 PM, ankit agarwal ankitgeniu...@gmail.comwrote:

 #includestdio.h

 int main()
 {
 float a=11.202;
 if(a11.202)
 printf(Hiii!!!\n);
 else
 printf(Hello!!!\n);
 return 0;
 }

 output: Hiii!!!

 why does this output comes???



 Ankit Agarwal


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 
Ankit Agarwal
B.Tech. 3rd Year
Computer Science  Engineering
IIT Rajasthan

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: c program output

2011-02-07 Thread ankit agarwal
Thanq ol...

On Mon, Feb 7, 2011 at 8:56 PM, Dave dave_and_da...@juno.com wrote:

 @Ankit: Yes. The bug is that the constant in the comparison should
 have been written 11.202e0.

 Dave

 On Feb 7, 9:05 am, ankit agarwal ankitgeniu...@gmail.com wrote:
  But is the bug in the given program
 
  On Mon, Feb 7, 2011 at 8:32 PM, Shalini Sah 
 shalinisah.luv4cod...@gmail.com
 
 
 
 
 
   wrote:
   try dis :
 
   #includestdio.h
   int main()
   {
   float a=11.202;
   if((a-11.202)==0)
 
   printf(Hiii!!!\n);
   else
   printf(Hello!!!\n);
   return 0;
   }
   you will get :
   Hello!!!
 
   On Mon, Feb 7, 2011 at 8:22 PM, ankit agarwal ankitgeniu...@gmail.com
 wrote:
 
   #includestdio.h
 
   int main()
   {
   float a=11.202;
   if(a11.202)
   printf(Hiii!!!\n);
   else
   printf(Hello!!!\n);
   return 0;
   }
 
   output: Hiii!!!
 
   why does this output comes???
 
   Ankit Agarwal
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.
 
  --
  Ankit Agarwal
  B.Tech. 3rd Year
  Computer Science  Engineering
  IIT Rajasthan- 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.




-- 
Ankit Agarwal
B.Tech. 3rd Year
Computer Science  Engineering
IIT Rajasthan

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-01-27 Thread ankit agarwal
(9*9-1)/(9-1)

On Thu, Jan 27, 2011 at 4:55 PM, nishaanth nishaant...@gmail.com wrote:

 (91-1)/9


 On Wed, Jan 26, 2011 at 11:07 PM, Apoorve Mohan apoorvemo...@gmail.comwrote:

 9 + 1 - ( 1 / 9 )


 On Wed, Jan 26, 2011 at 10:29 PM, satish satish@gmail.com wrote:

 19-(9/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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 regards

 Apoorve Mohan


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




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




-- 
Ankit Agarwal
B.Tech. 3rd Year
Computer Science  Engineering
IIT Rajasthan

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: twin pair

2011-01-11 Thread ankit agarwal
as all prime no. greater than 3 are of the form 6n+1 or 6n-1
so start checking for all these numbers and if they both are prime
then they will make pair
count the pair no. as well as u move on

Ankit

On Jan 11, 9:23 pm, snehal jain learner@gmail.com wrote:
 you will be given an input no. n u have to output nth twin pair..
 for eg input 1 output(3,5)
 input 5 output (29,31)

 twin pair is a pair in which prime no. differ by 2.. (3,5) , (5,7)
 (11,13), (17,19) (29,31)

-- 
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: amazon questions

2011-01-11 Thread ankit agarwal
it is (p(a)p(b)+p(b)p(c)+p(c)p(a))/3

On Jan 12, 1:51 am, SVIX saivivekh.swaminat...@gmail.com wrote:
 anuragh

 assume each can shoot the target everytime...
 P(A) = 1
 P(B) = 1
 P(C) = 1

 per your logic, the probability that the target will be hit is 3
 actually, it should have only been 2 as we're going to pick only 2
 people out of 3 to shoot...

 I think you should factor in the probability that A or B or C will be
 picked...
 There are 3C2 ways to pick 2 cards out of 3... Since its purely
 random, each card has 2/3rd chance that it's picked...

 so if you factor in the probability, the answer is

 required probablilty = P(A) * 2/3  + P(B) * 2/3 + P(C) * 2/3

 On Jan 11, 12:06 pm, anurag.singh anurag.x.si...@gmail.com wrote:







  For 2nd question (probability): Looks like one data is missing for C.
  If I assume C can shoot 8 out of 10. times then:

  P(A) = 4/5
  P(B)=6/7
  P(C)=8/10

  Required Probability should be = P(A) * P(B) + P(B) * P(C) + P(A) *
  P(C)

  On Jan 11, 9:58 pm, snehal jain learner@gmail.com wrote:

   1. what is valid in cpp
   char *cp;
   const char* cpp;
   1. cpp=cp 2. cp=cpp

   2 there r 3 ppl A B C
   A can shoot the target 4 out of 5 times B can shoot 6 out of 7 times
   and C can shoot 8 out of  times. 2 people r selected at random. then
   wat is the probability of hitting the target?

-- 
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 would you find the integer pairs which sum to m in o(n) time complexity

2010-11-17 Thread ankit agarwal
@mohit,ruturaj

We dont need to know the range only if there are +ve no's.
and then also we need only m/2 space.
if(a[i]m)
skip
else
  if(a[i]m/2)
if(hash[m-a[i]]==1))
  return true;
else
  hash[m-a[i]]++;
  else
if(hash[a[i]]==1))
  return true;
else
  hash[a[i]]++;

but we need to know the range if there are -ve numbers as well.

we need hashtable

On Nov 12, 3:29 am, Ruturaj rutura...@gmail.com wrote:
 On Oct 27, 8:21 am, MOHIT  mohit...@gmail.com wrote: @ruturaj : but 
 for that hash table you have to know range??

 Nope we dont need the range.

 #includemap

 map int, int hash;

 for(int i=0;in;i++)
 if(hash[m-a[i]]  0)count++;hash[a[i]]++;

 does the trick.

-- 
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: Binary Tree

2010-10-23 Thread ankit agarwal
Do level order traversal using two queues.


On Oct 23, 8:19 pm, juver++ avpostni...@gmail.com wrote:
 When visiting appropriate vertex v, increment counter +
 +levels[current_depth] and go further.
 You may done this using DFS or BFS.

 On 23 окт, 17:31, Harshal hc4...@gmail.com wrote:







  hi, i need to find the number of nodes at each level of a binary tree..the
  binary tree may not be balanced..

  output:
  Level 0 - 1 node
  Level 1 - 2 nodes
  Level 2-  3 nodes

  and so on..based on the tree structure..I am not able to count at each
  level..pls suggest a way to do that.

  --
  Harshal Choudhary

-- 
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: regarding output

2010-10-11 Thread ankit agarwal
when you press enter after entering a character.
scanf reads the character first time from the input buffer and the
next time it reads only enter from input buffer.
Solution to the problem is using fflush(stdin) after scanf command.

On Oct 12, 2:25 am, carry pawan1991ya...@gmail.com wrote:
 int main()
 {
 int i;
 char c;
 for(i=0;i5;i++)
 {
 scanf(%d,c);
 printf(%d,c);}
 }

 why the program scans only one time if u give an alphabet as an
 input??

-- 
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: arranging blocks

2010-10-11 Thread ankit agarwal
case 1: L+R=N+1
arrange Nth bloack at L position and from N-1 to N-L on its left in
decreasing order.
N-L-1 to 1
on its right in decreasing order.

eg 3 4 5 6 2 1
for n=6
 l=4
 r=3

L+RN+1
proceed as above
then place the remaining block between any two blocks.As the remaining
block will be shorter
than any all those that have already been placed they will never be
visible.

eg;
n=6
l=2
r=2

1)   5 6 4
place the remaining in between any two.
2)   5 3 2 1 6 4
here 3 2 1  will always be hidden

Ankit











On Oct 6, 4:04 pm, snehal jain learner@gmail.com wrote:
 You are given N blocks of height 1…N. In how many ways can you arrange
 these blocks in a row such that when viewed from left you see only L
 blocks (rest are hidden by taller blocks) and when seen from right you
 see only R blocks?

 Examples:
  1)For N=3, L=2, R=1 there is only one arrangement {2, 1, 3}.
  2)For N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}

-- 
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: Smallest window of K[] in N[]. Best order solution

2010-10-10 Thread ankit agarwal
Your Solution considers only those windows which contain continuous
elements of query array in input array.
It won't work for:
i/p array : 12345
query array: 1235

also it won't work for:
i/p array: 2
query array: 1112

Ankit Agarwal





On Oct 10, 9:04 pm, Mridul Malpani malpanimri...@gmail.com wrote:
 it can be solved in O(n).

 let query array be b[k] and array of int is a[n],

 int j=i=0, s=-1;
 for(i=0;in;i++)
 {
           if(a[i]==b[j])
           {
                j++;
                if(j==1)
                     s=i;
           }
           else
           {
               j=0;
               s=-1;
           }
           if(j==k)
              break;}

 if( i=n  j==k)
      printf(Found starting index=%d,s);
 else
      printf(NOt found);
  return 0;

 }

 On Oct 7, 1:20 pm, RAHUL KUJUR kujurismonu2...@gmail.com wrote:



  @prodigy: how is it coming O(nlogk) can u explain???

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