[algogeeks] Max difference of Monotonic Pair in An Array

2014-04-18 Thread Tushar Kanta Rath
Hi All,

Can anyone help me solving this problem ?

Given a non-empty array A consisting of N integers.

Find Max(j-i), s.t 0=i=jN  and A[i]=A[j]

Here (i, j) is a Monotonic Pair, satisfying the above condition.

Space Complexity : O(n)  Time Complexity: O(n)

-- 
Regards...

-- 
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] least common ancestore bst

2013-04-26 Thread Tushar Patil
@rahul : It's fine solution, but can we check  the root-data == n1 || n2
before calling function recursively, I think if we check this condition 1st
it will reduce unnecessary function calls.
  Correct me if i am wrong?
Thanks,
Tushar Patil.



On Sun, Apr 21, 2013 at 10:26 PM, rahul sharma rahul23111...@gmail.comwrote:

 int leastCommanAncestor(struct node* root, int n1, int n2)
 {
  if(root==NULL)
  return -1;
  if(root-datan1  root-datan2)
  return leastCommanAncestor(root-left,n1,n2);
  else if(root-datan1  root-datan2)
  return leastCommanAncestor(root-right,n1,n2);
  return root-data;

 }

 Does this code miss any case?N suppose if we have to find LCA of n1 and n2
 and suppose n1 is parent of n2 ..then this will return n1..is this fyn or
 if n1 is parent of n2 then we should return -1??

 Plz. comment

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




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




[algogeeks] Re: Amazon Interview Questions

2013-02-17 Thread Tushar
It looks as if you have just pasted some Amazon interview questions on this 
forum.
These are pretty common questions. 
Try to come up with your own answers.
Do some research on google and previous posts on this forum. You'll get 
answers to all of them.

If you have some idea and want to discuss that, then post different posts 
for each questions as arun recommended along with your understanding of the 
question and your approach.

All the best

On Saturday, 9 February 2013 14:45:35 UTC+5:30, Pratik Mehta wrote:

 Hi All,
 I need ur help in solving few questions.

 Would you please help me out *BY GIVING THE ALGORITHM AND THE LOGIC 
 BEHIND IT and it's DEEP EXPLANATION IF POSSIBLE?*


 *
 *

 *a. Kadane’s Algo.*

 *
 *

 *b. Linked-list intersection point.*

 *
 [A tree with only parent pointer, how to find LCA?]
 *

 *

 *

 *
 c. Design a stack which can perform findMax in O(1).
 *

 *

 *

 *d. Set of stocks for each day have been given. Need to find the days on 
 which I buy and sell share to earn max profit, alongwith finding the max 
 profit.*


 *
 e. Find top k searched elements from a continuous stream of data.
 *

 *

 *

 *f. Given a linked-list and 2 integers k  m. Reverse the linked-list 
 till k elements and then traverse till m elements and repeat.*

 *Write production quality code.*

 *
 *

 *g. An array of elements have been given. Find for each element, first 
 max element to its right.*

 *
 *

 *h. Boundary traversal of a tree. Write the code.*


 Please help me out...

 Thanks in advance...

 Thanks  Regards,
 Pratik Mayur Mehta.


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




Re: [algogeeks] help to give DP solution

2012-09-17 Thread Tushar
www.ams.jhu.edu/~castello/362/Handouts/*hungarian*.pdf
This PDF  might be helpful


On Sunday, 16 September 2012 16:42:25 UTC+5:30, Rahul Kumar Patle wrote:

 @atul: in Hungarian Algorithms works for minimization of cost where the 
 terminating condition is based on zeros.. in my problem what value i will 
 have to consider as base/terminating values because there may not be same 
 values in coloumn and rows..
 second thing you use subtraction there, here will i have to use 
 addition..??
 please clarify..
 i have seen following link:
 http://s-mat-pcs.oulu.fi/~mpa/matreng/eem1_2-1.htm
 if you have link which explains maximization problem..
 please post here..

 On Sun, Sep 16, 2012 at 12:44 AM, atul anand atul.8...@gmail.comjavascript:
  wrote:

 correct me if i am wrong ,
 it seems similar to Hungarian algorithm.
 here each column can be considered as persons P(p0,p1,p2,..pn) and each 
 as cost of job say X(x0,x1,x2,x3,x4xn).
  Hungarian algorithm tells how to find minimal but here its maximal...so 
 i guess changes in the algo will give the outputl

 On Sat, Sep 15, 2012 at 9:10 PM, Rahul Kumar Patle 
 patlera...@gmail.comjavascript:
  wrote:

 A 2D array of order A[N][N] is given, considering entry A[i][i] as 
 invalid you have to select one element from each row such that
 1. Selected elements does not belong to same column.
 2. Sum of selected element has maximal.


 -- 
 Thanks and Regards:
 Rahul Kumar 
 Patlehttp://www.linkedin.com/profile/view?id=106245716trk=tab_pro
 M.Tech, School of Information Technology
 Indian Institute of Technology, Kharagpur-721302, 
 Indiahttp://www.iitkgp.ac.in/
 Mobile No: +91-8798049298, +91-9424738542
 Alternate Email: rahulku...@hotmail.com javascript:

  -- 
 You received this message because you are subscribed to the Google 
 Groups Algorithm Geeks group.
 To post to this group, send email to algo...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 algogeeks+...@googlegroups.com javascript:.
 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 algo...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 algogeeks+...@googlegroups.com javascript:.
 For more options, visit this group at 
 http://groups.google.com/group/algogeeks?hl=en.




 -- 
 Thanks and Regards:
 Rahul Kumar 
 Patlehttp://www.linkedin.com/profile/view?id=106245716trk=tab_pro
 M.Tech, School of Information Technology
 Indian Institute of Technology, Kharagpur-721302, 
 Indiahttp://www.iitkgp.ac.in/
 Mobile No: +91-8798049298, +91-9424738542
 Alternate Email: rahulku...@hotmail.com javascript:



-- 
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/-/p2mOfKSQbrUJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Matrix Searching

2012-09-16 Thread Tushar
For a large list of words,
At each location, look 
for the character before/after that character in the word on opposite 
sides of the initial location, and continue from there

Is it like:
frequency count of 'a' is smallest

'a' is in 2 words available and alpha

shall we check for 'v' near 'a'; if found then look for the complete word
OR
look for 'v' and 'i' on both sides of 'a'; if found then search for 
remaining characters in both directions
OR
look for 'l' and 'b' on both sides of 'a'; if found then search for 
remaining characters in both directions
OR
look for 'l' 'a'; if found then search for remaining characters in that 
direction
OR
look for 'h' 'a'; if found then search for remaining characters in that 
direction

Is this what we should be doing?

On Saturday, 15 September 2012 01:43:14 UTC+5:30, Don wrote:

 I had to do something like this with a large list of words to search 
 for. If you're just looking for one word, look for the first letter, 
 and when you find it, look at adjacent locations for the second 
 letter. If found, continue in that direction matching letters until 
 you either match the whole word or don't. 

 But for a big list of words to search for, it was faster to do 
 something like this: 
 Build a frequency count for each character, along with a list of 
 ordered pairs indicating where that character is located. Then, to 
 look for a word, find the character with the smallest frequency count 
 and step through the list for that character. At each location, look 
 for the character before/after that character in the word on opposite 
 sides of the initial location, and continue from there. 

 Don 

 On Sep 14, 2:47 pm, Arun Kindra reserve4placem...@gmail.com wrote: 
  *You have given any n*n matrix in which characters are stored and you 
 have 
  to search that a given word is present or not.(words can be 
 horizontally, 
  vertically, diagonally)* 


-- 
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/-/tKJcCEYJsjAJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 to give DP solution

2012-09-16 Thread Tushar
we can assign minimum possible value, like negative infinity to the 
diagonal elements.
Then they would not be considered for maximizing the sum.

-- 
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/-/iQtl7QGJBFwJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] array problem

2012-09-16 Thread Tushar
@srikanth
we can use segment trees to get sum of an interval
but there is another condition of sum of distinct numbers only. how can we 
take that into account in a segment tree?

On Thursday, 6 September 2012 17:35:59 UTC+5:30, srikanth reddy malipatel 
wrote:

 post the logic not the code!
 BTW this  problem can be done using segment trees.


 http://community.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor
  

 On Thu, Sep 6, 2012 at 4:51 PM, bharat b bagana.bh...@gmail.comjavascript:
  wrote:

 Its better to write an O(n) solution for this problem as the # test cases 
 are very high and #elements are also very huge..
 use visited array for distinct numbers ... space--O(n).. time--O(n)


  On Sat, Aug 25, 2012 at 2:39 AM, michael miller 
 wentworth@gmail.comjavascript:
  wrote:

 Hi,
 You are given N numbers. You have to perform two kinds of operations:
 U x y - x-th number becomes equal to y.
 Q x y - calculate the sum of distinct numbers from x-th to y-th. It 
 means that the sum for the set {1, 2, 3, 2, 7} will be equal to 13 
 (1+2+3+7).

 1=N=5 and 
 t is the number of test cases where   1=t=10

 all numbers fit in the 32 bit integer range...

 suggest some solution..

 here is my solution
 but it is giving wrong answer fo some unknown test case...plz suggest me 
 the test case where i am getting wrong answer


 #includestdio.h
 #includemath.h
 int main()
 {
 int list[5],i,n,j,sum,k,l;char c;long t;
 scanf 
 http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html(%d,n);
 for(i=0;in;i++)
 {
 scanf 
 http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html(%d,list[i]);


 }
 scanf 
 http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html(%ld,t);


 t=2*t;
 while(t)
 {
 sum=0;
 scanf 
 http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html(%c,c);


 fflush(stdin);
 scanf 
 http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html(%d
 %d,k,l);   


 if(c=='Q')
 {
 for(i=k-1;il-1;i++)
 {
 for(j=i+1;jl;j++)
 {
if(list[i]==list[j])
   break;
else if((j==l-1) (list[i]!=list[j]))


{
   sum=sum+list[i];

}
 }
  }

  printf 
 http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(%d\n,sum+list[l-1]);


  }
  if(c=='U')
  {
  list[k-1]=l;

  }
  t--;
 }
 return 0;   
 }



  -- 
 You received this message because you are subscribed to the Google 
 Groups Algorithm Geeks group.
 To post to this group, send email to algo...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 algogeeks+...@googlegroups.com javascript:.
 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 algo...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 algogeeks+...@googlegroups.com javascript:.
 For more options, visit this group at 
 http://groups.google.com/group/algogeeks?hl=en.




 -- 
 Srikanth Reddy M
 (M.Sc Tech.) Information Systems
 BITS-PILANI

  

-- 
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/-/tBX6PSU32EkJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Programming Problem

2012-07-25 Thread Tushar
i think we cannot change the order of the characters

On Thursday, 19 July 2012 11:00:20 UTC+5:30, gobind hemb wrote:

 String s is called *unique* if all the characters of s are different.

 String s2 is *producible* from string s1, if we can remove some 
 characters of s1 to obtain s2.

 String s1 is *more beautiful* than string s2 if length of s1 is more than 
 length of s2 or they have equal length and s1 is lexicographically greater 
 than s2.

 Given a string s you have to find the *most beautiful unique* string that 
 is producible from s.

 *Input:*

 First line of input comes a string s having no more than 1,000,000(10^6) 
 characters. all the characters of s are lowercase english letters.

 *Output:*

 Print the most beautiful unique string that is producable from s

 *Sample Input:*

 babab 

 *Sample Output:*

 ba

 *Explanation*

 In the above test case all unique strings that are producible from s are 
 ab and ba and ba is more beautiful than ab.


-- 
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/-/xq8pHByKW9kJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 support engineer

2012-07-24 Thread Tushar
this is interview street
post here freely

all the best


On Monday, 23 July 2012 19:40:12 UTC+5:30, rahul sharma wrote:

 Guys i am having amazon support engg. test tonyt...90 min 27 questions 
 mcq...plz tell how to prepare and wats dis profyl???reply asap..and sory 
 for posting it in algogeeks as i need quick response.waiting for +ve 
 response soon...
 thnx


-- 
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/-/qytHyFXxaSsJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Appropriate data structure

2012-07-16 Thread Tushar
can you please elaborate on usage of stack to do it in 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/-/8jTvBVdzsmYJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 solve

2012-04-12 Thread Tushar
2
3
1 1 1
5
1 2 3 1 2

O/P should be:
0
6

Your O/P is
3
9


-- 
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/-/4pcRBMXAvXQJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Array Problem

2012-02-15 Thread TUSHAR
@amrit,@Pranav and others  :  Thanks a lot..



On Feb 15, 11:35 am, amrit harry dabbcomput...@gmail.com wrote:
 @tushar
 lower bound for sorting an array is 
 nlogn.http://www.bowdoin.edu/~ltoma/teaching/cs231/fall11/Lectures/6-moreso...

 On Wed, Feb 15, 2012 at 11:16 AM, TUSHAR tusharkanta.r...@gmail.com wrote:
  That means,,,we have to sort the array first in O(n).
  Is there any way to sort the array inplace in O(n) ?

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

 --
 AMRIT

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

2012-02-14 Thread TUSHAR
Given an array of size N having numbers in the range 0 to k where
k=N, preprocess the array inplace and in linear time in such a way
that after preprocessing you should be able to return count of the
input element in O(1).

Please give some idea !!
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.



[algogeeks] Re: Array Problem

2012-02-14 Thread TUSHAR
That means,,,we have to sort the array first in O(n).
Is there any way to sort the array inplace in O(n) ?

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



[algogeeks] plz help...

2011-09-14 Thread Tushar Kanta Rath
hello,

i want a good reference in web designing.can anyone plzz help me
with some good links, for reference..

plzz its urgent

Thanks in Advance

-- 
Tushar Kanta Rath,
Master In Computer Application
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.



Re: [algogeeks] apti

2011-08-21 Thread Tushar Bindal
if the cyclist would have left on time, then in those 20 minutes, he would
have covered 4miles at a speed of 12miles/h
so he would have been 1 mile before station whereas train would have been 5
miles before as it is on its normal time, so no change in its position.
then, when the cyclist covers that 1 mile, the train covers 5 miles so that
both of them meet at the station.
thus, speed of the train = 5*speed of cyclist = 60 miles/hour

On Sun, Aug 21, 2011 at 12:19 PM, prasanth n nprasnt...@gmail.com wrote:

 @gupta:

 can you explain your answer?


 On Sun, Aug 21, 2011 at 1:50 AM, D!leep Gupta dileep.smil...@gmail.comwrote:

 60mph

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




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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: GS on campus

2011-08-07 Thread Tushar Bindal
you were not given any essay during the written round?
and if you can get your friends to tell us what kind of puzzles were asked?
just a bit of info on that.

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



Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-06 Thread Tushar Bindal
is it confirmed that the answer is 11/23 only?
bcoz the point that we need a left-right pair only is also valid. if we
consider that case, answer comes out to be 12/23.
since it just says pair, shall we assume that pair means just 2 of same
colour or take a proper pair that consists of one right and one left



On Fri, Aug 5, 2011 at 9:46 AM, sukran dhawan sukrandha...@gmail.comwrote:

 cpp = cp is valid.other one is not valid because the compiler places cp in
 read only memory.so we cannot change its address


 On Fri, Aug 5, 2011 at 12:43 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 dev cpp par chal jaenge ,
 ideone.com par try kar
 cp=cpp nahi chalega . .


 On Fri, Aug 5, 2011 at 12:40 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 i have a doubt regarding 3rd questions..acc to me both are valid...what
 is the correct answer?


 On Fri, Aug 5, 2011 at 12:27 AM, newOne trader.lu...@gmail.com wrote:

 2 issues:
 1. no error handling for malloc failure( can be ignored)
 2. no memset for pq.

 strcat will not work properly: as by definition it will search for the
 null char in first string, removes it then copies the second string
 including the null char of second string.

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




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

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


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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] difference between the two

2011-08-06 Thread Tushar Bindal
that means the order is immaterial.
the sizeof the struct always remains same irrespective of the order and just
depends on the type of variables???
why char with double does not get size in multiples of 8??

On Sat, Aug 6, 2011 at 12:54 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:

 Sorry guys, int is 4 bytes on 64 bit and 2 bytes on 32 bit system..

 But padding rule remains same for both structures as mentioned above...




 On 8/6/11, Puneet Gautam puneet.nsi...@gmail.com wrote:
  There is no difference between the two...
 
  On 32 bit system, both structures need every address location where
  int and pointer are stored to be a multiple of 4(highest size is 4)..
 
  On 64 bit,
  even if pointer is 4bytes(say, in 64 bit system), and p1, p2 be
  structure variables, then p2 should start at address which is multiple
  of 8 as int data is 8bytes. So, if p1 starts at 0, it should end at 16
  not 12 so that p2 starts at 8's multiple.
 
  This is done by padding pointer by 4bytes in both I and II struct.
  declarations.
 
 
  Hope i made it clear...!
 
  Thanks.
 
 
 
 
  On 8/6/11, Tushar Bindal tushicom...@gmail.com wrote:
 
 http://www.serc.iisc.ernet.in/ComputingFacilities/systems/cluster/xlf/html/xlfug/ug35.htm
  this says int is always 4 bytes and pointer is 8 bytes on 64 bit
  compiler.
 
  so how does padding affect these structures because of the difference in
  size of int and pointer?
 
 
  I tried this program
  https://ideone.com/CRU6x#view_edit_box
  char always gets 4 bytes whenever it has int or double in the same
 struct
  irrrespctive of the order of the declaration of variables.
  I thought char should get size 8 when there is a double in the ame
 struct
  whereas it gets size 4 only.
  what is the problem here?
 
  On Sat, Aug 6, 2011 at 4:40 AM, Shashank Jain shashan...@gmail.com
  wrote:
 
  i dont understand the diff btw dem, could u plz elaborate?
 
  Shashank Jain
  IIIrd year
  Computer Engineering
  Delhi College of Engineering
 
 
 
  On Sat, Aug 6, 2011 at 12:32 AM, Kamakshii Aggarwal
  kamakshi...@gmail.com
   wrote:
 
  in case of 64 bit,
  size of second structure will also be 16 not 8
 
 
  On Fri, Aug 5, 2011 at 11:40 PM, UTKARSH SRIVASTAV 
  usrivastav...@gmail.com wrote:
 
  I think voth are just same..
 
 
  On Fri, Aug 5, 2011 at 10:57 AM, priya v pria@gmail.com wrote:
 
  in case of 64 bit machine y doesn't padding happen in the 2nd
  structure?
 
 
  On Fri, Aug 5, 2011 at 11:21 PM, hary rathor
  harry.rat...@gmail.comwrote:
 
  no ,if u r using 32 bit machine . that will use 4 byte pointer size
  ,
  but   in 64 machine that enforce to be size of 8 . where padding
  will
  take int your given first structure
 
  so for 32 bit- size will 8 8 for both structure
  for 64 bit - size will 16 and 12 respectively cause of 4 bit
 padding
  in
  one structure
 
  hence 2nd structure is good for use
 
  --
  You received this message because you are subscribed to the Google
  Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 
 
 
  --
  *UTKARSH SRIVASTAV
  CSE-3
  B-Tech 2nd Year
  @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.
 
 
 
 
  --
  Regards,
  Kamakshi
  kamakshi...@gmail.com
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
   --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Tushar Bindal
  Computer Engineering
  Delhi College of Engineering
  Mob: +919818442705
  E-Mail : tushicom...@gmail.com
  Website: www.jugadengg.com

Re: [algogeeks] Re: Puzzle

2011-08-05 Thread Tushar Bindal
of this double, half is kept inside the well, and the other half is used as
input to the 2nd well

half mean 1/2 or 50%
how can we assume it to be 100???
if we take it to be 1/2, the question goes wrong, so ur concept is valid but
then question should have been framed correctly

On Fri, Aug 5, 2011 at 7:55 PM, Lakshmi Prasad
prasadlakshmi...@gmail.comwrote:

 I didn't understand it fully plese explain

 On Aug 4, 2:48 pm, sagar pareek sagarpar...@gmail.com wrote:
  double 87.5 gives you 175
  100 will be used by 1st well and 75 will be used by second
  now second well will double the 75 and will give you 150
  100 will be used by second and remainder 50 will forwarded to third
  now third one use 50 and will double it to 100
 
  no remainder left
  i think its clear now  :) :)
 
  On Fri, Aug 5, 2011 at 12:14 AM, Himanshu Srivastava 
 
 
 
 
 
 
 
 
 
  himanshusri...@gmail.com wrote:
   i mean @sagar:how did you get 87.5%??
 
   On Fri, Aug 5, 2011 at 12:13 AM, Himanshu Srivastava 
   himanshusri...@gmail.com wrote:
 
   @nikhil:how did you get 87.5%??
 
   On Thu, Aug 4, 2011 at 11:59 PM, sagar pareek sagarpar...@gmail.com
 wrote:
 
   87.5 %
 
   On Thu, Aug 4, 2011 at 10:39 PM, Nikhil Gupta 
 nikhilgupta2...@gmail.com
wrote:
 
   There are 3 magical wells. Any input quantity of water we provide
 the
   1st well is returned double (of this double, half is kept inside the
 well,
   and the other half is used as input to the 2nd well).
   The 2nd well also returns double the quantity of its input (of which
   half is kept inside the well, and the other half is used as input to
 the 3rd
   well). Same goes with the 3rd, but its half output is the remainder
 (other
   half being kept inside the well). Now what input should we provide
 in the
   1st well, so that the remainder at the end comes out to be zero?
 
   (Asked in classroom coaching of T.I.M.E.)
   --
   Nikhil Gupta
   Senior Co-ordinator, Publicity
   CSI, NSIT Students' Branch
   NSIT, New Delhi, India
 
--
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
   **Regards
   SAGAR PAREEK
   COMPUTER SCIENCE AND ENGINEERING
   NIT ALLAHABAD
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  **Regards
  SAGAR PAREEK
  COMPUTER SCIENCE AND ENGINEERING
  NIT ALLAHABAD

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] MICRSOFT WRITEN TEST

2011-08-05 Thread Tushar Bindal
they always repeat questions.
go through lined list and trees questions on geeksforgeeks like finding loop
in LL, path in a binary tree (not BST) for a given sum, addition of numbers
stored digitwise in a linked list.
Printing 2d matrix in spiral order, KMP algorithm - these are some questions
they asked in interviews.

this one was asked to several candidates:
given: ddbbccae
output: 2d4a2b2c1a1e
isn't that easy?

On Fri, Aug 5, 2011 at 11:03 AM, siddharam suresh
siddharam@gmail.comwrote:

 thank you
 Thank you,
 Siddharam



 On Fri, Aug 5, 2011 at 10:51 AM, Poised~ dip10c...@gmail.com wrote:

 try this:
 https://groups.google.com/forum/?hl=en#!topic/algogeeks/Mbah1QXrJB4

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] difference between the two

2011-08-05 Thread Tushar Bindal
http://www.serc.iisc.ernet.in/ComputingFacilities/systems/cluster/xlf/html/xlfug/ug35.htm
this says int is always 4 bytes and pointer is 8 bytes on 64 bit compiler.

so how does padding affect these structures because of the difference in
size of int and pointer?


I tried this program
https://ideone.com/CRU6x#view_edit_box
char always gets 4 bytes whenever it has int or double in the same struct
irrrespctive of the order of the declaration of variables.
I thought char should get size 8 when there is a double in the ame struct
whereas it gets size 4 only.
what is the problem here?

On Sat, Aug 6, 2011 at 4:40 AM, Shashank Jain shashan...@gmail.com wrote:

 i dont understand the diff btw dem, could u plz elaborate?

 Shashank Jain
 IIIrd year
 Computer Engineering
 Delhi College of Engineering



 On Sat, Aug 6, 2011 at 12:32 AM, Kamakshii Aggarwal kamakshi...@gmail.com
  wrote:

 in case of 64 bit,
 size of second structure will also be 16 not 8


 On Fri, Aug 5, 2011 at 11:40 PM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:

 I think voth are just same..


 On Fri, Aug 5, 2011 at 10:57 AM, priya v pria@gmail.com wrote:

 in case of 64 bit machine y doesn't padding happen in the 2nd structure?


 On Fri, Aug 5, 2011 at 11:21 PM, hary rathor harry.rat...@gmail.comwrote:

 no ,if u r using 32 bit machine . that will use 4 byte pointer size ,
 but   in 64 machine that enforce to be size of 8 . where padding will
 take int your given first structure

 so for 32 bit- size will 8 8 for both structure
 for 64 bit - size will 16 and 12 respectively cause of 4 bit padding in
 one structure

 hence 2nd structure is good for use

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




 --
 *UTKARSH SRIVASTAV
 CSE-3
 B-Tech 2nd Year
 @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.




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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


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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] pls help

2011-08-05 Thread Tushar Bindal
, 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.




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Why this is giving run time error ?

2011-08-04 Thread Tushar Kanta Rath
@Dipankar : thanks.i think,this is the right logic

On Thu, Aug 4, 2011 at 11:10 AM, Dipankar Patro dip10c...@gmail.com wrote:

 Well I think the reason is very simple:
 When you enter the loop through L, the value of i is not initialized to 0,
 it is some garbage value.
 now while exiting the loop, the condition is checked for another iteration.
 Since the value of i is unknown, it might be the case that ij for a lot of
 number of times before the loop actually ends.

 But it is not a runtime error, and no infinite loop. the loop will end, the
 moment value of i becomes = j.

 On 4 August 2011 11:00, TUSHAR tusharkanta.r...@gmail.com wrote:

 #includestdio.h
 main()
 {
  int j=4,i;
  goto L;
  for(i=0;ij;i++)
  {

   L:
 printf(%d,j);
   }
 }




 why this is giving infinite loop.Runtime error ?



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




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

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




-- 
Tushar Kanta Rath,
Master In Computer Application
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.



Re: [algogeeks]

2011-08-04 Thread Tushar Kanta Rath
I also think Radix sort..as it runs in linear
TCcorrect me If i m wrong.


And in terms of minimum time of memory access , which sort is best ??
. Does it means minimum swap procedures 

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

2011-08-03 Thread TUSHAR
1.   Given an array of n-elements ? the 1st k -elements are in
descending order and k+1 to n elements are in
  ascending order. give an  efficient algo for searching an
element ?




2.  Given an array of n-elements ? each element in the array is either
same or less by 1 or larger by 1 from the
 previous element . give an  efficient algo for searching an
element ?

  e.g :   6 6 6 5 4 4 3 2 3 4 3 4 

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

2011-08-03 Thread Tushar Kanta Rath
these are asked in CITRIX ?  pl share possible logics..

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

2011-08-03 Thread Tushar Bindal
if we do not know k, how do we find it?

inthe series : 17 15 13 11 9 1 3 5 7

we can take k at element 1 also as the descending series can be 17 15 13 11
9 1 and ascending 3 5 7
OR
descending 17 15 13 11 9 and ascending 1 3 5 7
isn't there any relationship in kth and (k+1)th element that helps us find
out k correctly

On Thu, Aug 4, 2011 at 7:37 AM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 For question two ,
 try this.

 see te element at arr[0] . and supose you have to find k . if arr[0]==k ,
 then yes we found the element else see the diff betweem arr[0] and k. that
 will be minimum amount of steps needed to convert a[0] to k(let abs(a[0]-k)
 = p). then repeat the procedure again at the new element arr[p] untill you
 find the number of reach end of array..


 On Thu, Aug 4, 2011 at 6:59 AM, Dave dave_and_da...@juno.com wrote:

 @Amit: If k is not known, you can find it with another binary search.

 Dave

 On Aug 3, 3:02 pm, amit karmakar amit.codenam...@gmail.com wrote:
  I think for question 1, the value of k is not provided, right?
 
  On Aug 4, 12:53 am, Ankur Garg ankurga...@gmail.com wrote:
 
 
 
   Dave's solution looks gud to me :)
 
   On Wed, Aug 3, 2011 at 3:52 PM, Ankur Garg ankurga...@gmail.com
 wrote:
Q1 can be looked as rotated sorted array...check whether the no is
 less or
greater than kth element ..if greater search using binary search
 with low =0
high k-1 and if less earch in right with low=k+1 high =n;
 
q2) Dont know :(
 
On Wed, Aug 3, 2011 at 3:44 PM, Dave dave_and_da...@juno.com
 wrote:
 
@Tushar: For problem 1, do a binary search on elements 1 to k, and
 if
no hit is found, do a binary search on elements k+1 to n.
 
For problem 2, suppose that you are searching the given array for
 the
number 2. The idea is to take big steps when you are far from the
target, and small steps when you are close. Start with i = 0. If
 a[i] !
= 2, then add abs(a[i]-2) to i and try again. This is because it
 will
take at least abs(a[i]-2) steps to get to 2.
 
 In this case, i = 0 and a[0] = 6, so add 4 to i, getting 4. a[4] =
 4,
so add 2 to i, getting 6. a[6] = 3, so add 1. a[7] = 2.
 
Dave
 
On Aug 3, 2:09 pm, TUSHAR tusharkanta.r...@gmail.com wrote:
 1.   Given an array of n-elements ? the 1st k -elements are in
 descending order and k+1 to n elements are in
   ascending order. give an  efficient algo for searching an
 element ?
 
 2.  Given an array of n-elements ? each element in the array is
 either
 same or less by 1 or larger by 1 from the
  previous element . give an  efficient algo for searching an
 element ?
 
   e.g :   6 6 6 5 4 4 3 2 3 4 3 4 
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Call by reference

2011-08-03 Thread Tushar Bindal
Shashank,
In C++ we implement it thru reference variables

in the function call we can say func(x);
in the definition we have, func(int a)

whatever changes we make to a in func() are reflected back in x in the
calling function


In C, we can simulate i t through pointers
call : func(x);
definition: func(int *a)


I think this is what Sandeep meant

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

2011-08-03 Thread Tushar Bindal
never assume that he compiler is same as the OS you run. it may be that you
are running a 32-bit compiler

I think pointers have size 4bytes on 8 byte compiler also - not sure.
someone please correct me.

On Thu, Aug 4, 2011 at 10:26 AM, Shashank Jain shashan...@gmail.com wrote:

 the size of a pointer is showing 4 bytes in my 64-bit OS, which should have
 been 8 bytes. Correct me where i am wrong?

 Shashank Jain
 3rd year, Computer Engg.
 Delhi College of Engineering

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Call by reference

2011-08-03 Thread Tushar Bindal
we know all these definitions.

but i think the doubt was regarding the word simulate as we consider call by
reference an internal part of C
but your statement means that it is a concept of C++, but we just simulate
it in C using pointers. Am I correctly interpreting it?


On Thu, Aug 4, 2011 at 10:38 AM, Sandeep Jain sandeep6...@gmail.com wrote:

 We can say call-by-reference is where changes in formal parameters are
 reflected in actual parameters.
 call-by-value is where changes in formal parameters are not reflected in
 actual parameters.
 However when u have something like

 int x=10;
 f(x);

 void f(int *p){ *p = 20;}
 changes in p(formal parameter) won't be reflected in x (actual parameter)
 However changes in *p are reflected in x, using this the caller's variable
 is getting modified by the callee.


 Regards,
 Sandeep Jain




 On Thu, Aug 4, 2011 at 10:19 AM, Shashank Jain shashan...@gmail.comwrote:

 @sandeep, i dint get what do you mean by simulate here, as in an example
 wud be gud.

 Shashank Jain
 Delhi College of Engineering



 On Wed, Aug 3, 2011 at 11:34 PM, Sandeep Jain sandeep6...@gmail.comwrote:

 I'd say C language is a truly call-by-value language. C++ supports
 call-by-reference.
 However in C we can simulate call-by-reference using pointers and
 address-of operator.


 Regards,
 Sandeep Jain




 On Wed, Aug 3, 2011 at 11:27 PM, NITIN SHARMA 
 coolguyinat...@gmail.comwrote:

 As we say in C that we do call by reference but i thk call by
 reference is something different like we do through void pointer in c
 ++ but it should be call by address in C is it so?

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Call by reference

2011-08-03 Thread Tushar Bindal
that is exactly what i thought
thanks for the clarification

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

2011-08-03 Thread TUSHAR
#includestdio.h
main()
{
  int j=4,i;
  goto L;
  for(i=0;ij;i++)
  {

   L:
 printf(%d,j);
   }
}




why this is giving infinite loop.Runtime error ?



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

2011-08-02 Thread Tushar Bindal
i could not get what A and B stand for.
pls elaborate a bit more on that

On Tue, Aug 2, 2011 at 7:03 PM, vaibhavmitta...@gmail.com wrote:

 I guess in the above solution greedy wont wrk..i just assumed it wud..dint
 prove it..
 nevertheless..we can replace dis with..
 F(A,B,a,b,x,N) = % fill + max( F(A,B-x,a,b,x,N-(squares filled across
 length)), F(A-x,B,a,b,x,N-(squares filled across breadth)) )


 Regards
 VM
 NSIT, COE, 3rd yr
 On , vaibhavmitta...@gmail.com wrote:
  With the binary search we can decide for a value of size of square with
 reasonable error..
  nw to check hw much % fill does that value of size gives..we can
 implement a dp..or a recursive substitute..
  say size of rectangle is 'a' x 'b' and size of square chosen is 'x'..
  we hv to fill a grid with squares of size 'x'..so greedily fill the
 squares across the length of rectangle(subject to N)..
  so recursive function wud luk sumthin like dis
  F(A,B,a,b,x,N) = gives the % fill = % fill + F(A,B-x,a,b,x,N-(squares
 filled across length))
  where A x B is size of rectangle to fill, a x b is maximum size of
 rectangle, x is size of square we are considering, N is remaining squares we
 can fill..
  base cases wud be wen we cannot fill squares subjected to N = 0 or if A
 and B dont permit us to..
 
  I hope dis helps mam.
 
  Regards
  VM
  NSIT, COE, 3rd yr
 
  On , Kamakshii Aggarwal kamakshi...@gmail.com wrote:
   @vaibhav:can u please elaborate?
  
   On Tue, Aug 2, 2011 at 6:31 PM, Vaibhav Mittal
 vaibhavmitta...@gmail.com wrote:
  
   dynamic programming with binary search should do it..
  
   Regards
   VM
   NSIT, COE, 3rd yr
  
  
  
   On Tue, Aug 2, 2011 at 6:19 PM, Kamakshii Aggarwal
 kamakshi...@gmail.com wrote:
  
   @sunny:yes all the squares should be of same size
  
  
   On Tue, Aug 2, 2011 at 5:03 PM, Poised~ dip10c...@gmail.com wrote:
  
  
  
   @ narain-i didn't see that coming. thanks for the heads up.
  
  
  
  
  
   --
  
   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/-/oSuB8bJuqDcJ.
  
  
  
   To post to this group, send email to algogeeks@googlegroups.com.
  
   To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  
  
   For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
  
  
  
  
  
  
  
  
  
  
   --
   Regards,
   Kamakshi
   kamakshi...@gmail.com
  
  
  
  
  
   --
  
  
   You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  
  
  
   To post to this group, send email to algogeeks@googlegroups.com.
  
   To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  
  
   For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
  
  
  
  
  
  
  
  
  
  
  
  
   --
  
   You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  
   To post to this group, send email to algogeeks@googlegroups.com.
  
   To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  
  
   For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
  
  
  
  
  
  
  
  
   --
   Regards,
   Kamakshi
   kamakshi...@gmail.com
  
  
  
  
  
   --
  
   You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  
   To post to this group, send email to algogeeks@googlegroups.com.
  
   To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  
  
   For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
  
  
  
  

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Tushar Bindal
@Nikhil
Once the rabbits are mature, they should be able to produce babies every
month. after 2 months a female produces new babies for first time.
but then they should be able to produce a new pair at the end of the third
month as they can again mate at the end of second month.
Like in the cow problem also, it gave birth to a young one for the first
time at the age of 2 and then every year.
Hope this logic is right.
Then the number of rabbits after one year are 466

On Sun, Jul 31, 2011 at 12:24 PM, ashish kumar ashishmnnit6...@gmail.comwrote:

 233 is the right answer..


 On Fri, Jul 29, 2011 at 12:27 PM, shiv narayan 
 narayan.shiv...@gmail.comwrote:

 solutions for cow questions:
 if we consider first cow would she calf at age 2 then first new cow
 would come at age two.
 at end of 2nd year: 1st would give new cow:
 at end of 3rd year:1st cow would another new cow
 at end of 4th year :1st cow will give new cow and the cow born at end
 of 2nd year would give another cow
 at 5th year:  :now of new cows=cow born by(1st+2nd year+3rd
 year)
 -
 -
 -
 -
 if you try it this way then you would be able to understad that it
 would be a reverse fibinacci series( try to analyse by last cow
 produced by 1st cow)
 total no of cows would be:  1+1+2+3+5+8+13+21+34+55+89=(sum of first
 11 terms of fibinacci series)
 232

 correct me if i am wrong.
 On Jul 29, 11:15 am, Reynald reynaldsus...@gmail.com wrote:
  If a cow produces its first she-calf at age two years and after that
  produces another single she-calf every year, how many she-calves are
  there after 12 years? assuming none die.
 
  and a similar one, asked to another guy,
 
  Suppose a newly-born pair of rabbits, one male, one female, are put in
  a field. Rabbits are able to mate at the age of one month so that at
  the end of its second month a female can produce another pair of
  rabbits. Suppose that our rabbits never die and that the female always
  produces one new pair (one male, one female) every month from the
  second month on. How many pairs will there be in one year?

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




 --
 Ashish kumar
 ECE final yr
 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.




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Tushar Bindal
 Suppose that our rabbits never die and that the female always
produces one new pair (one male, one female) *every month from the
second month on
*
@Priyanka
You have answer 288
I added 178 to it because I got the answer that 89 females would have given
birth in the last month.
Pls clarify.
Are you taking one month less or am I taking 1 more?

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



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

2011-07-30 Thread Tushar Bindal
i think sunny's method should work.

On Sat, Jul 30, 2011 at 12:45 PM, varun pahwa varunpahwa2...@gmail.comwrote:

 do morris traversal until you find k. but that may modify the tree if you
 break as you find k.


 On Sat, Jul 30, 2011 at 9:14 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 Here the required program :

 void findkthSmallest(Node *root,int k)
 {
 Node *stack[100];
 int top=-1,count=0;
 Node *temp;
 stack[++top]=root;

 /*First we will find the minimum node*/
 temp=root;
 while(temp-left != NULL)
 {
 stack[++top]=temp-left;
 temp-left=NULL; //Make it NULL so that we do not traverse it
 again
 temp=temp-left;
 }
 //Now top of the stack contains the minimum node.
 //Now we will do inorder traversal
 while(top!=-1)
 {
 temp=stack[top];
 count++;   //Increment the count for every eleemnt
 traversed
 if(count==k)   //If count reaches k, we have kth smallest
 element as the top of the stack
 return stack[top]-value;
 else if(temp-left!=NULL)
 {
 stack[++top]=temp-left;
 temp-left=NULL;  //Make it NULL so that we do not
 traverse it again
 count++;
 }
 else if(temp-right!=NULL)
 {
 stack[++top]=temp-right;
 temp-right=NULL;  //Make it NULL so that we do not
 traverse it again
 count++;
 }
 else
 top--;

 }
 }

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




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

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

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Novell - Puzzle

2011-07-30 Thread Tushar Bindal
for rabbits answer would be different from cows as they give birth to a pair
at a time, so at any time odd number of rabbits won't be there

On Sat, Jul 30, 2011 at 9:13 AM, Reynald Suz reynaldsus...@gmail.comwrote:

 Thank ya shiv, agarwal and Anders.


 On Sat, Jul 30, 2011 at 8:10 AM, Anders Ma xuejiao...@gmail.com wrote:

 anders@anders-Satellite-U400:~/puzzle$ cat novel_she_calf.c
 #include stdio.h

 /*
 iIf a cow produces its first she-calf at age two years and after that
 produces another single she-calf every year, how many she-calves are
 there after 12 years? assuming none die.
 */

 unsigned int she_calves(unsigned int year)
 {
unsigned int one_year = 0;
unsigned int two_year = 1;
unsigned int tmp;

while (year--) {
tmp = one_year;
one_year += two_year;
two_year = tmp;
}
return one_year + two_year - 1;
 }

 int main (int argc, char** argv)
 {
unsigned int number;

if (argc != 2) {
printf([usage]: she_calves [year]\n);
return 0;
}
number = she_calves(atoi(argv[1]));
printf(After %d years, she-calves number is %d\n, atoi(argv[1]),
 number);
 }
 anders@anders-Satellite-U400:~/puzzle$ gcc novel_she_calf.c -o she_calves
 anders@anders-Satellite-U400:~/puzzle$ ./she_calves 12
 After 12 years, she-calves number is 232
 anders@anders-Satellite-U400:~/puzzle$



 --
 Regards
 Anders

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

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Novell - Puzzle

2011-07-30 Thread Tushar Bindal
Nikhil
can u pls explain ur logic for the rabbit question.
I think it will be more

On Sat, Jul 30, 2011 at 8:46 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 And 233 for cows. Shiv narayan's answer is correct. But he didn't add the
 main cow.


 On Sat, Jul 30, 2011 at 8:42 PM, Nikhil Gupta 
 nikhilgupta2...@gmail.comwrote:

 For rabbits, answer is 256.


 On Sat, Jul 30, 2011 at 8:33 PM, Tushar Bindal tushicom...@gmail.comwrote:

 for rabbits answer would be different from cows as they give birth to a
 pair at a time, so at any time odd number of rabbits won't be there


 On Sat, Jul 30, 2011 at 9:13 AM, Reynald Suz reynaldsus...@gmail.comwrote:

 Thank ya shiv, agarwal and Anders.


 On Sat, Jul 30, 2011 at 8:10 AM, Anders Ma xuejiao...@gmail.comwrote:

 anders@anders-Satellite-U400:~/puzzle$ cat novel_she_calf.c
 #include stdio.h

 /*
 iIf a cow produces its first she-calf at age two years and after that
 produces another single she-calf every year, how many she-calves are
 there after 12 years? assuming none die.
 */

 unsigned int she_calves(unsigned int year)
 {
unsigned int one_year = 0;
unsigned int two_year = 1;
unsigned int tmp;

while (year--) {
tmp = one_year;
one_year += two_year;
two_year = tmp;
}
return one_year + two_year - 1;
 }

 int main (int argc, char** argv)
 {
unsigned int number;

if (argc != 2) {
printf([usage]: she_calves [year]\n);
return 0;
}
number = she_calves(atoi(argv[1]));
printf(After %d years, she-calves number is %d\n,
 atoi(argv[1]), number);
 }
 anders@anders-Satellite-U400:~/puzzle$ gcc novel_she_calf.c -o
 she_calves
 anders@anders-Satellite-U400:~/puzzle$ ./she_calves 12
 After 12 years, she-calves number is 232
 anders@anders-Satellite-U400:~/puzzle$



 --
 Regards
 Anders

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

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




 --
 Tushar Bindal
 Computer Engineering
 Delhi College of Engineering
 Mob: +919818442705
 E-Mail : tushicom...@gmail.com
 Website: www.jugadengg.com

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




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: rotate a matrix NVIDIA question

2011-07-28 Thread Tushar Bindal
I think that we have to make a spiral traversal
So o/p for your matrix would be:
1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10

On Thu, Jul 28, 2011 at 1:56 PM, Rajeev Kumar rajeevprasa...@gmail.comwrote:

 @puneet

 Can you give us an example what u mean by 180 degree rotation...
 For given matrix like
 1, 2,   3, 4
 5, 6,   7, 8
 9,10,11,  12
 13,14,15,16

 What is the expected output?


 On Wed, Jul 27, 2011 at 11:29 PM, Puneet Gautam 
 puneet.nsi...@gmail.comwrote:

 Can anyone give an O(n) solution pls...??
 I think the above code is an O(n^2) solution..
 if i am not wrong...!!!



 On 7/27/11, amit amit.codenam...@gmail.com wrote:
  #include cstdio
  #include algorithm
  using namespace std;
 
  const int MX = 1000;
  int n, m;
  int a[MX][MX];
 
  int main() {
  scanf(%d%d, n, m);
  for(int i = 0; i  n; i++)
  for(int j = 0; j  m; j++)
  scanf(%d, a[i][j]);
 
  for(int i = 0; i  n/2; i++)
  for(int j = 0; j  m; j++)
  swap(a[i][j], a[n-i-1][m-j-1]);
  if(n1)
  for(int j = 0; j  m/2; j++)
  swap(a[n/2][j], a[n/2][m-j-1]);
 
  for(int i = 0; i  n; i++) {
  for(int j = 0; j  m; j++)
  printf(%d , a[i][j]);
  printf(\n);
  }
  }
 
 
  On Jul 27, 7:54 pm, Anika Jain anika.jai...@gmail.com wrote:
  is it lyk for {1,2,3
 4,5,6,
 7,8,9}
  to be {3,2,1,
   6,5,4,
   9,8,7}??
 
 
 
  On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan deok...@gmail.com
 wrote:
   rotate a 2D matrix by angle 180
 
   --
   **With Regards
   Deoki Nandan Vishwakarma
 
   *
   *
 
--
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

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




 --
 Thank You
 Rajeev Kumar

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: rotate a matrix NVIDIA question

2011-07-28 Thread Tushar Bindal
If this is the case, we can follow this method:

take variables
1. dir = 1
2. st_col=0
3. end_col = n-1
4. st_row = 1
5. end_row = n-1
6. row = 0
7. col = n-1
8. noOfCellsVisited = 0

dir are as follows:
1 - left ro right
2 - top to bottom
3 - right to left
4 - bottom to top

row will keep account of the row we will traverse when dir=1 or 3
col will keep account of the column we will traverse when dir=2 or 4

st_col and end_col will keep account of leftmost and rightmost columns for
traversing rows
st_row and end_row will keep account of topmost and bottom rows for
traversing columns


while(noOfCellsVisitedmn)
{
if(dir == 1)
{
for i = st_col to end_col
{ print arr[row][i]; noOfCellsVisited++}
dir++;
end_col--;
row = n-1-row;
}

if(dir==2)
{
for i = st_row to end_row
{ print arr[i][col]; noOfCellsVisited++}
dir++;
end_row--;
col=n-1-col;
}

if(dir==3)
{
for i = end_col to st_col
{ print arr[row][i]; noOfCellsVisited++}
dir++;
row=n-row;
st_col++;
}
if(dir==4)
{
for i = end_row to st_row
{ print arr[i][col; noOfCellsVisited++}

}
dir=1;
col=n-1-(i-1);
st_row++;
}

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

2011-07-28 Thread Tushar Bindal
There will be following changes to this

while(noOfCellsVisitedmn)
{
if(dir == 1)
{
for i = st_col to end_col
{ print arr[row][i]; noOfCellsVisited++}
dir++;
end_col--;
row = n-1-row;
}

else if(dir==2)
{
for i = st_row to end_row
{ print arr[i][col]; noOfCellsVisited++}
dir++;
end_row--;
col=n-1-col;
}

else if(dir==3)
{
for i = end_col to st_col
{ print arr[row][i]; noOfCellsVisited++}
dir++;
row=n-row;
st_col++;
}

else if(dir==4)
{
for i = end_row to st_row
{ print arr[i][col; noOfCellsVisited++}

}
dir=1;
col=n-1-(i+1);
st_row++;
}
}

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

2011-07-28 Thread Tushar Bindal
i am sorry for givin such a naive solution and making so many mistakes.
i still left a mistake in dir==4
*
col=n-1-(col+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.



Re: [algogeeks] Re: rotate a matrix NVIDIA question

2011-07-28 Thread Tushar Bindal
thanks amit for this code
i tried this for the first time and am still not over finding out my
mistakes (got another one while trying it out on an array)

yours was an easy one :)

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



Re: [algogeeks] Re: Facebook Interview question at NIT Warangal

2011-07-28 Thread Tushar Bindal
though the code given by siddharth seems to be a bit tough to understand due
to one long statement, it gives a good idea to run the main loop fron 2^k
-1  to (2^k - 1)*(2^(n-k)) since these rae the only numbers having k digits
set

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



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

2011-07-28 Thread Tushar Bindal
can't we include -9 , 3 , 1, 5 , 0 as a possible sub array?

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



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

2011-07-28 Thread Tushar Bindal
yup
i got it now.
nice code

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



Re: [algogeeks] Puzzle

2011-07-28 Thread Tushar Bindal
we can just infer that at the point where the man met the driver, from that
point, it takes 10 minutes to reach the office (assuming that car moves at
same uniform speed all the time)

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

2011-07-28 Thread Tushar Bindal
for compiler giving 8 bit for pointers, shouldn't int also be of 8 bits??

On Thu, Jul 28, 2011 at 12:26 PM, Jnana Sagar supremeofki...@gmail.comwrote:

 @aditya..the answer may vary, because c is machine dependent
 language..in few machines int is of 2 bytes and char is of 1 byte..u
 can't say..it varies with diff machines

 On 7/26/11, aditya kumar aditya.kumar130...@gmail.com wrote:
  char *s[5] is a array of pointers of type char . but the thing is size of
  pointers is 4byte irrespective of its type . coz address is always an
  unsigned int which is of 4byte.
  On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam
  puneet.nsi...@gmail.comwrote:
 
  @everyone:
  I have this mind strangling doubt..!!!
 
  Why is char *s[5] of 20 bytes...?
 
  yes the output is 28...
 
  On 7/26/11, Don dondod...@gmail.com wrote:
   A reasonable guess would be 28 bytes. But the size of a structure is
   implementation dependent, and therefore, some other result could be
   correct as well.
   Don
  
   On Jul 26, 7:40 am, Puneet Gautam puneet.nsi...@gmail.com wrote:
   #includestdio.h
   #includestddef.h
   struct node{
  int a;
  char *b[5];
  struct node *link;
  };
   main()
   {
 int a;
 a=sizeof(struct node);
 printf(%d,a);
 getchar();
 return 0;
 }
  
   Whats the output..?
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



[algogeeks] write an scanf that reads only a to z charchter.............

2011-07-26 Thread TUSHAR
write an scanf that reads only a to z charchter.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: write an scanf that reads only a to z charchter.............

2011-07-26 Thread Tushar Kanta Rath
thanks to all . :)

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

2011-07-21 Thread Tushar Kanta Rath
1st reverse each word in place.then reverse the whole
sentenceit will give the required *answer*

-- 
Tushar Kanta Rath,
Master In Computer Application
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.



Re: [algogeeks] Re: Puzzle

2011-07-17 Thread Tushar Bindal
thanks sagar for this wonderful shortcut

but can you please explain it better. in what cases can we use this
approach?

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



Re: [algogeeks] Re: Puzzle

2011-07-17 Thread Tushar Bindal
thankyou :)

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



Re: [algogeeks] c++ output

2011-07-17 Thread Tushar Bindal
@varun
you are contradicting your own statement
when inline replaces the code at place where it is called, then this code
will work fine.

and the other one w/o inline won't as explained by others also.
there seems to be some confusion in your statement.


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] puzzle-plz explain stepwise

2011-07-14 Thread Tushar Bindal
yx - xy = x0y - yx
=  (10y + x) - (10x + y) = (100x + y) - (10y + x)
9y - 9x = 99x - 9y
18y = 108x
y=6x

Since, x comes in hundreds place, we know it can only be 1 as the difference
between the 3 digit number and two digit number is difference of two 2 digit
numbers only.
thus, y=6*1 = 6

a explained earlier
avg speed = (106-16)/2 = 45 units

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

2011-07-07 Thread Tushar Bindal
the clock has become faster by 48 seconds in 10800 minutes
i.e., 1 sec in 225 minutes

from 8am on sunday we have to go 225*5*60 minutes behind to get time when
clock showed the correct time.
i.e., 67500 minutes or 44 days 1260 minutes
44 days 21 hours
which means clock showed correct timing at 11amon the day 45 days before the
sunday on which it was 5 minutes ahead.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-07-07 Thread Tushar Bindal
probability that i win standing at second position: 1/365
third position : 364/365*2/365 = 1/365)*(628/365)
fourth position : 364/365*363/365*3/365
4th : 364/365*363/365*362/365*4/365

nth position:
(365-1)*(365-2)*(365-3)*(365-4)*(365-5).*(365-(n-2))*(365-(n-1))*(n)*(1/365)^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: Puzzle

2011-07-07 Thread Tushar Bindal
Sorry for the previous post
the last line was incorrect
it should have been (n+1)th position

I was just writing roughly and pressed send instead of save.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-07-07 Thread Tushar Bindal
probability that i win standing at second position: 1/365
probability that i win standing at third position : 364/365*2/365 =
1/365)*(628/365)
probability that i win standing at fourth position : 364/365*363/365*3/365
probability that i win standing at 4th position :
364/365*363/365*362/365*4/365

probability that i win standing at (n+1)th position:
(365-1)*(365-2)*(365-3)*(365-4)*(365-5).*(365-(n-2))*(365-(n-1))*(n)*(1/365)^n

there is a pattern in the probabilities
let probability of winning standing at nth position be x
probability of winning standing at (n+1)th position = x * {(365 - n +1)*(n)}
/ {365*(n-1)}

maximum probability is at nth position if at (n+1)th position,
{(365 - n +1)*(n)} / {365*(n-1)}



-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] puzzle

2011-07-07 Thread Tushar Bindal
Sumit,
the answer is 14
I think the example of 16 that they take on careerplus is probably confusing
you.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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-07-07 Thread Tushar Bindal
Sory once again for that incomplete answer.
The complete one is here.
probability that i win standing at second position: 1/365
probability that i win standing at third position : 364/365*2/365 =
1/365)*(628/365)
probability that i win standing at fourth position : 364/365*363/365*3/365
probability that i win standing at 4th position :
364/365*363/365*362/365*4/365

probability that i win standing at (n+1)th position:
(365-1)*(365-2)*(365-3)*(365-
4)*(365-5).*(365-(n-2))*(365-(n-1))*(n)*(1/365)^n

there is a pattern in the probabilities
let probability of winning standing at nth position be x
probability of winning standing at (n+1)th position = x * {(365 - n +1)*(n)}
/ {365*(n-1)}

maximum probability is at nth position if at (n+1)th position,
{(365 - n +1)*(n)} / {365*(n-1)}  =  1

This is true for n=20

For n=19,
{(365 - n +1)*(n)} / {365*(n-1)}1

So max probability is when *n=19*
i.e., n+1 = 20, which is my position.

So standing at 20th position gives me maximum chance of winning


Just hope I haven't got anything wrong here.

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



Re: [algogeeks] Re: help to code

2011-07-06 Thread Tushar Bindal
Evenly divisible simply means that a number should be completely divisible
by the given numbers, i.e., it should give a whole number as an answer when
divided by that particular number. Evenly divisible doesn't mean that
quotient should be an even number. It just needs to be a whole number.
Probably this link can help you understand that
http://en.wiktionary.org/wiki/evenly_divisible

So if you agree with my interpretation that numbers which are not divisible
by all 5 numbers should be taken into account, then my code is correct.
:)

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

2011-07-06 Thread Tushar Bindal
You have given solution for number of coins required for different sum as
explained on topcoder tutorial.
But I think the question has put forward some conditions based on which it
asks us to find the denominations of the 6 coins.
You have taken the sum given(which cannot be obtained by using coins we
have) in the problem as denominations.

I think you have interpreted it erongly.
Just hope my interpretation is correct :)

On Tue, Jul 5, 2011 at 5:25 PM, Azhar Hussain azhar...@gmail.com wrote:

 What I understood from the statement is what is the 'minimum denomination'
 required for a given value.

 I will try to explain it in short
 we can solve the problem as sub-problems

 Lets say you want a denomination for some sum S and 'i' be the previous sum
 so i = S.
  If we can find the sum at i we can find the sum for i+1 using i as our
 reference.

 For example S= 15. What is the minimum denomination required using the
 coins 5, 10
 from the statement above I cannot calculate sums other than multiples of 5.
 So, I will write down sums which are multiples of 5 upto 15.
 0
 5
 10
 15

 Inorder to calculate denominations for 15. I must have calculate
 denominations of 15, 5, 0

 Goal:
 First 0, this does not require coins so coins are 0.
 Sum 5, we have found the solution yet for this mark it as infinity. We see
 that there is only one coin in the denomination pool which is less than this
 sum.
 Sum 10, If I can take the previous sum 10 - 5, I will end up having 2 coins
 but the best solution would be denomination of 10 i.e., 1 coin. I compare
 the denominations value and the previous sum and store the minimum value.
 Sum 15, From the previous step 1 coin for 10 and 5 denomination will make
 up the sum so number of coins are 2.

 this can be recursively defined as
 if ((N[j] = i)  ((Min[i-N[j]] + 1)  Min[i]))
 Min[i] = Min[i-N[j]] + 1;

 Where N is the denominations
 i is the Previous Sum denoted as Min
 j is the index of denomination

 sum[1,, 15] = infinity;
 for sum 0 i = 0; N[0] = 5 and 5 = is false sum remains 0, so Sum[0] = 0.
 for Sum 5 i = 5 ; N[0] = 5 and 5 = 5 true and (Sum[5-5] + 1)  Sum[5]
 update the sum[5] = sum[5-5] + 1;
 + 1 because including N[j] coin makes the sum
 do the same for remaining sums.


 can be represented mathematically like this
 *C*(*N*,*m*) = *C*(*N*,*m* - 1) + *C*(*N* - *S**m*,*m*)

 Or This is the least I can say.
 M(j) = Minimum number of coins required to make change for amount of money
 j.
 M(j) = Min { M( j - vi ) } + 1;
   i
 complexity O(n^S)  for the Sum S.

 -
 Azhar.



 -
 Azhar.




 On Tue, Jul 5, 2011 at 4:37 PM, Dumanshu duman...@gmail.com wrote:

 @Azhar: could u plz explain the q8. problem.

 On Jul 5, 12:13 pm, Azhar Hussain azhar...@gmail.com wrote:
  Q8 is a DP problem, here is the solution
 
  #include stdio.h
 
  #define MAX 125
  #define VAL 6
  int Min[MAX];
  int N[VAL] = {5, 10, 20, 25, 50, 100};
 
  int main(void)
  {
  int i, j;
 
  for (i = 1; i  MAX; i++)
  Min[i] = 100;
 
  for (i = 5; i  MAX; i += 5)
  for (j = 0; j  VAL; j++)
  if ((N[j] = i)  ((Min[i-N[j]] + 1)  Min[i]))
  Min[i] = Min[i-N[j]] + 1;
 
  fprintf(stderr, \n***\n);
  for (i = 0; i  MAX; i += 5)
  fprintf(stderr, %d = %d\n, i, Min[i]);
  return 0;
 
  }
 
  OUTPUT:
 ***
  0 = 0
  5 = 1
  10 = 1
  15 = 2
  20 = 1
  25 = 1
  30 = 2
  35 = 2
  40 = 2
  45 = 2
  50 = 1
  55 = 2
  60 = 2
  65 = 3
  70 = 2
  75 = 2
  80 = 3
  85 = 3
  90 = 3
  95 = 3
  100 = 1
  105 = 2
  110 = 2
  115 = 3
  120 = 2
 
  more information can be found athttp://
 www.topcoder.com/tc?module=Staticd1=tutorialsd2=dynProg
 
  -
  Azhar.

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Puzzle

2011-07-06 Thread Tushar Bindal
Let speed of boat be x miles/hr
Let speed of river be s miles/hr

First Method:
Hat comes down 1 mile in 10 minutes.
Hat comes with flow of river only. So its speed is equal to speed of river.
In 60 minutes, it will travel 6 miles.
thus, s = 6 miles/hr

Second Method:
Distance travelled upward by boat = 1 + (5/60)*(x-s) miles
Distance travelled downward by boat = (5/60)*(x+s) miles
Both are same, so
1 + (5/60)*(x-s) = (5/60)*(x+s)
x gets cancelled, and we have
s/6 = 1
s = 6 miles/hr

Second method is just one possible method which nobody would like to follow.
First one is easier and faster - win-win situation
For a change the easier method is faster as well
-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Reversing the order of words in String

2011-07-06 Thread Tushar Bindal
good job
but how can this be done in one traversal as asked on the Adobe Interview
Questions 
threadhttps://groups.google.com/forum/#%21msg/algogeeks/oEL8z4wwMJY/FAVdr2McPqIJ
.



On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com wrote:

 I think somebody on this thread has asked this question but i am not
 able to find that.

 Question was if a string is like my name is ram, then output should
 be ram is name my.

 Wrote the code for same, so sharing.

 #includeiostream
 #includestring
 using namespace std;

 void SwapStringChars(string str, int pos1, int pos2)
 {
char ch = str[pos1];
str[pos1] = str[pos2];
str[pos2] = ch;
 }

 void reverseString(string str, int left, int right)
 {
for(int i = left ; i = left + (right-left)/2 ; i++)
SwapStringChars(str, i, right + left -i));
 }

 void reverseWordsInString(string str)
 {
char space = ' ';
int len = str.length();
int startIndex = 0, endIndex = 0;
while(endIndex  len - 1)
{
while(str[endIndex] != space  endIndex  len)endIndex++;
reverseString(str, startIndex, endIndex-1);
startIndex = endIndex;
while(str[startIndex] == space)startIndex++;
endIndex = startIndex;
}
 }

 int main()
 {
string str;
cout\nEnter enter the string :;
getline(cin,str);

//Reverse whole string at once
reverseString(str, 0, str.length() - 1);

//Reverse Individual words in string
reverseWordsInString(str);
coutstr;
cin.get();
return 0;
 }

 --
 Regards,
 Navneet

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Reversing the order of words in String

2011-07-06 Thread Tushar Bindal
I read that solution.
But the same doubt as Navneet which I think you also raised i one of your
posts on that thread

On Wed, Jul 6, 2011 at 10:34 PM, Navneet Gupta navneetn...@gmail.comwrote:

 Saurabh,

 I understood your solution but wonder if it is purely single traversal

 In affect, you have a second traversal when you are popping the
 strings from stack to form the reverse order string.

 Though the second activity is less than O(n) i.e. O(#words in string)
 Nice solution, this way we can also get rid of extra spaces easily in
 the actual string if that is also to be done.

 On Wed, Jul 6, 2011 at 10:16 PM, saurabh singh saurab...@gmail.com
 wrote:
  I have proposed my solution in one of the previous posts.Check the
 solution
  there
 
  On Wed, Jul 6, 2011 at 10:10 PM, Tushar Bindal tushicom...@gmail.com
  wrote:
 
  good job
  but how can this be done in one traversal as asked on the Adobe
 Interview
  Questions thread.
 
 
 
  On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com
  wrote:
 
  I think somebody on this thread has asked this question but i am not
  able to find that.
 
  Question was if a string is like my name is ram, then output should
  be ram is name my.
 
  Wrote the code for same, so sharing.
 
  #includeiostream
  #includestring
  using namespace std;
 
  void SwapStringChars(string str, int pos1, int pos2)
  {
 char ch = str[pos1];
 str[pos1] = str[pos2];
 str[pos2] = ch;
  }
 
  void reverseString(string str, int left, int right)
  {
 for(int i = left ; i = left + (right-left)/2 ; i++)
 SwapStringChars(str, i, right + left -i));
  }
 
  void reverseWordsInString(string str)
  {
 char space = ' ';
 int len = str.length();
 int startIndex = 0, endIndex = 0;
 while(endIndex  len - 1)
 {
 while(str[endIndex] != space  endIndex 
 len)endIndex++;
 reverseString(str, startIndex, endIndex-1);
 startIndex = endIndex;
 while(str[startIndex] == space)startIndex++;
 endIndex = startIndex;
 }
  }
 
  int main()
  {
 string str;
 cout\nEnter enter the string :;
 getline(cin,str);
 
 //Reverse whole string at once
 reverseString(str, 0, str.length() - 1);
 
 //Reverse Individual words in string
 reverseWordsInString(str);
 coutstr;
 cin.get();
 return 0;
  }
 
  --
  Regards,
  Navneet
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Tushar Bindal
  Computer Engineering
  Delhi College of Engineering
  Mob: +919818442705
  E-Mail : tushicom...@gmail.com
  Website: www.jugadengg.com
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT ALLAHABAD
 
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 



 --
 Regards,
 Navneet

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] puzzle

2011-07-06 Thread Tushar Bindal
100th floor is the answer


On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan narayan.shiv...@gmail.comwrote:


 * You are given 2 eggs.
 * You have access to a 100-storey building.
 * Eggs can be very hard or very fragile means it may break if dropped
 from the first
 floor or may not even break if dropped from 100 th floor.Both eggs are
 identical.

 * You need to figure out the highest floor of a 100-storey building an
 egg can be
 dropped without breaking.
 * Now the question is how many drops you need to make. You are allowed
 to break 2
 eggs in the process

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] puzzle

2011-07-06 Thread Tushar Bindal
Eggs can never break the building.
So dropping the eggs won't break the building - whether you drop them from
1st floor or 100th floor.

On Wed, Jul 6, 2011 at 10:42 PM, Sriganesh Krishnan 2448...@gmail.comwrote:

 i think this puzzle follows arithmetic progression...i'm not sure
 though...does anybody have a clean explanation for this?


 On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan 
 narayan.shiv...@gmail.comwrote:


 * You are given 2 eggs.
 * You have access to a 100-storey building.
 * Eggs can be very hard or very fragile means it may break if dropped
 from the first
 floor or may not even break if dropped from 100 th floor.Both eggs are
 identical.

 * You need to figure out the highest floor of a 100-storey building an
 egg can be
 dropped without breaking.
 * Now the question is how many drops you need to make. You are allowed
 to break 2
 eggs in the process

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] puzzle

2011-07-06 Thread Tushar Bindal
@Navneet
Didn't get your point


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: puzzle

2011-07-06 Thread Tushar Bindal
the solution is given
herehttp://www.thecareerplus.com/?page=resourcescat=150subCat=10qNo=2
but can anyone lease explain it better
please give a original solution

and stop making rude comments about answers posted genuinely.
If you have an original solution, please post 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.



Re: [algogeeks] help to code

2011-07-05 Thread Tushar Bindal
I think you are getting it wrong.
Surender, your solution says that numbers divisible by all of the first 5
prime numbers will be taken into account whereas the question says that only
the numbers *not* evenly divisible by *any* of the first 5 prime numbers are
to be added.

Shiv,
you are making two mistakes:
1. you say n is also included but your code excludes it.
2. you are just checking if a number is not divisible by one of the 5 prime
numbers. If it is not divisible by any one number, you add it to your
result, whereas your language of the question suggests that it should be
that numbers which are not divisible by any of the five numbers, i.e., not
divisible by all the 5 numbers ( not the ones divisible by just ant one of
the 5).

Hope I am correct in my interpretation.

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

2011-07-05 Thread Tushar Bindal
If my interpretation is right, following should be the code.


int main()
{
int userInteger = 0;
cout  Enter A Number endl;
cin  userInteger; // Ask For a number from the user
if (userInteger  0) // Is the number valid?
{
int result = 0;
int prime[5] = { 2, 3, 5, 7, 11 };
int a,b, count = 0;
*for(a=1;a=userInteger;++a) // Looping to user's input
{
  for(b=0;b  5;++b) // Looping the prime numbers array
   {
   if (a % prime[b] == 0) //if divisible by any number, just end it there
   break;
  }
 //break or end of loop will bring the control here
 if(b==5) //a was not divisible by any of the first 5 prime numbers
 {
 result+=a;
 ++count;
 }
}*
cout  Numbers Not evenly divisible by 5 prime numbers:   count
 endl;
cout  The Sum of numbers not evenly divisible by 5 prime numbers: 
 result  endl;
}
getch();
return 0;
}



As per my solution,
Test Cases:
1)
userInteger = 20
count = 4
Numbers will be: 1, 13, 17, 19
result = 50

2)
userInteger = 35
count = 7
Numbers will be: 1, 13, 17, 19, 23, 29, 31
result = 133




Even numbers can never be there in this list as they are all divisible by 2.
Bfore 169, only prime numbers can be included.
Hope my interpretation of your question was correct

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

2011-05-28 Thread Tushar Bindal
that theorem is for odd primes
9 is not an odd prime
so we can;t apply this theorem

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



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

2011-04-29 Thread Tushar Bindal
Manish is right.
This would start from the left.
In cout also processing starts from left.

The processing is from right in the printf statement.


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Stroustrup C++ BOOK

2011-04-27 Thread Tushar Bindal
I have the book
but I hope there are no issues with ths book being shared here. I don't have
the link now.
would it be fine if I share the book directly?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Cracking the IT interview: jump start your career with confidence

2011-04-26 Thread Tushar Bindal
is there anyone who has this book?

-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Stroustrup C++ BOOK

2011-04-26 Thread Tushar Bindal
searching in the group did not help
please give the link to your previous post
or better give the link once again


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Stroustrup C++ BOOK

2011-04-26 Thread Tushar Bindal
Is this one fine?
http://www.megaupload.com/?d=YSSE195C


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com
Website: www.jugadengg.com

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



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

2011-04-24 Thread Tushar Bindal
Plz mail the book to me too



-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com
Website: www.jugadengg.com

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



Re: [algogeeks] Re: Google puzzles

2011-03-30 Thread Tushar Bindal
Arpit
The formula that you have written is wrong. You would have approached it
correctly but the formula written here is incorrect.

m= n + (n**1/6* + (n-1)) + ((n**7/6* + (n-1))**1/6* + n-2) +..

If you add all the terms there should be 1/6 in these terms as the terms
give the number of medals given on each day.
If you use 7/6, you only need to solve for one term where n-6 would come. As
the terms in the series when 7/6 is used give the number of medals remaining
at (n-i)th day.


Sukhmeet,
You have to apply the formula
n = k - [(n-1) + (1/7)(k- (n-1))]
where k is taken to be the number of medals at the start of (n-1)th day.
on (n-1)th day, n-1 medals are given. Then (k - (n-1)) medals are left.
1/7 of these are given away as well.
So after (n-1) days  the medals left are given by RHS of the equation which
is equal to n - the medals left which are given on nth day.

Solving this equation we get:
k - (n-1) = 7/6*n

Thus, medals given away on (n-1)th day = (n-1) + (1/7)*(7/6*n) = (n-1) +
1/6*n
Similarly medals given away on (n-2)th day = (n-2) + (1/7)*(7/6*(sum of
medals given on (n-1)th and nth days))
   = (n-2) +
(1/7)*(7/6*(n-1 + 7/6*n))
   = (n-2) +
(1/6)*(n-1 + 1/6*n))

For  (n-i)th day,
medals given away = (n-i) + (1/6)*(sum of medals given away from (n-
(i-1))th to nth day)
It goes on like this till we get the term for first day.


SO total medals, m = n + [(n-1) + 1/6*n]  +  [(n-2) + (1/6)*(n-1 + 7/6*n))]
+...
Put 6 in this equation and we get the required answer m = 36


Simple formula
m = n + [(n-1) + 1/6*first term]+ [(n-2) + (1/6)*(sum of 1st and 2nd term)]+
 + [(n-i) + (1/6)*(sum of all terms till now)] + 
i goes upto 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: Construct Binary Tree From Ancestor Matrix

2011-03-30 Thread Tushar Bindal
a[i][j]=1 if 'i' is a parent to 'j'

But in your matrix,
a[1][2] = 1
a[1][3] = 1
a[2][3] = 1
a[4][2] = 1
a[4][3] = 1

You have taken 'j' to be a parent to 'i'


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com

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



Re: [algogeeks] Re: debugging contest

2011-03-26 Thread Tushar Bindal
xxx, yyy are considered as cases?

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

2011-02-19 Thread Tushar Bindal
what happened?

On Sat, Feb 19, 2011 at 7:14 PM, ankit sablok ankit4...@gmail.com wrote:

 all u fuckers please chedck into the problem


 On Sat, Feb 19, 2011 at 6:57 PM, Troika'11 by...@dcetech.com wrote:

 Play the world cup here with your codes...

 https://www.spoj.pl/BYTES11A/problems/main/

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com

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



Re: [algogeeks] Fwd: SANKALAN 2011:DUCSS Annual Technical Festival

2011-02-18 Thread Tushar Bindal
how can you send such well formatted messages on google groups???

On Fri, Feb 18, 2011 at 9:40 PM, kanika suri surfatheig...@gmail.comwrote:







   Delhi University Computer Science Society

 presents


 Sankalan 2011


 Annual Technical Festival

 on


  5th and 6th March 2011


With open arms we welcome you all.
 Come and join us in our


  celebrations.

  Lots of fun and many
 cash prizes to be won.



  Register For Techno Speak at

 technospeak2...@gmail.com



  For Further Details, Registration and Accommodation kindly visit :

 *http://cs.du.ac.in/sankalan2011*

 *
 *

 *http://twitter.com/#!/Sankalan2011
 http://www.facebook.com/home.php#!/pages/Sankalan-2011/191073857576935*

 *
 *

 Or

 You can mail to us at sankalan2...@gmail.com


 *Registration is open till 20th February 2011 for techno speak.

 *
 *

 *
 *











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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com

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



Re: [algogeeks] Fwd: SANKALAN 2011:DUCSS Annual Technical Festival

2011-02-18 Thread Tushar Bindal
don't take me wrongly.
I tried doing the same but failed.
that is why I asked.

I know this is not the place to taunt anyone.

On Sat, Feb 19, 2011 at 12:09 AM, kanika suri surfatheig...@gmail.comwrote:

 u r really askin d way to format dis kinda msg or its a taunt?..If it is
 den i would say its jus a promotional activity. We thot here ppl discuss on
 technical topics so it wud b gr8 to enlighten ppl vd such fest whr ppl
 compete n exchange knowledge.

 Sorry if we broke ne rule for the group.


 On Fri, Feb 18, 2011 at 11:57 PM, Tushar Bindal tushicom...@gmail.comwrote:

 how can you send such well formatted messages on google groups???

 On Fri, Feb 18, 2011 at 9:40 PM, kanika suri surfatheig...@gmail.comwrote:







   Delhi University Computer Science Society

 presents


 Sankalan 2011


 Annual Technical Festival

 on


  5th and 6th March 2011


With open arms we welcome you
 all. Come and join us in our


  celebrations.

  Lots of fun and
 many cash prizes to be won.



  Register For Techno Speak at

 technospeak2...@gmail.com



  For Further Details, Registration and Accommodation kindly visit :

 *http://cs.du.ac.in/sankalan2011*

 *
 *

 *http://twitter.com/#!/Sankalan2011
 http://www.facebook.com/home.php#!/pages/Sankalan-2011/191073857576935*

 *
 *

 Or

 You can mail to us at sankalan2...@gmail.com


 *Registration is open till 20th February 2011 for techno speak.

 *
 *

 *
 *











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




 --
 Tushar Bindal
 Computer Engineering
 Delhi College of Engineering
 Mob: +919818442705
 E-Mail : tusharbin...@jugadengg.com

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




 --
 regards
 kanika suri
 MCS 2nd yr
 DUCS
 University of Delhi

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com

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



[algogeeks] DCE techfest

2011-02-17 Thread Tushar Bindal
***DELHI TECHNOLOGICAL UNIVERSITY*
*(Formerly DELHI COLLEGE OF ENGINEERING)**

CSI-DTUPHOENIX'11
presents

FIREWALL*
 *The Art Of Hacking
*
*
*


Do you swear by having the key to every single lock?

Do you think you possess the innate talent of finding loopholes in anything
and everything?

Do you think you are gifted with unmatched and unparalleled skills of
getting your task done irrespective of what it takes to do so?

If your answer to all these questions is yes, then put on your Hacking Hats
as the ultimate hacking event *FIREWALL* is back again.

*FIREWALL* is an *online hacking* event that aims to bring out the budding
hacker in you and put your skills to test against the best of the brains
across the country.

And if you think you are in for loads of rules and regulations, feel
refreshed as in this event, it’s just clearing the levels that matters
regardless of the means. But remember, any sort of malicious activity would
be dealt with serious appreciation and if you think that’s it, then letting
the cat out of the bag- you’ll get bonus for indulging in such acts!

Rack your brains, make use of your tools, take help of Google: use every
single possible resource you can think of to break through the levels and do
not forget: making it to the next level is the only thing that matters.

So pull up your socks, exercise your grey cells and get ready to unleash
those honed hacking skills of yours.


Register right away at Firewall http://www.firewall.csidtu.in/register.php

Discussion 
Forumhttp://www.jugadengg.com/forum/viewforum.php?f=7sid=0e62260aa30fcade203e4b1ea1ac511f

*For more queries contact:** *Abhijeet 9654034759

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

2011-02-17 Thread Tushar
   DELHI TECHNOLOGICAL UNIVERSITY
  (Formerly DELHI COLLEGE OF ENGINEERING)

   PHOENIX'11
presents

   FIREWALL
  The Art Of
Hacking



Do you swear by having the key to every single lock?

Do you think you possess the innate talent of finding loopholes in
anything and everything?

Do you think you are gifted with unmatched and unparalleled skills of
getting your task done irrespective of what it takes to do so?

If your answer to all these questions is yes, then put on your Hacking
Hats as the ultimate hacking event FIREWALL is back again.

FIREWALL is an online hacking event that aims to bring out the budding
hacker in you and put your skills to test against the best of the
brains across the country.

And if you think you are in for loads of rules and regulations, feel
refreshed as in this event, it’s just clearing the levels that matters
regardless of the means. But remember, any sort of malicious activity
would be dealt with serious appreciation and if you think that’s it,
then letting the cat out of the bag- you’ll get bonus for indulging in
such acts!

Rack your brains, make use of your tools, take help of Google: use
every single possible resource you can think of to break through the
levels and do not forget: making it to the next level is the only
thing that matters.

So pull up your socks, exercise your grey cells and get ready to
unleash those honed hacking skills of yours.


Register right away at http://www.firewall.csidtu.in/register.php

Discussion Forum - goo.gl/pVJkv

For more queries contact: Abhijeet 9654034759

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

2011-02-14 Thread Tushar Bindal
It would be
*vertcal_sum(root-right,level+1);
*in the last line


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com

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



Re: [algogeeks] Special Binary Tree Again

2011-02-14 Thread Tushar Bindal
I think the following algo should work:
1. Create a DLL of the inorder traversal of the tree
2. for each node, check whether P of that node points to the previous node
in the DLL or not.
3. If not, assign it value NULL



-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com

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



Re: [algogeeks] interview quest..

2011-02-14 Thread Tushar Bindal
if we have RBGGGBGGBR
what should be the answer???
RBGR or (empty string)

On Mon, Feb 7, 2011 at 3:51 PM, rajan goswami rajan.goswam...@gmail.comwrote:

 yeh.
 Agree with ramkumar.
 Simplest solution is to use Stack...


 On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao abhijitkrao...@gmail.comwrote:

 I could not get it for recursively, but iteratively, I coded a solution.
 If anyone knows recursively,
 let us know please.

 #includestdio.h
 void main()
 {
  char s[18]=DGGDBCBHH;
  int i=0,j=0;
  int count;
  while(s[i]!='\0')
  {
   if(s[i] == s[i+1])
   {
   count = strlen(s)-2;
   while(count--)
   {
s[i]=s[i + 2];
i++;
   }
   s[i]='\0';
   i=0;
   }
  else
  {
  i++;
  }
  }
  printf(%s,s);
  getch();
 }


 I/P:  DGGDBCBHH  O/P: BCB

 Best Regards
 Abhijit



 On Sun, Feb 6, 2011 at 1:47 PM, ramkumar santhanam 
 ramkumars@gmail.com wrote:

 use stack.

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com

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



Re: [algogeeks] Re: Meetings puzzle

2011-02-09 Thread Tushar Bindal
what are f1, f2, f3,...?

On Wed, Feb 9, 2011 at 5:05 PM, Ujjwal Raj ujjwal@gmail.com wrote:

 Input: n meetings
 A meeting e(i) has start time s(i) and finish time f(i).
 Sort n events based on there finish time f(i)
 Say sorted meeting(based on finishing time) are:
 e1,e2,e3,e4,...en

 E(t): denotes the maximum no of meetings conducted where 0 = time = t.

 E(f1) = e1
 E(f2) = max(E(s2) + 1), E(f1));
 E(f3) = max(E(s3)+1), E(f2));

 Make array of E based on finishing times.
 So your array will have values of E at different finishing times
 f1 E1
 f2, E2
 f3 E3
 f4 E4

 so E2 means maximum no of events between time = f2 and  f3.

 Hope it is now clear.


 On Wed, Feb 9, 2011 at 12:59 PM, Sachin Agarwal sachinagarwa...@gmail.com
  wrote:

 didn't quite get it, can you please elaborate.
 thanks

 On Feb 8, 10:38 pm, Ujjwal Raj ujjwal@gmail.com wrote:
  Use dynamic programming:
  1) Sort the events in order of finishing time.
  f1, f2, f3, f4, ... fn
 
  E(fn) = E(sn) + 1;
  Solve the above recursion
  sn is start time of event n
 
  On Wed, Feb 9, 2011 at 11:30 AM, Sachin Agarwal
  sachinagarwa...@gmail.comwrote:
 
 
 
 
 
 
 
   Suppose I have a room and I want to schedule meetings in it. You're
   given a list of meeting start and end times. Find a way to schedule
   the maximum number of meetings in the room.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com

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



Re: [algogeeks] no. of passwords

2011-02-09 Thread Tushar Bindal
Are all the selected letters or numbers always different?
If they can also be same then answer would be different.

On Wed, Feb 9, 2011 at 7:20 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 is it
 26C3 * 26C3 * 10C2 * 62C2 * 10!


 On Wed, Feb 9, 2011 at 7:16 PM, snehal jain learner@gmail.com wrote:

 how many passwords can be made if
 1. there should be atleast 3 capital letters
 2. atleast 3 small letters
 3. atleast 2 numbers 0-9
 4 the password should has length=10

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




 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee

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




-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com

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



[algogeeks] Re: Meetings puzzle

2011-02-09 Thread Tushar
sorry.
did not go thru it thoroughly earlier.
got it now.

On Feb 9, 7:35 pm, Tushar Bindal tushicom...@gmail.com wrote:
 what are f1, f2, f3,...?



 On Wed, Feb 9, 2011 at 5:05 PM, Ujjwal Raj ujjwal@gmail.com wrote:
  Input: n meetings
  A meeting e(i) has start time s(i) and finish time f(i).
  Sort n events based on there finish time f(i)
  Say sorted meeting(based on finishing time) are:
  e1,e2,e3,e4,...en

  E(t): denotes the maximum no of meetings conducted where 0 = time = t.

  E(f1) = e1
  E(f2) = max(E(s2) + 1), E(f1));
  E(f3) = max(E(s3)+1), E(f2));

  Make array of E based on finishing times.
  So your array will have values of E at different finishing times
  f1 E1
  f2, E2
  f3 E3
  f4 E4

  so E2 means maximum no of events between time = f2 and  f3.

  Hope it is now clear.

  On Wed, Feb 9, 2011 at 12:59 PM, Sachin Agarwal sachinagarwa...@gmail.com
   wrote:

  didn't quite get it, can you please elaborate.
  thanks

  On Feb 8, 10:38 pm, Ujjwal Raj ujjwal@gmail.com wrote:
   Use dynamic programming:
   1) Sort the events in order of finishing time.
   f1, f2, f3, f4, ... fn

   E(fn) = E(sn) + 1;
   Solve the above recursion
   sn is start time of event n

   On Wed, Feb 9, 2011 at 11:30 AM, Sachin Agarwal
   sachinagarwa...@gmail.comwrote:

Suppose I have a room and I want to schedule meetings in it. You're
given a list of meeting start and end times. Find a way to schedule
the maximum number of meetings in the room.

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

 --
 Tushar Bindal
 Computer Engineering
 Delhi College of Engineering
 Mob:+919818442705begin_of_the_skype_highlighting+919818442705  end_of_the_skype_highlighting
 E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com

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



Re: [algogeeks] Re: Frequently one of the Top Question Asked in Amazon

2011-01-31 Thread Tushar Bindal
bittu,

you have written this code at end of main()

*printGivenOrder(start);

printList(rslt);*

so the BT in spiral order should be printed twice
But you are getting a extra 4 only in place of the whole tree because of
these lines

*temp=current;
current=head;

rslt=appnd(temp,current);

* There is an error in this code. you should assign *temp=rslt* so that
current is added to the
DLL rslt. In your code, it just assigns current to rslt whereas it should
append current to rslt.
That is why in the end 4 is assigned to rslt and it is the final value of
rslt.

So please make it:

*temp=rslt;
current=head;

rslt=appnd(temp,current);*

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

2011-01-06 Thread Tushar Bindal
Is it necessary that the two lists are merging at their ends??
Do we have to find whether they merge at the end into same lists or wheter
they are just intersecting??


On Thu, Jan 6, 2011 at 10:04 PM, Aditya adit.sh...@gmail.com wrote:

  There are two aspects here for second question.
 1. to find if the common node exist (ie the lists are merging) with out the
 limitation of length available.
 2. To find the merging node.



 On 1/6/2011 8:49 PM, Naveen Kumar wrote:

 @ Vishal,
 I think question says that its merging at a point.
 But anyway can you tell me how to detect cycle in this case.

 On Thu, Jan 6, 2011 at 7:57 PM, vishal raja vishal.ge...@gmail.comwrote:

 @aditya,
 Who said it's a Y shaped structure, It can very well has a cycle.
 Assume the case when the last node is not pointing to NULL but to a node
 in the list.



 On Thu, Jan 6, 2011 at 7:45 PM, ADITYA KUMAR aditya...@gmail.com wrote:

 @vishal
 saurabh is right
 its merging at only one point its a Y-shaped structure



 On Thu, Jan 6, 2011 at 7:29 PM, vishal raja vishal.ge...@gmail.comwrote:


 @sourabh,
 In addition to your solution, If there is any cycle(loop) exist in the
 link list your algo will fail.
 To solve this problem first detect this cycle if there is any and count
 the element in the cycle, and then you can do the mathematics.



 On Thu, Jan 6, 2011 at 6:51 PM, sourabh jakhar sourabhjak...@gmail.com
  wrote:

 for second question calculate the difference in length of two linked
 list.
 and than shift the head of longest linked list to the calculated
 difference. while the head of shorest is at the first node of that linked
 list.
 Than iterate both to see if info is equal and that is the merging
 point.
 complexity-o(n).
 hope this help


 On Thu, Jan 6, 2011 at 6:48 PM, juver++ avpostni...@gmail.com wrote:

 Yes, but recursion stack's size is limited instead of iterative
 version.
  --
 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.comalgogeeks%2bunsubscr...@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 algoge...@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.


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




 --
  Regards
 Aditya Kumar
 B-tech 3rd year
 Computer Science  Engg.
 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 algoge...@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.


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




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


 --
 Regards Aditya

 --
 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.comalgogeeks%2bunsubscr...@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] Re: Single linked list questions.

2011-01-06 Thread Tushar Bindal
I agree
But my doubt is that whether we have to find that they just have their last
node as common or they can have many nodes common(which I was calling
intersecting)

On Thu, Jan 6, 2011 at 11:07 PM, Naveen Kumar naveenkumarve...@gmail.comwrote:

 How can two list just intersect, each node can have one pointer to the
 next. So, if they intersect they will definitely be merging.

 On Thu, Jan 6, 2011 at 11:01 PM, Tushar Bindal tushicom...@gmail.comwrote:

 Is it necessary that the two lists are merging at their ends??
 Do we have to find whether they merge at the end into same lists or wheter
 they are just intersecting??



 On Thu, Jan 6, 2011 at 10:04 PM, Aditya adit.sh...@gmail.com wrote:

  There are two aspects here for second question.
 1. to find if the common node exist (ie the lists are merging) with out
 the limitation of length available.
 2. To find the merging node.



 On 1/6/2011 8:49 PM, Naveen Kumar wrote:

 @ Vishal,
 I think question says that its merging at a point.
 But anyway can you tell me how to detect cycle in this case.

 On Thu, Jan 6, 2011 at 7:57 PM, vishal raja vishal.ge...@gmail.comwrote:

 @aditya,
 Who said it's a Y shaped structure, It can very well has a cycle.
 Assume the case when the last node is not pointing to NULL but to a node
 in the list.



 On Thu, Jan 6, 2011 at 7:45 PM, ADITYA KUMAR aditya...@gmail.comwrote:

 @vishal
 saurabh is right
 its merging at only one point its a Y-shaped structure



 On Thu, Jan 6, 2011 at 7:29 PM, vishal raja vishal.ge...@gmail.comwrote:


 @sourabh,
 In addition to your solution, If there is any cycle(loop) exist in the
 link list your algo will fail.
 To solve this problem first detect this cycle if there is any and
 count the element in the cycle, and then you can do the mathematics.



 On Thu, Jan 6, 2011 at 6:51 PM, sourabh jakhar 
 sourabhjak...@gmail.com wrote:

 for second question calculate the difference in length of two linked
 list.
 and than shift the head of longest linked list to the calculated
 difference. while the head of shorest is at the first node of that 
 linked
 list.
 Than iterate both to see if info is equal and that is the merging
 point.
 complexity-o(n).
 hope this help


 On Thu, Jan 6, 2011 at 6:48 PM, juver++ avpostni...@gmail.comwrote:

 Yes, but recursion stack's size is limited instead of iterative
 version.
  --
 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.comalgogeeks%2bunsubscr...@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 algoge...@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.


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




 --
  Regards
 Aditya Kumar
 B-tech 3rd year
 Computer Science  Engg.
 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 algoge...@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.


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




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


 --
 Regards Aditya

 --
 You received

[algogeeks] Recaman's sequence

2009-12-02 Thread Tushar Ghosh
Hi, Well
Recaman's sequence is defined by: a(0) = 0
   a(k) = a(k-1) -
k, k0, a(k) new term in series or else a(k-1) + k

So sequence is 0, 1, 3,6, 2, 7, 13, 20, 12, 21, 11, 22, 10,
23,
My approach used memoization using map in c++ (giving O(n) time and
memory for generating sequence), but I somehow feel that there can be
a better approach to check if a term already exists in the sequence.
Any suggestion would be gratefully acknowledged.

Regards,
Tushar

--

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] Shaastra Online Programming Contest

2008-09-12 Thread Tushar Rathee

Hi

Shaastra is the annual technical festival of IIT Madras. Like every
year, Shaastra 2008 has an online programming contest in which anyone
can participate. The event registrations has started on the site
http://www.shaastra.org/2008/Events/OPC

The Shaastra Online Programming Contest gets hundreds of participants
from all over the world. The total prize money at stake is INR
70,000.

Other than this, there are several other programming contests. Please
visit www.shaastra.org for more details.

Regards

Tushar Rathee
Publicity Core
Shaastra 2008
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the 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
-~--~~~~--~~--~--~---