Re: [algogeeks] Sub-array problem

2011-11-29 Thread Nitin Garg
cant think of anything better than O(N^2). Are you sure there exists such
algo?

On Tue, Nov 29, 2011 at 2:55 AM, Mohit kumar lal kumarmohit...@gmail.comwrote:

 Given a array of positive integers ,You have to find the largest sum
 possible from consecutive sub-array but sum should be less than or equal to
 K and also find that sub-array. Ex- array={2,1,3,4,5} k=12,
  ans-12, sub-array={3,4,5}

 Firstly i tried with brute-force and then i also tried to solve it by DP
 but complexity were same ( O(n^2)) so plz try to provide a solution for
 O(nlgn) or O(n).

 --
 Mohit kumar lal

 IIIT ALLAHABAD

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-29 Thread Nitin Garg
*What are the different ways to say, the value of x can be either a 0 or a
1.*


-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-28 Thread Nitin Garg
 of all the expected
 values
   for the
  elements selected from each subarray is maximum.
 
  You can assume that n is a power of 2.
 
  Example:
 
  Array: [0,0,1,1,0,0,1,1,0,1,1,0]
  n = 12
  k = 3
  Size of subarrays can be: 2,3,4,5,6
 
  Possible subarrays [0,0,1] [1,0,0,1] [1,0,1,1,0]
  Expected Value of the sum of the elements randomly selected
 from the
   subarrays: 1/3 + 2/4 + 3/5 = 43/30 ~ 1.433
 
  Optimal split: [0,0,1,1,0,0][1,1][0,1,1,0]
  Expected value of optimal split: 1/3 + 1 + 1/2 = 11/6 ~
 1.8333
 
  Source -
  http://stackoverflow.com/questions/8189334/google-combinatorial-optim.
 ..
 
   --
  You received this message because you are subscribed to the
 Google
   Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com
 .
  To unsubscribe from 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.




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-28 Thread Nitin Garg
Please clarify. Also tell offcampus interview for which company?

On Mon, Nov 28, 2011 at 7:10 PM, Siddharth Pipriya sid@gmail.comwrote:

 write a program that takes as input a number x and gives output true x
 percent of the time it is run.

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-28 Thread Nitin Garg
Lets say the in-order traversal is O =  O1,O2,...On
Pre-order is P = P1,P2,...Pn

Lets assume that the in-order traversal gives sorted sequence of numbers.
(if not, we can replace Pi by i in our algorithm and replace it to original
later on)

Observe P1 will be the root.
If left subtree is not empty, then P2 is the root of left subtree.
Otherwise it is the root of right subtree.
If left subtree is non empty, how can we find what is the root of right
subtree?

A[i,j] - returns pointer to root of the tree containing elements from Pi to
Pj in order as we want them in our resultant tree.

Algorithm - A[i,j,r1,r2]

IF i==j return Pi
ELSE
1. make Pi the root.
2. Binary search in P[i+1,j] to find out the last element Pk which is on
left side of Pi in O[r1,r2] where Or = Pi.
3.a.  if(!k) S1 = empty S2 = A[2,n,r1,r1,r-1]
3.b . else S1 = A[2,k], S2 = A[k+1,n,r+1,r2]
4. make S1 left child of P1 and S2 the right child of P1.



Rec for running time
T(n) = 2*T(n/2) + O(logn)

It is linear.



On Sun, Nov 27, 2011 at 8:26 PM, bharath sriram bharath.sri...@gmail.comwrote:

 The in-order and pre-order traversal are already given. So, there is no
 way to do what you are saying if I understand you completely.


 On Sun, Nov 27, 2011 at 8:19 AM, Ankuj Gupta ankuj2...@gmail.com wrote:

 Hint : try with prestoring the preorder traversal element position in
 inorder traversal before constructing the tree

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-28 Thread Nitin Garg
A[1,n,1,n] will give us the solution.

On Mon, Nov 28, 2011 at 7:47 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Lets say the in-order traversal is O =  O1,O2,...On
 Pre-order is P = P1,P2,...Pn

 Lets assume that the in-order traversal gives sorted sequence of numbers.
 (if not, we can replace Pi by i in our algorithm and replace it to original
 later on)

 Observe P1 will be the root.
 If left subtree is not empty, then P2 is the root of left subtree.
 Otherwise it is the root of right subtree.
 If left subtree is non empty, how can we find what is the root of right
 subtree?

 A[i,j] - returns pointer to root of the tree containing elements from Pi
 to Pj in order as we want them in our resultant tree.

 Algorithm - A[i,j,r1,r2]

 IF i==j return Pi
 ELSE
 1. make Pi the root.
 2. Binary search in P[i+1,j] to find out the last element Pk which is on
 left side of Pi in O[r1,r2] where Or = Pi.
 3.a.  if(!k) S1 = empty S2 = A[2,n,r1,r1,r-1]
 3.b . else S1 = A[2,k], S2 = A[k+1,n,r+1,r2]
 4. make S1 left child of P1 and S2 the right child of P1.



 Rec for running time
 T(n) = 2*T(n/2) + O(logn)

 It is linear.



 On Sun, Nov 27, 2011 at 8:26 PM, bharath sriram 
 bharath.sri...@gmail.comwrote:

 The in-order and pre-order traversal are already given. So, there is no
 way to do what you are saying if I understand you completely.


 On Sun, Nov 27, 2011 at 8:19 AM, Ankuj Gupta ankuj2...@gmail.com wrote:

 Hint : try with prestoring the preorder traversal element position in
 inorder traversal before constructing the tree

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




 --
 Nitin Garg

 Personality can open doors, but only Character can keep them open




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-28 Thread Nitin Garg
 Find the min and max in an array. Now do it in less than 2n comparisons.
(they were looking for the solution that finds both max and min in about
3/2 n comparisons).


-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-26 Thread Nitin Garg
Hi Guys
I saw this question
http://stackoverflow.com/questions/8189334/google-combinatorial-optimization-interview-problm
But couldn't get the solution which has been accepted, nor could work out
one on my own.
Please help!

-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] Re: Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted

2011-11-24 Thread Nitin Garg
Struct tuple
{int s;int e;}

tuple findsubarray(Array input)
{
int i=0, j=input.length()-1;

while(input[i]  input[i+1])
i++;

if(i==j) return NULL // array already sorted

while(input[j-1]  input[j])
j--;

// now the subarrays from 0 to i is sorted and  j to end is sorted.

int min = min(input(i+1,j-1));
int max = max(input(i+1,j-1));

while(input[i]min  i0)
 i--;

while(input[j]max  jinput.size()-1)
j++;

return (i,j);
}


On Thu, Nov 24, 2011 at 6:09 PM, vikas vikas.rastogi2...@gmail.com wrote:

 char arr[] = {'a', 'b', 'e', 'f', 'd', 'g', 'h', 'i'};

 calculate the point where array is not sorted , in this case arr[4] =
 'd'
 calulate k in array[5..n] such that k  4 arr[k]  d  , take the min =
 min{ arr[k] }
 same thing for max from reverse
 use quick /selection sort to identify the correct insertion indices of
 min/max, that will be answer.
 complexity O(n)

 On Nov 24, 2:06 pm, Ankuj Gupta ankuj2...@gmail.com wrote:
  Given an unsorted array arr[0..n-1] of size n, find the minimum length
  subarray arr[s..e] such that sorting this subarray makes the whole
  array sorted.

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-24 Thread Nitin Garg
Please explain what do you mean by 'path between x and z'.

On Wed, Nov 23, 2011 at 11:46 PM, Ankuj Gupta ankuj2...@gmail.com wrote:

 There is a binary tree (Not a BST) in which you are given three nodes
 X,Y, and Z .Write a function which finds whether y lies in the path b/
 w x and z.

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-24 Thread Nitin Garg
.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Anup Ghatage
 
   --
  You received this message because you are subscribed to the
 Google
Groups
  Algorithm Geeks group.
  To post to this group, send email to
 algogeeks@googlegroups.com.
  To unsubscribe from 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*
  *The Coder*
 
  *Life is a Game. The more u play, the more u win, the more u
 win , the
  more successfully u play*
 
   --
  You received this message because you are subscribed to the
 Google
Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com
 .
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 --
 Aamir Khan | 3rd Year  | Computer Science  Engineering | IIT
 Roorkee
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.

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


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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-11-24 Thread Nitin Garg
I don't think it can be done in better than O(n) space and time.

On Tue, Nov 22, 2011 at 9:28 PM, himanshu kansal 
himanshukansal...@gmail.com wrote:

 @SAM: in your first step, where you are xoring the unique elements, you
 must be using some DS such as hashtable or something.

 so space complexity will be O(n).

 can someone reduces this O(n) space complexity.because it wont be a
 good approach if there are many elements in the array


 On Fri, Nov 18, 2011 at 9:26 AM, SAMM somnath.nit...@gmail.com wrote:

 On 11/18/11, SAMM somnath.nit...@gmail.com wrote:
  For example the array has ..
  1 4 2 6 7 4 8 3..
  xor the elements in the array will give (1^2^6^7^8^3).
 
  now xor the unique elements using hash table ,It gives (1^4^2^6^7^8^3).
  Now xor these two value which gives 4.
 
  On 11/18/11, Dave dave_and_da...@juno.com wrote:
  @SAMM: It sounds like a circular argument. How do you XOR all of the
  unique elements without first finding the repeated ones?
 
  Dave
 
  On Nov 17, 11:24 am, SAMM somnath.nit...@gmail.com wrote:
  Yes we can do so in O(n) .
 
  First find the XOR of all unique elements  using hash table or some
  other
  DS.
  Secondly XOR  all the elements of the array .which will hav the xor of
  elements other thn the element repeated twice.
 
  Now XOR the above two value which will give the answer..
 
  On 11/17/11, himanshu kansal himanshukansal...@gmail.com wrote:
 
 
 
 
 
   consider an array having n elements.out of which one number is
   repeated twiceother number are repeated odd number of times(for
   simplicity, assume other numbers are occurring just once)
 
   can you find the number that is repeated twice in O(n) time???
 
   PS: numbers are not from a particular range.
 
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Somnath Singh
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Somnath Singh
 


 --
 Somnath Singh

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




 --

Regards
  Himanshu Kansal
Msc Comp. sc.
 (University of Delhi)


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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] Amazon Question

2011-11-14 Thread Nitin Garg
@surendra - converse is not true.
aabbcc will be reduced 2.
aabbcc can be reduced to acbcc
acbcc has unequal number of a's,b's and c's. Hence it should be reducable
to 1.


On Sun, Nov 13, 2011 at 3:42 PM, Anika Jain anika.jai...@gmail.com wrote:

 its coming out be either 1 or 2 in all cases


 On Sun, Nov 13, 2011 at 1:55 PM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:

 @Surinder give some proof or logic


 On Sun, Nov 13, 2011 at 10:25 AM, surender sanke surend...@gmail.comwrote:

 @nitin
 yes i meant the same, if each different character have equal number of
 frequency like abcabcabc  a's -3, b's - 3 c's- 3
 then resultant string size is 2 else 1

 surender


 On Sun, Nov 13, 2011 at 12:21 AM, Ankur Garg ankurga...@gmail.comwrote:

 @Srinivas

 Wat if the string is abc
 then it reduces to cc :) ...So  size 2 can also be there.so u cant say
 it will be 1 always


 On Sun, Nov 13, 2011 at 12:01 AM, Srinivasa Chaitanya T 
 tschaitanya@gmail.com wrote:



 On Sat, Nov 12, 2011 at 4:24 PM, Snoopy Me thesnoop...@gmail.comwrote:

 Given a string consisting of a,b and c's, we can perform the
 following
 operation:
  Take any two adjacent distinct characters and replace it with the
 third character. For example, if 'a' and 'c' are adjacent, they can
 replaced with 'b'.
 What is the smallest string which can result by applying this
 operation repeatedly?

 1) if the string a..aaa, or bb..bb, etc... string cannot be
 modified
 2) if string starts with ac = this can be reduced to b -
 aaac - aab - ac - b
 3) So if string not of type (1), then it can be reduced to single
 character always using  method 2
e.g:
   *aab*cacaab // first reduce aab to b
   *bbc*acaab  // reduce bbc to c
   *ca*caab
   *bc*aab
   *aaab*
   c
 .. i guess u got the idea





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




 --
 T Srinivasa Chaitanya


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




 --
 *UTKARSH SRIVASTAV
 CSE-3
 B-Tech 3rd 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.


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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] Amazon Question

2011-11-12 Thread Nitin Garg
If yes, how do you prove it?

On Sat, Nov 12, 2011 at 8:18 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 I can prove that the size of resulting string will be 1 or 2.

 @surender -
 what do you mean by no of distinct characters? they are 3 in this case -
 a,b and c.
 Do you mean to say that the no. of times each character appears are equal
 then the final string is of size 2. and 1 otherwise?


 On Sat, Nov 12, 2011 at 4:57 PM, surender sanke surend...@gmail.comwrote:

 @myself

 if number of distinct characters are equal then its final string size is
 2.
 else there are more repeated characters other than distinct characters
 then its 1

  correct me !!!
 surender

 On Sat, Nov 12, 2011 at 4:46 PM, surender sanke surend...@gmail.comwrote:

 All distinct combinations will result in string size of 2 + rest
 repeated characters
 eg
 abcabcabc -aabbcc-abc-aa or bb or cc

 surender

 On Sat, Nov 12, 2011 at 4:24 PM, Snoopy Me thesnoop...@gmail.comwrote:

 Given a string consisting of a,b and c's, we can perform the
 following
 operation:
  Take any two adjacent distinct characters and replace it with the
 third character. For example, if 'a' and 'c' are adjacent, they can
 replaced with 'b'.
 What is the smallest string which can result by applying this
 operation repeatedly?

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




 --
 Nitin Garg

 Personality can open doors, but only Character can keep them open




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-10-29 Thread Nitin Garg
Total possible 9 digit numbers = 10^9  2^32
We have = 3 X 10^8 numbers  2^32

notice that if we observe only 16 msb of social security numbers, we will
have atleast one combination (of the 16 most significant bits) which will
occur less that 2^16 times.


   1. Now with this, we build an array A of 2^16 integers (indexed on the 16
   msb) in RAM, initialized to 0. (2^16 X 4 bytes = 256 KB)
   2. Scan the hard disk containing social security numbers. for each social
   sec number X,  do A[X16] ++
   3. now find out i such that A[i]  2^16. Call this as M = i
   4. Now we know that for the 16 msb of M  we have atleast one combination
   of 16 lsb such that the number is absent.
   5. build a bit array B of size 2^16, initlialized to 0
   6. rescan the hard disk and whenever you find an X such that X16 = M,
   do B[(X16)16] = 1
   7. Now scan the bitarray B to find i such that B[i] = 0. Call this as N =
   i;


Q = N bitwise or M is one missing element.


Done in 2 scans.


On Sat, Oct 29, 2011 at 11:46 PM, Arun Vishwanathan
aaron.nar...@gmail.comwrote:

 can someone give me a short explanation of Dave solution? I understand that
 a[n%10]  1 is trying to find the bin which has less than what
 maximum numbers it can hold and the bin is such that all numbers counted in
 this have the same remainder when divided by 10. I do not get the
 a[n/10] part after that ..wat is that trying to say?



 On Sat, Oct 29, 2011 at 10:42 AM, yq Zhang zhangyunq...@gmail.com wrote:

 Given the SSN number is 9 digit number, the total space of possible
 numbers are 1000million. So I think Dave's solution works.


 On Sat, Oct 29, 2011 at 8:47 AM, bharat b 
 bagana.bharatku...@gmail.comwrote:

 @Dave
 Your solution works if the total no.of records(ssn numbers) is 1000
 million.
 But the question states that there are only 300 million numbers.

 I think some modification is needed to your answer.
 Correct me if i am wrong.



 On Fri, Oct 28, 2011 at 2:04 AM, Dave dave_and_da...@juno.com wrote:

 @Shiva: Using an integer array a[10], initialized to 0, read
 through the file and for each number n, increment a[n%10]. At the
 end of the file, find any k such that a[k] != 1. Then read through
 the file again. For any number n such that n%10 == k, set a[n/
 10] = -1. At the end of file, find any j  1 such that a[j] =
 0. Then 10 * j + k is a number that is missing from the file.

 Dave

 On Oct 27, 10:25 am, shiva@Algo shiv.jays...@gmail.com wrote:
  Given a file containing roughly 300 million social security
  numbers(9-digit numbers), find a 9-digit number that is not in the
 file.
  You have unlimited drive space but only 2megabytes of RAM at your
  disposal.

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




 --
  People often say that motivation doesn't last. Well, neither does
 bathing - that's why we recommend it daily.

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] What Data Structure to use ?

2011-10-29 Thread Nitin Garg
Assuming students and courses have unique integer ids.

Use an adjacency list kind of data structure. Where the location of the
student/course in the list can be decided by hashing.

Essentially, there will be 3 hash tables,
1. To store student objects. Key - student id, value- student object.
2. To store course objects. Key - course id, value- course object.
3. to store relationships. Key - student-id/course-id. Values corresponding
student-ids/course-ids. Multiple values will belong to a key and they will
be stored as linked list.

queries a and b can be easily answered by just returning all values from
hash table 1 or 2.
hash table 3 will optimize queries c and d.
On Sun, Oct 30, 2011 at 1:17 AM, Aamir Khan ak4u2...@gmail.com wrote:

 In a university, students can enroll in different courses. A student may
 enroll for more than one course. Both students and courses can be
 identified by IDs given to them. Design a data structure to store
 students, courses, and the student-course relationships. You can use arrays,
 lists, stacks, trees, graphs, etc. or come up with your own data structures.
 Give the running times, in Big O notation, for the following operations
 for your data structure and justify the answers:

 a) Return all students in a list.
 b) Return all courses in a list.
 c) Return all courses in a list for a given student.
 d) Return all students in a list for a given course.





 Aamir Khan | 3rd Year  | Computer Science  Engineering | IIT 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.




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-10-28 Thread Nitin Garg
The hashing solution is similar to the 1st answer
herehttp://stackoverflow.com/questions/2932979/find-a-common-element-within-n-arrays

A sorting solution will take O(k.n.logn)  time



On Fri, Oct 28, 2011 at 9:51 AM, Anup Ghatage ghat...@gmail.com wrote:

 Don,
 As you said, the intersection set, won't really be in sorted order as it
 depends on the elements of the second array, which are unsorted. Still,
 sorting them wouldn't be much different as it'd be worst case O(n logn).. [
 Array 2 == Array 1 ]
 But sorting the First Array has already cost O(n logn)

 So I guess the worse case complexity has to be O(n logn) anyway..


 On Thu, Oct 27, 2011 at 10:54 PM, Dan dant...@aol.com wrote:

 Hashing all of the K arrays seems like a bit much.   How about this?

 You have  K  seperate arrays to start with,  each array having N
 elements (is that correct?).

 1)  Sort the first array.

 2)  Step through the 2nd array, 1 element at a time  say
 Array(2).element(i)
 Check to see if the value of  Array(2).element(i) is in the first
 sorted array.
 If it is,  add this numeric value to your list of  intersection
 elements.

 As you pass through all elements of the 2nd array,  the values
 found which
 are intersecting need to be saved  ( maybe in the 1st arrays
 space to save
  memory).   Ideally, these should be saved in sorted order as
 they are found.

 ( how you store the sorted array will affect speed of this check
 of course.
   I'd keep it simple on the 1st round, then optimize the code
 once everything
   appears to be working well, ie with buckets or pointers or
 whatever.  How
   you determine if an element in array 2 intersects with an
 element of array
   1 will depend on how you store your sorted array.  You might do
 a linear
   search or a binary search or a bucket search of some sort ).

 3)  Now...  step through the 3rd array,  1 element at a time,  looking
 to see if each
value is in the  just created  list  of   intersection elements

 4)  Do the save thing now with each of the remaining original K
 arrays.

 Dan:-)



 On Oct 24, 10:17 pm, kumar raja rajkumar.cs...@gmail.com wrote:
   Find intersection of K unsorted array of N elements each. Intersection
  consists of elements that appear in all the K arrays.
 
  what data structure is useful here??
 
  --
  Regards
  Kumar Raja
  M.Tech(SIT)
  IIT Kharagpur,
  10it60...@iitkgp.ac.in

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




 --
 Anup Ghatage

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] Re: Find all possible combination of integers for a given sum

2011-10-27 Thread Nitin Garg
Are we talking about only positive integers here?

On Wed, Oct 26, 2011 at 11:33 PM, Vaibhav Mittal
vaibhavmitta...@gmail.comwrote:

 +1 Prem
 @ligerdave : I knew about the recursion method..but can u throw some light
 on the pointer based method..(with a small example maybe)..
 Specifically I wanted to know the implementation part and the running time
 of the algorithm.


 On Wed, Oct 26, 2011 at 8:33 PM, ligerdave david.c...@gmail.com wrote:

 @meng You already have the pattern figured out. each time subtract 1
 from the lowest digit and add to higher digit(only once), until the
 lowest digit equals to closest higher digit. the selection of which
 number to start could be figured out with given parameters sum and
 combination

 @Prem, no recursion needed here. it make it more complex than
 necessary. one loop with a pointer should be able to resolve this

 On Oct 24, 6:28 pm, Meng Yan mengyan.fu...@gmail.com wrote:
  Hi, my question is
 
  given sum=N and combination constraint=M (the number of elements), how
 to
  find all possible combinations of integers?
 
  For example, given sum=6, combination=3; how to get the result as
 following:
  1+1+4;
  1+2+3;
  2+2+2;
 
  We don't care about order of the elements, which means 1+1+4 and 1+4+1
 are
  considered as same combination.
 
  Thanks a lot!
 
  Meng

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] Amazon Onsite

2011-10-24 Thread Nitin Garg
Lets say the Amount of petrol is Pi and distance to next petrol pump is Di
for ith petrol pump.

start from i=1, j=1 S =0
while (i=n)
  S += Pj - Dj;
  if S = 0  j = i-1 return i
  if S  0  j = i-1 return 0
  else if S = 0 j++ mod n;
  else  if S  0  j ++ mod n, i = j , S = 0;

return 0



it will traverse atmost twice, and hence O(n). no extra space required.


On Mon, Oct 24, 2011 at 4:06 AM, Aniket aniket...@gmail.com wrote:

 Suppose there is a circle. You have five points on that circle. Each
 point corresponds to a petrol pump. You are given two sets of data.

 1. The amount of petrol that petrol pump will give.
 2. Distance from that petrol pump to the next petrol pump.

 (Assume for 1 lit Petrol the truck will go 1 km)

 Now calculate the first point from where a truck will be able to
 complete the circle.
 (The truck will stop at each petrol pump and it has infinite
 capacity).
 Give o(n) solution. You may use o(n) extra space.

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-10-06 Thread Nitin Nizhawan
hi,

   given a tree with N nodes find the node such that its average total
distance from each other node is smallest

   i.e.  if nodes are labeled 0N-1 then
 find i such that[ SUM d(i, j ){0=jN}] /N  is minimum


NOTE: This is different from the classic problem of finding tree center
where tree center is the node such that its maximum distance to other nodes
is minmum

   this must be done is O(n) time and O(n) space

sample input :  an integer array Tree with N elements where each element
T[a]=b represents an edge (a,b) when a!=b

 Tree[]={14,9,11,16,14,0,11,6,14,11,3 ,16,13,17,12, 1, 5,17}

correct answer is 16.


My solution was to find (SUM(i,j) {0=jN})/N for any one value of i using
dfs then find it for other is value of i's by the fact that if there is an
edge in tree (a,b)
and average total distance for node a is X and then average total distance
for node be can be found in constant time as follows

if we remove the edge (a,b) from the tree then there will be two connected
components in the tree one that contains node a and other that contains node
b.
Let number of nodes in first be Na and number of nodes in second be Nb
then average total distance of node b is   =  X + Na - Nb.  Na, and Nb can
be found in linear time again using dfs for each node.

Somehow this solution gives wrong answer ,


Any Help ?

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

2011-10-06 Thread Nitin Nizhawan
 anyone?

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

2011-10-01 Thread Nitin
Can anybody tell me the procedure of amdocs and the difficulty level to
crack the company??

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



Re: [algogeeks] Amazon - array problem

2011-09-30 Thread Nitin Garg
Can we assume the output array is a new array and we can distort the
originial array???


On Fri, Sep 30, 2011 at 9:14 AM, praveen raj praveen0...@gmail.com wrote:

 Take two array... one will take care of left products... and othr will take
 care of right product.. at any index left[i]=A[i-1]*left[i-1]  starting
 from left and right[i]= A[i+1]*right[i+1] starting frm right……

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] Amazon - array problem

2011-09-30 Thread Nitin Garg
@raju - so it means the input array should be distorted to give the output
array.
Are you sure about it? i doubt if its possible.

On Fri, Sep 30, 2011 at 11:24 PM, raju nikutel...@gmail.com wrote:

 @nitin ..
 Output array is not a new array ... you can do anything to input array ..

 ~raju


 On Fri, Sep 30, 2011 at 1:24 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Can we assume the output array is a new array and we can distort the
 originial array???


 On Fri, Sep 30, 2011 at 9:14 AM, praveen raj praveen0...@gmail.comwrote:

 Take two array... one will take care of left products... and othr will
 take care of right product.. at any index left[i]=A[i-1]*left[i-1]
 starting from left and right[i]= A[i+1]*right[i+1] starting frm right……

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




 --
 Nitin Garg

 Personality can open doors, but only Character can keep them open

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-09-28 Thread Nitin
I dnt know much but one of my frend got selected and they have taken 8
rounds of interviews in a joint placements of ip univ...

On Wed, Sep 28, 2011 at 5:40 PM, ravi maggon maggonr...@gmail.com wrote:

 Hey can anyone tell me about the procedure and questions of Indus Valley
 Partners??

 --
 Regards
 Ravi Maggon
 B.E. CSE, Final Year
 Thapar University

 www.algorithmguru.com

 *Failure is the opportunity to begin again more intelligently*

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


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

2011-09-27 Thread Nitin
C questions there are 12 -13 questions given on internet it will be same as
it is given in the paper ,i dnt find a link right now otherwise do test ur c
skills thoruoghly all c questions will be from that book

On Tue, Sep 27, 2011 at 7:47 PM, vartika aggarwal 
vartika.aggarwa...@gmail.com wrote:

 Thanks! :-)


 On Tue, Sep 27, 2011 at 7:45 PM, rahul sharma rahul23111...@gmail.comwrote:


 test ur c skill for c..ds simple and os simpleno need to prepare
 if know basics...
 25 dieasy.25 problem solving...
 interviews will b easy to crack...once u done with test u have done 90%
 all d best

 On Tue, Sep 27, 2011 at 7:24 PM, sourabh jain 
 sourabhjain...@gmail.comwrote:




 1, writin 50 que.. (20 frm DI, 5 frm Quanta, 25 frm puzzel)
 2. technical written (20 frm c/c++, 5 frm DS, 5 frm OS)
 3. technical interview ( c/c++, DS, OS)
 4. HR interview (normal)


 --
 Regards
 SOURABH KUMAR JAIN
 MCA,  NIT RAIPUR
 MOB.-+919993878717


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

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

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


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



Re: [algogeeks] Re: MS Question - Median of a BST without using extra space and in O(n)

2011-09-27 Thread Nitin Garg
Do inorder traversal, to find out the total no. of nodes.

Next time, do the inorder traversal but keeping the count of nodes visited
and stop when you visit n/2 nodes.

Non recursive In-order Traversal -

*inorder*(node)
  *while* hasleftchild(node) *do*
node = node.left
  *do*
visit(node)
*if* (hasrightchild(node)) *then*
  node = node.right
  *while* hasleftchild(node) *do*
node = node.left
*else*
  *while* node.parent ≠ *null* *and* node == node.parent.right *do*
node = node.parent
  node = node.parent
  *while* node ≠ *null*

Source: Wikipedia

On Tue, Sep 27, 2011 at 9:13 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Recursion also requires space, so the problem is how to traverse without
 extra space.

 Once this is done, nothing is left in the problem.
 Sanju
 :)



 On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma 
 dheerajsharma1...@gmail.com wrote:

 @anshu
 can middle element can be found if the no. of nodes are not given...


 On Tue, Sep 27, 2011 at 8:34 PM, vikas vikas.rastogi2...@gmail.comwrote:

 a simple one is rabit-tortoise method, and using stackless traversal,
 facing a lot of corner cases in coding this, can someone check this as
 well?

 On Sep 27, 6:41 pm, anshu mishra anshumishra6...@gmail.com wrote:
  its not o(n) it is O(max height of tree) :P
  i have not seen the constraint.

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




 --
 *Dheeraj Sharma*



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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-09-27 Thread Nitin
can anybody tell me about the pattern of accenture???is is worth going to
accenture as a fresher???

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



Re: [algogeeks] Amazon Interview Question

2011-09-24 Thread Nitin Garg
 produce 00122?


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




 --
 Anup Ghatage

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




 --
 *Dheeraj Sharma*
 Comp Engg.
 NIT Kurukshetra


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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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



Re: [algogeeks] Re: MICROSOFT IDC

2011-09-23 Thread Nitin Garg
Congrats Saurabh.

On Fri, Sep 23, 2011 at 7:18 PM, sagar pareek sagarpar...@gmail.com wrote:

 congrates dude


 On Thu, Sep 22, 2011 at 7:26 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Saurabh : Thank u very much :)

 Sanju
 :)



 On Thu, Sep 22, 2011 at 6:15 AM, saurabh sah.saurab...@gmail.com wrote:

 thanx to all

 @sanjay I have shared my interview experience at
 http://msidcinterview.blogspot.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
 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.




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-09-21 Thread Nitin Garg
Ohh i totally missed that line.
Thanx a lot :)

On Wed, Sep 21, 2011 at 10:46 AM, pankaj agarwal 
agarwal.pankaj.1...@gmail.com wrote:

 @Nitin Garg

 Question 6 -

 i agree that greater the sum is and greater the probability to getting it.
 but in given question if sum100 then rolling is stopped
 so for

 P(106)=P(100)*1/6
 P(105)=P(100)*1/6+P(99)*1/6
 .
 .
 .
 P(101)=P(100)*1/6+P(99)*(1/6)+P(98)*(1/6)+P(97)*(1/6)+..+P(95)*(1/6)

 now P(101) is more

 cleare me if something is wrong.



 On Mon, Sep 19, 2011 at 1:35 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Question 6 -
 Intuitively you can see that the greater the sum is, the greater the
 favorable events in sample space.

 e.g. - sum = 1 .. cases {(1)}   Pr = 1/6
 sum = 2 cases {(2),(1,1)}   Pr = 1/6 + 1/36
 sum = 3cases {(3),(2,1)(1,2)(1,1,1)}  Pr = 1/6 + 1/36 +1/36 +
 1/216


 for a more formal proof, look at the recursion -


 P(k) = (P(k-6) + P(k-5) + P(k-4)... P(k-1)))/6

 where P(0) = 1, P(i) = 0  for i0

 Base case -
 P(2)  P(1)

 Hypothesis -

 P(i)  P(i-1) for  all i = k

 To prove
 P(k+1)   P(k)

 Proof
 P(k+1) - P(k) = (P(k) - P(k-6))/6  0






  --
  Pankaj Agarwal
  Communication and Computer Engineering
  LNMIIT,jaipur

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




-- 
Nitin Garg

Personality can open doors, but only Character can keep them open

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

2011-09-19 Thread Nitin Garg
Question 3 -
To eliminate one player, you need to host atleast 2 matches and make him
loose in both 2. These 2 matches can not contribute to elimination of any
other player.
So, min 2 matches for every player who is to be eliminated, hence 100.


On Mon, Sep 19, 2011 at 11:54 AM, Bhanu Chowdary bhanuchowd...@gmail.comwrote:

 @Nitin: Answer to question 3 is 50.


 On Mon, Sep 19, 2011 at 11:44 AM, praveen raj praveen0...@gmail.comwrote:

 @nitin Plz explain how u have reached answer of question no. 4 and 6

 On 19-Sep-2011 12:26 AM, Nitin Garg nitin.garg.i...@gmail.com wrote:
 
  Answer  3 - 100
  Answer 6 - 103
  Answer 4 - 194 total processes including the parent
  Answer 7 - 12 km south, 12 km east
 
 
  On Sun, Sep 18, 2011 at 11:53 PM, Ashima . ashima.b...@gmail.com
 wrote:
 
  @malay: how cm n+logn-2?
  cn u explain the logic ?
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sun, Sep 18, 2011 at 11:07 AM, Ashima . ashima.b...@gmail.com
 wrote:
 
  rite! 62.5%
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti 
 m1234...@gmail.com wrote:
 
  create a tournament tree.in each round one value is eliminated to
 obtain in the process the winner or the highest value in n-1 comparisons.
 Then check the queue of the winner which contains log(n) entries of the
 values beaten by the winner which implicitly will contain the runners
 up.Then log(n)-1 comparisons to find the highest among all the losers whom
 the winner had beaten. So all over complexity will be n-1 +log(n) -1 =
 n+log(n)-2. Hp that answers ur query. nice question btw :)
 
 
  On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI viharri@gmail.com
 wrote:
 
  hey i'm also thinking n + logn -2.. but couldnt able to figure out
  how??? can you please explain the logic
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 
 
 
  --
  Nitin Garg
 
  Personality can open doors... but only Character can keep them open
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.




 --
 Bhanu Chowdary

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




-- 
Nitin Garg

Personality can open doors... but only Character can keep them open

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

2011-09-19 Thread Nitin Garg
Question 6 -
Intuitively you can see that the greater the sum is, the greater the
favorable events in sample space.

e.g. - sum = 1 .. cases {(1)}   Pr = 1/6
sum = 2 cases {(2),(1,1)}   Pr = 1/6 + 1/36
sum = 3cases {(3),(2,1)(1,2)(1,1,1)}  Pr = 1/6 + 1/36 +1/36 +
1/216


for a more formal proof, look at the recursion -


P(k) = (P(k-6) + P(k-5) + P(k-4)... P(k-1)))/6

where P(0) = 1, P(i) = 0  for i0

Base case -
P(2)  P(1)

Hypothesis -

P(i)  P(i-1) for  all i = k

To prove
P(k+1)   P(k)

Proof
P(k+1) - P(k) = (P(k) - P(k-6))/6  0








On Mon, Sep 19, 2011 at 1:04 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Question 3 -
 To eliminate one player, you need to host atleast 2 matches and make him
 loose in both 2. These 2 matches can not contribute to elimination of any
 other player.
 So, min 2 matches for every player who is to be eliminated, hence 100.


 On Mon, Sep 19, 2011 at 11:54 AM, Bhanu Chowdary 
 bhanuchowd...@gmail.comwrote:

 @Nitin: Answer to question 3 is 50.


 On Mon, Sep 19, 2011 at 11:44 AM, praveen raj praveen0...@gmail.comwrote:

 @nitin Plz explain how u have reached answer of question no. 4 and 6

 On 19-Sep-2011 12:26 AM, Nitin Garg nitin.garg.i...@gmail.com wrote:
 
  Answer  3 - 100
  Answer 6 - 103
  Answer 4 - 194 total processes including the parent
  Answer 7 - 12 km south, 12 km east
 
 
  On Sun, Sep 18, 2011 at 11:53 PM, Ashima . ashima.b...@gmail.com
 wrote:
 
  @malay: how cm n+logn-2?
  cn u explain the logic ?
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sun, Sep 18, 2011 at 11:07 AM, Ashima . ashima.b...@gmail.com
 wrote:
 
  rite! 62.5%
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti 
 m1234...@gmail.com wrote:
 
  create a tournament tree.in each round one value is eliminated to
 obtain in the process the winner or the highest value in n-1 comparisons.
 Then check the queue of the winner which contains log(n) entries of the
 values beaten by the winner which implicitly will contain the runners
 up.Then log(n)-1 comparisons to find the highest among all the losers whom
 the winner had beaten. So all over complexity will be n-1 +log(n) -1 =
 n+log(n)-2. Hp that answers ur query. nice question btw :)
 
 
  On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI viharri@gmail.com
 wrote:
 
  hey i'm also thinking n + logn -2.. but couldnt able to figure out
  how??? can you please explain the logic
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 
 
 
  --
  Nitin Garg
 
  Personality can open doors... but only Character can keep them open
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.




 --
 Bhanu Chowdary

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




 --
 Nitin Garg

 Personality can open doors... but only Character can keep them open




-- 
Nitin Garg

Personality can open doors... but only Character can keep them open

-- 
You received this message because you

Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-19 Thread Nitin Garg
In Question 4 i just kept counting new processes that are being added in
every iteration.
No. of new processes being created is equal to the already running no. of
even pid processes.

Time - PId
0  - 0  1
1 - 0,12
2, - 0,1,23
3, - 0,1,2,3,4  5
4 - 0,1,2,3,4,5,6,7   8
.
.
.



1,2,3,5,8,11,17,25,38,57,86,129,194

I kept counting, got 194.
Don't know of any shortcut.





On Mon, Sep 19, 2011 at 1:35 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Question 6 -
 Intuitively you can see that the greater the sum is, the greater the
 favorable events in sample space.

 e.g. - sum = 1 .. cases {(1)}   Pr = 1/6
 sum = 2 cases {(2),(1,1)}   Pr = 1/6 + 1/36
 sum = 3cases {(3),(2,1)(1,2)(1,1,1)}  Pr = 1/6 + 1/36 +1/36 +
 1/216


 for a more formal proof, look at the recursion -


 P(k) = (P(k-6) + P(k-5) + P(k-4)... P(k-1)))/6

 where P(0) = 1, P(i) = 0  for i0

 Base case -
 P(2)  P(1)

 Hypothesis -

 P(i)  P(i-1) for  all i = k

 To prove
 P(k+1)   P(k)

 Proof
 P(k+1) - P(k) = (P(k) - P(k-6))/6  0








 On Mon, Sep 19, 2011 at 1:04 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Question 3 -
 To eliminate one player, you need to host atleast 2 matches and make him
 loose in both 2. These 2 matches can not contribute to elimination of any
 other player.
 So, min 2 matches for every player who is to be eliminated, hence 100.


 On Mon, Sep 19, 2011 at 11:54 AM, Bhanu Chowdary bhanuchowd...@gmail.com
  wrote:

 @Nitin: Answer to question 3 is 50.


 On Mon, Sep 19, 2011 at 11:44 AM, praveen raj praveen0...@gmail.comwrote:

 @nitin Plz explain how u have reached answer of question no. 4 and 6

 On 19-Sep-2011 12:26 AM, Nitin Garg nitin.garg.i...@gmail.com
 wrote:
 
  Answer  3 - 100
  Answer 6 - 103
  Answer 4 - 194 total processes including the parent
  Answer 7 - 12 km south, 12 km east
 
 
  On Sun, Sep 18, 2011 at 11:53 PM, Ashima . ashima.b...@gmail.com
 wrote:
 
  @malay: how cm n+logn-2?
  cn u explain the logic ?
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sun, Sep 18, 2011 at 11:07 AM, Ashima . ashima.b...@gmail.com
 wrote:
 
  rite! 62.5%
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti 
 m1234...@gmail.com wrote:
 
  create a tournament tree.in each round one value is eliminated to
 obtain in the process the winner or the highest value in n-1 comparisons.
 Then check the queue of the winner which contains log(n) entries of the
 values beaten by the winner which implicitly will contain the runners
 up.Then log(n)-1 comparisons to find the highest among all the losers whom
 the winner had beaten. So all over complexity will be n-1 +log(n) -1 =
 n+log(n)-2. Hp that answers ur query. nice question btw :)
 
 
  On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI viharri@gmail.com
 wrote:
 
  hey i'm also thinking n + logn -2.. but couldnt able to figure out
  how??? can you please explain the logic
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 
 
 
  --
  Nitin Garg
 
  Personality can open doors... but only Character can keep them open
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.




 --
 Bhanu Chowdary

 --
 You received

Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-19 Thread Nitin Garg
Can someone tell answers to question 2 and 5 with explanation??




On Mon, Sep 19, 2011 at 1:40 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 In Question 4 i just kept counting new processes that are being added in
 every iteration.
 No. of new processes being created is equal to the already running no. of
 even pid processes.

 Time - PId
 0  - 0  1
 1 - 0,12
 2, - 0,1,23
 3, - 0,1,2,3,4  5
 4 - 0,1,2,3,4,5,6,7   8
 .
 .
 .



 1,2,3,5,8,11,17,25,38,57,86,129,194

 I kept counting, got 194.
 Don't know of any shortcut.





 On Mon, Sep 19, 2011 at 1:35 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Question 6 -
 Intuitively you can see that the greater the sum is, the greater the
 favorable events in sample space.

 e.g. - sum = 1 .. cases {(1)}   Pr = 1/6
 sum = 2 cases {(2),(1,1)}   Pr = 1/6 + 1/36
 sum = 3cases {(3),(2,1)(1,2)(1,1,1)}  Pr = 1/6 + 1/36 +1/36 +
 1/216


 for a more formal proof, look at the recursion -


 P(k) = (P(k-6) + P(k-5) + P(k-4)... P(k-1)))/6

 where P(0) = 1, P(i) = 0  for i0

 Base case -
 P(2)  P(1)

 Hypothesis -

 P(i)  P(i-1) for  all i = k

 To prove
 P(k+1)   P(k)

 Proof
 P(k+1) - P(k) = (P(k) - P(k-6))/6  0








 On Mon, Sep 19, 2011 at 1:04 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Question 3 -
 To eliminate one player, you need to host atleast 2 matches and make him
 loose in both 2. These 2 matches can not contribute to elimination of any
 other player.
 So, min 2 matches for every player who is to be eliminated, hence 100.


 On Mon, Sep 19, 2011 at 11:54 AM, Bhanu Chowdary 
 bhanuchowd...@gmail.com wrote:

 @Nitin: Answer to question 3 is 50.


 On Mon, Sep 19, 2011 at 11:44 AM, praveen raj praveen0...@gmail.comwrote:

 @nitin Plz explain how u have reached answer of question no. 4 and 6

 On 19-Sep-2011 12:26 AM, Nitin Garg nitin.garg.i...@gmail.com
 wrote:
 
  Answer  3 - 100
  Answer 6 - 103
  Answer 4 - 194 total processes including the parent
  Answer 7 - 12 km south, 12 km east
 
 
  On Sun, Sep 18, 2011 at 11:53 PM, Ashima . ashima.b...@gmail.com
 wrote:
 
  @malay: how cm n+logn-2?
  cn u explain the logic ?
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sun, Sep 18, 2011 at 11:07 AM, Ashima . ashima.b...@gmail.com
 wrote:
 
  rite! 62.5%
 
  Ashima
  M.Sc.(Tech)Information Systems
  4th year
  BITS Pilani
  Rajasthan
 
 
 
 
  On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti 
 m1234...@gmail.com wrote:
 
  create a tournament tree.in each round one value is eliminated to
 obtain in the process the winner or the highest value in n-1 comparisons.
 Then check the queue of the winner which contains log(n) entries of the
 values beaten by the winner which implicitly will contain the runners
 up.Then log(n)-1 comparisons to find the highest among all the losers whom
 the winner had beaten. So all over complexity will be n-1 +log(n) -1 =
 n+log(n)-2. Hp that answers ur query. nice question btw :)
 
 
  On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI viharri@gmail.com
 wrote:
 
  hey i'm also thinking n + logn -2.. but couldnt able to figure
 out
  how??? can you please explain the logic
 
  --
  You received this message because you are subscribed to the
 Google Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 
 
 
  --
  Nitin Garg
 
  Personality can open doors... but only Character can keep them open
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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

Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-18 Thread Nitin Garg
Answer  3 - 100
Answer 6 - 103
Answer 4 - 194 total processes including the parent
Answer 7 - 12 km south, 12 km east

On Sun, Sep 18, 2011 at 11:53 PM, Ashima . ashima.b...@gmail.com wrote:

 @malay: how cm n+logn-2?
 cn u explain the logic ?

 Ashima
 M.Sc.(Tech)Information Systems
 4th year
 BITS Pilani
 Rajasthan




 On Sun, Sep 18, 2011 at 11:07 AM, Ashima . ashima.b...@gmail.com wrote:

 rite! 62.5%

 Ashima
 M.Sc.(Tech)Information Systems
 4th year
 BITS Pilani
 Rajasthan




 On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti m1234...@gmail.comwrote:

 create a tournament tree.in each round one value is eliminated to obtain
 in the process the winner or the highest value in n-1 comparisons. Then
 check the queue of the winner which contains log(n) entries of the values
 beaten by the winner which implicitly will contain the runners up.Then
 log(n)-1 comparisons to find the highest among all the losers whom the
 winner had beaten. So all over complexity will be n-1 +log(n) -1 =
 n+log(n)-2. Hp that answers ur query. nice question btw :)


 On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI viharri@gmail.com wrote:

 hey i'm also thinking n + logn -2.. but couldnt able to figure out
 how??? can you please explain the logic

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




-- 
Nitin Garg

Personality can open doors... but only Character can keep them open

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



Re: [algogeeks] Re: need explanation of this c code

2011-09-05 Thread Nitin
On Sun, Sep 4, 2011 at 9:22 PM, vivek goel vivek.thapar2...@gmail.comwrote:

 itz my pleasure  .
 so u r pursuing ur engg frm  where

 i thk its an undefined behaviour and the answer will vary from compiler to
 compiler.
 On Sun, Sep 4, 2011 at 7:33 PM, sinjanspecial sinjanspec...@gmail.comwrote:

 thanks vivek

 On Sep 3, 10:29 pm, sinjanspecial sinjanspec...@gmail.com wrote:
  code:-
  void main()
  {
  int i=5;
  i=(++i)/(i++);
  printf(%d,i)}
 
  Output is 2
  plz explain how it is?

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


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


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



Re: [algogeeks] Re: need explanation of this c code

2011-09-05 Thread Nitin
It's 1 on dev c++

On Mon, Sep 5, 2011 at 1:17 PM, Nitin coolguyinat...@gmail.com wrote:



 On Sun, Sep 4, 2011 at 9:22 PM, vivek goel vivek.thapar2...@gmail.comwrote:

 itz my pleasure  .
 so u r pursuing ur engg frm  where

 i thk its an undefined behaviour and the answer will vary from compiler to
 compiler.

 On Sun, Sep 4, 2011 at 7:33 PM, sinjanspecial sinjanspec...@gmail.comwrote:

 thanks vivek

 On Sep 3, 10:29 pm, sinjanspecial sinjanspec...@gmail.com wrote:
  code:-
  void main()
  {
  int i=5;
  i=(++i)/(i++);
  printf(%d,i)}
 
  Output is 2
  plz explain how it is?

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


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




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



Re: [algogeeks] very urgent .. help

2011-09-04 Thread Nitin
no need to preapre...
questions are very tough..
first attempt verbal... only this section is easy... try to attempt all
questions in this section..

Regards:
Nitin Kalra
Contact Number : 09050760645
Student : Electronics  Communication Engineering Department
National Institute of Technology, Kurukshetra


On Sun, Sep 4, 2011 at 2:24 PM, ashish kumar ashishmnnit6...@gmail.comwrote:

 there are 3 sections verbal,problemsolving and quant .. questions are
 tough..


 On Sun, Sep 4, 2011 at 2:06 PM, mani walia manis...@gmail.com wrote:

 ph elitmus test??


 what is that??

 and how to prepare for that??


 can anyone provide me with good sources for preparation??  please

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


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

2011-09-04 Thread Nitin Garg
Don's solution is correct.
At each push() operation, you update the value of min element upto that
depth in stack.
Can be illustrated with the following example -


stack = {}
push(2) stack = {(2,2)}
push(3) stack = {(3,2),(2,2)}
push(1) stack = {(1,1),(3,2),(2,2)}

where b in tuple (a,b) represents the min value upto current depth in stack.
pop() and min() are straight forward.

On Mon, Sep 5, 2011 at 12:48 AM, Don dondod...@gmail.com wrote:

 Each element in the stack will contain not only its own value, but the
 min value at that depth of the stack:

 struct stackItemStruct
 {
  int value;
  int min;
  struct stackItemStruct *next;
 };

 typedef struct stackItemStruct stackItem;

 class stack
 {
 public:
  stack();
  void push(int v);
  int pop();
  int min();
 private:
  stackItem *_stack;
 };

 stack::stack()
 {
  _stack = 0;
 }

 void stack::push(int v)
 {
  stackItem newItem = new stackItem;
  newItem-value = newItem-min = v;
  if (_stack   (_stack-min  v) )
  newItem-min = _stack-min;
  newItem-next = _stack;
  _stack = newItem;
 }

 int stack::pop()
 {
  int result = 0;
  if (_stack)
  {
result = _stack-val;
stackItem *tmp = _stack;
_stack = tmp-next;
delete tmp;
  }
  return result;
 }

 int stack::min()
 {
  return _stack ? _stack-min : 0;
 }

 On Sep 4, 12:08 pm, Sangeeta sangeeta15...@gmail.com wrote:
  How would you design a stack which,in addition to push and pop,also
  has a function min which returns the minimum element?push,pop and min
  should all operate in O(1) 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.




-- 
Nitin Garg

Personality can open doors... but only Character can keep them open

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

2011-09-03 Thread Nitin
I think b-tree would help you...

On Sat, Sep 3, 2011 at 9:47 AM, bharatkumar bagana 
bagana.bharatku...@gmail.com wrote:

 WHY trie? any reason ?
 Dictionary means not only to save efficiently and also we have to get back
 in almost O(1) time .. I think Hash Table is best suited for this... Or any
 way we have Dictionary Data Structure in Java..


 On Fri, Sep 2, 2011 at 3:23 PM, Yuchen Liao lycdra...@gmail.com wrote:

 Trie is good, but I prefer inverted index.


 On Fri, Sep 2, 2011 at 1:38 PM, somya mishra somya.bvm...@gmail.comwrote:

 trie


 On Sat, Sep 3, 2011 at 12:05 AM, sukran dhawan 
 sukrandha...@gmail.comwrote:

 trie data structure


 On Fri, Sep 2, 2011 at 11:21 PM, Aman Kumar amanas...@gmail.comwrote:

 Hii

 Which data structures can be used for implementation for dictionary?

 which is best/good among them?

 provide good link for 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.


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




 --
 from Yuchen Liao via Gmail

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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
 *BharatKumar Bagana*
 **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar
 *
 Mobile +91 8056127652*
 bagana.bharatku...@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.



Re: [algogeeks] Algorithms for Interviews

2011-09-03 Thread Nitin Garg
Even i need the book.
Please reshare a working link.

I am studying computer science at IIT Delhi.

On Sat, Sep 3, 2011 at 9:08 PM, vivek goel vivek.thapar2...@gmail.comwrote:

 hey  u  frm which college.

 On Sat, Sep 3, 2011 at 9:04 PM, Ankuj Gupta ankuj2...@gmail.com wrote:

 If someone has Algorithms for Interviews please share with me. I tried
 the link which was earlier posted on the group but it says it is
 locked.

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




-- 
Nitin Garg

Personality can open doors... but only Character can keep them open

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

2011-09-03 Thread Nitin Garg
This link worked for me
http://www.mediafire.com/?a2ia1j1i0q0pet1



On Sat, Sep 3, 2011 at 9:22 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 Even i need the book.
 Please reshare a working link.

 I am studying computer science at IIT Delhi.


 On Sat, Sep 3, 2011 at 9:08 PM, vivek goel vivek.thapar2...@gmail.comwrote:

 hey  u  frm which college.

 On Sat, Sep 3, 2011 at 9:04 PM, Ankuj Gupta ankuj2...@gmail.com wrote:

 If someone has Algorithms for Interviews please share with me. I tried
 the link which was earlier posted on the group but it says it is
 locked.

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




 --
 Nitin Garg

 Personality can open doors... but only Character can keep them open




-- 
Nitin Garg

Personality can open doors... but only Character can keep them open

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

2011-09-03 Thread Nitin Garg
 int(*p)[col];

Here, p is a pointer to an array of 4 integers.
Size of *p is 4X4 = 16.

 p=(int(*)[col])malloc(row*sizeof(*p));

here clearly 3X 16  = 48 bytes of memory is being allocated.


On Sat, Sep 3, 2011 at 9:14 PM, piyush agarwal pshagl...@gmail.com wrote:

 no. of rows is 3
 size of (*p) is 12
 then how can 48 be the no. of bytes ??

 On Sat, Sep 3, 2011 at 8:32 AM, Deepak Garg deepakgarg...@gmail.comwrote:

 +1


 On Sat, Sep 3, 2011 at 8:57 PM, Ankuj Gupta ankuj2...@gmail.com wrote:

 p is a pointer to an array of 4 integers. So when you do (int(*)
 [col])malloc(row*sizeof(*p)) total of 48 bytes is allocated as
 sizeof(*p) is 12 bytes.

 On Sep 3, 4:14 pm, rohit rajuljain...@gmail.com wrote:
  how many bytes are allocated by following code?
 
  #includealloc.h
  #define col 4
  #define row 3
 
  int main()
  {
  int(*p)[col];
  p=(int(*)[col])malloc(row*sizeof(*p));
 
  return 0;
 
  }
 
  please explain answer?

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




 --
 U.D.I.T

 Sent by Nokia OVI (c)

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




 --
 Piyush Agarwal
 Final Year Undergraduate
 Department of Computer Engineering
 Malaviya National Institute of Technology
 Jaipur

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




-- 
Nitin Garg

Personality can open doors... but only Character can keep them open

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

2011-08-29 Thread Nitin
Please specify the difference between Array of pointer and Pointer to
array???it's getting very messy

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

2011-08-23 Thread Nitin Nizhawan
Thus above statement is true if and only it is given that there are some
girls who are not Beautiful.

On Tue, Aug 23, 2011 at 7:50 PM, Bharat Kul Ratan
bharat.kra...@gmail.comwrote:

 Statement: Some girls are beautiful
 IMO , this means you a set of all girls and after that comes statement
 about some otherwise statement would be for all girls.
 There is something left in the set after statement which is nothing but
 complement of beautiful i.e. not beautiful
 so, the conclusion must be true.

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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



Re: [algogeeks] convert a vector containing octal representation of a number to decimal number

2011-08-21 Thread Nitin Nizhawan
int num = 0;
for(int i=0;iA.size();i++){
   num=num||(A[i]3*i);
}
printf(%d,num);

I think this will do.

On Sun, Aug 21, 2011 at 2:25 PM, sarvesh saran
aquarian.thun...@gmail.comwrote:

 Hi,

 I have a vectorint A or an array (for C guys) that contains the octal
 representation of a number.

 So the array can be something like: [1,5,7] or [7,7,5,6,3,4,2] etc

 i.e no number in the array can be = 8.

 Now given this array, I need to convert it its decimal representation.

 The naive way to do it would be to scan array from left to right, take each
 digit, multiply by 8 pow (x) where x is from 0 to ...n and compute sum.

 i.e something like:

 int oct = 1;
 int num = 0;

  for(array length){
 num+= oct * A[i];
 oct = oct * 8;
 }

 is there a faster way to do this? maybe using some STL container or 
 algorithm. ?

 thanks,
 sarvesh


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


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



Re: [algogeeks] convert a vector containing octal representation of a number to decimal number

2011-08-21 Thread Nitin Nizhawan
int num = 0;
for(int i=0;iA.size();i++){
   num=num||(A[i]3*i);
}
printf(%d,num);

I think this will do. Given the number is with in the range of integer.

On Sun, Aug 21, 2011 at 3:40 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote:

 int num = 0;
 for(int i=0;iA.size();i++){
num=num||(A[i]3*i);
 }
 printf(%d,num);

 I think this will do.


 On Sun, Aug 21, 2011 at 2:25 PM, sarvesh saran aquarian.thun...@gmail.com
  wrote:

 Hi,

 I have a vectorint A or an array (for C guys) that contains the octal
 representation of a number.

 So the array can be something like: [1,5,7] or [7,7,5,6,3,4,2] etc

 i.e no number in the array can be = 8.

 Now given this array, I need to convert it its decimal representation.

 The naive way to do it would be to scan array from left to right, take
 each digit, multiply by 8 pow (x) where x is from 0 to ...n and compute sum.

 i.e something like:

 int oct = 1;
 int num = 0;

  for(array length){
 num+= oct * A[i];
 oct = oct * 8;
 }

 is there a faster way to do this? maybe using some STL container or 
 algorithm. ?

 thanks,
 sarvesh


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




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



Re: [algogeeks] convert a vector containing octal representation of a number to decimal number

2011-08-21 Thread Nitin Nizhawan
@sanjay, oops, my intention was bitwise OR

On Sun, Aug 21, 2011 at 4:25 PM, sarvesh saran
aquarian.thun...@gmail.comwrote:

 Hi Prakash,

 I'll paste the exact description of the problem:

 A non-empty array A of N elements contains octal representation of a
 non-negative integer K, i.e. each element of A belongs to the interval [0;
 7] (both ends included).

 Write a function that returns the number of bits set to 1 in the binary
 representation of K.

 thanks,

 Sarvesh






 i.e take any decimal number, convert to base 8 and then store each digit of
 base 8 representation in an array.

 So the question is, given such an array get back the original number.

 thanks,
 Sarvesh


 On Sun, Aug 21, 2011 at 4:13 PM, Prakash D cegprak...@gmail.com wrote:

 A[i]3*i

 why is it needed to convert from base 8 to base 10??

 On Sun, Aug 21, 2011 at 4:07 PM, Sanjay Rajpal srn...@gmail.com wrote:

 Hi your intention was logical OR or BITWISE OR ?

 u did Logical.
 Sanju
 :)



 On Sun, Aug 21, 2011 at 3:30 AM, sarvesh saran 
 aquarian.thun...@gmail.com wrote:

 Hi Nitin,

 thanks that makes sense. I will try that out.

 I have another question. Is there a  really fast way of converting a
 hexadecimal string say 02F9A to its decimal representation in C++?

 thanks,
 Sarvesh

 thanks,
 Sarvesh


 On Sun, Aug 21, 2011 at 3:41 PM, Nitin Nizhawan 
 nitin.nizha...@gmail.com wrote:

 int num = 0;
 for(int i=0;iA.size();i++){
num=num||(A[i]3*i);
 }
 printf(%d,num);

 I think this will do. Given the number is with in the range of integer.



 On Sun, Aug 21, 2011 at 3:40 PM, Nitin Nizhawan 
 nitin.nizha...@gmail.com wrote:

 int num = 0;
 for(int i=0;iA.size();i++){
num=num||(A[i]3*i);
 }
 printf(%d,num);

 I think this will do.


 On Sun, Aug 21, 2011 at 2:25 PM, sarvesh saran 
 aquarian.thun...@gmail.com wrote:

 Hi,

 I have a vectorint A or an array (for C guys) that contains the
 octal representation of a number.

 So the array can be something like: [1,5,7] or [7,7,5,6,3,4,2] etc

 i.e no number in the array can be = 8.

 Now given this array, I need to convert it its decimal
 representation.

 The naive way to do it would be to scan array from left to right,
 take each digit, multiply by 8 pow (x) where x is from 0 to ...n and 
 compute
 sum.

 i.e something like:

 int oct = 1;
 int num = 0;

  for(array length){
 num+= oct * A[i];
 oct = oct * 8;
 }

 is there a faster way to do this? maybe using some STL container or 
 algorithm. ?

 thanks,
 sarvesh


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



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


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


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


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


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


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



Re: [algogeeks] c question

2011-08-21 Thread Nitin
thnx:)

On Sun, Aug 21, 2011 at 9:26 AM, Sanjay Rajpal srn...@gmail.com wrote:

 See you are considering one bit of bit1, and printing it as signed integer.
 So what i think is that '1' bit will be treated as   while treating
 it as Signed Integer, and this is the binary representation of
 -1. Hence the result.

 If you write it as unsigned int bit1:1, the result is 122. So my argument
 is correct.

 Try this and let me know.

 Correct me If m wrong.
 Sanju
 :)



 On Sat, Aug 20, 2011 at 8:44 PM, sukran dhawan sukrandha...@gmail.comwrote:

 only one bit is reserved for it.so the binary representation is 1.since
 only one bit is present,
 that bit becomes sign nit and hence -1

 On Sun, Aug 21, 2011 at 8:07 AM, saurabh singh saurab...@gmail.comwrote:

 Read bit field


 On Sun, Aug 21, 2011 at 2:44 AM, Nitin coolguyinat...@gmail.com wrote:

 #includestdio.h
 main()
 {
   struct value
 {
   int bit1:1;
 int bit2:4;
 int bit3:4;
 }bit={1,2,2};
 printf(%d%d%d,bit.bit1,bit.bit2,bit.bit3);
 }

 output is -1,2,2;
 can anybody tell me the reason that y it is giving -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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD



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


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


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


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



Re: [algogeeks] convert a vector containing octal representation of a number to decimal number

2011-08-21 Thread Nitin Nizhawan
I guess, earlier sarvan simply wanted to calculate
result = SUM {0=i  N }  A[i]*(8^i)

in which
8^i = 2^(3*i) which is equivalent to  right shifting 3*i

since each A[i] is octal it is just 3bits long , we need not add we can
simply shift and do OR.

On Sun, Aug 21, 2011 at 10:16 PM, Sanjay Rajpal srn...@gmail.com wrote:

 @Nitin : could u explain ur logic ?


 Sanju
 :)



 On Sun, Aug 21, 2011 at 9:24 AM, Nitin Nizhawan 
 nitin.nizha...@gmail.comwrote:

 @sanjay, oops, my intention was bitwise OR


 On Sun, Aug 21, 2011 at 4:25 PM, sarvesh saran 
 aquarian.thun...@gmail.com wrote:

 Hi Prakash,

 I'll paste the exact description of the problem:

 A non-empty array A of N elements contains octal representation of a
 non-negative integer K, i.e. each element of A belongs to the interval [0;
 7] (both ends included).

 Write a function that returns the number of bits set to 1 in the binary
 representation of K.

 thanks,

 Sarvesh






 i.e take any decimal number, convert to base 8 and then store each digit
 of base 8 representation in an array.

 So the question is, given such an array get back the original number.

 thanks,
 Sarvesh


 On Sun, Aug 21, 2011 at 4:13 PM, Prakash D cegprak...@gmail.com wrote:

 A[i]3*i

 why is it needed to convert from base 8 to base 10??

 On Sun, Aug 21, 2011 at 4:07 PM, Sanjay Rajpal srn...@gmail.comwrote:

  Hi your intention was logical OR or BITWISE OR ?

 u did Logical.
 Sanju
 :)



 On Sun, Aug 21, 2011 at 3:30 AM, sarvesh saran 
 aquarian.thun...@gmail.com wrote:

 Hi Nitin,

 thanks that makes sense. I will try that out.

 I have another question. Is there a  really fast way of converting a
 hexadecimal string say 02F9A to its decimal representation in C++?

 thanks,
 Sarvesh

 thanks,
 Sarvesh


 On Sun, Aug 21, 2011 at 3:41 PM, Nitin Nizhawan 
 nitin.nizha...@gmail.com wrote:

 int num = 0;
 for(int i=0;iA.size();i++){
num=num||(A[i]3*i);
 }
 printf(%d,num);

 I think this will do. Given the number is with in the range of
 integer.


 On Sun, Aug 21, 2011 at 3:40 PM, Nitin Nizhawan 
 nitin.nizha...@gmail.com wrote:

 int num = 0;
 for(int i=0;iA.size();i++){
num=num||(A[i]3*i);
 }
 printf(%d,num);

 I think this will do.


 On Sun, Aug 21, 2011 at 2:25 PM, sarvesh saran 
 aquarian.thun...@gmail.com wrote:

 Hi,

 I have a vectorint A or an array (for C guys) that contains the
 octal representation of a number.

 So the array can be something like: [1,5,7] or [7,7,5,6,3,4,2] etc

 i.e no number in the array can be = 8.

 Now given this array, I need to convert it its decimal
 representation.

 The naive way to do it would be to scan array from left to right,
 take each digit, multiply by 8 pow (x) where x is from 0 to ...n and 
 compute
 sum.

 i.e something like:

 int oct = 1;
 int num = 0;

  for(array length){
 num+= oct * A[i];
 oct = oct * 8;
 }

 is there a faster way to do this? maybe using some STL container or 
 algorithm. ?

 thanks,
 sarvesh


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



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


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


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


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


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options

Re: [algogeeks] Re: Make My Trip *URGENT*

2011-08-20 Thread Nitin
MMT selected 5 students from our university those who are selected for
development have been asked about there project about there pros and cons
and in detailed manner,but people who are selected for the QA they were
provided with the puzzles..


On Fri, Aug 19, 2011 at 10:46 AM, snehi jain snehijai...@gmail.com wrote:

 after the aptitude written round .. there were 15 questions in technical (c
  c++)
 and 5 questions on coding in 45 m.in.


 On Thu, Aug 18, 2011 at 11:01 PM, Anika Jain anika.jai...@gmail.comwrote:

 the level is very easy.. i dont remember the questions .. but they are
 easy.. but tht makes cut off go very high

 On Thu, Aug 18, 2011 at 1:22 PM, monish001 monish.gup...@gmail.comwrote:

 What level of questions for each- english, aptitute, coding? Can you
 discuss some?

 -Monish

 On Aug 17, 5:06 pm, Anika Jain anika.jai...@gmail.com wrote:
  there will be 15 english fill in the blanks, 5 series questn, 10
 aptitude
  questions, 10 logical questions..
  then 10 c++ mcqs and 5 coding questions
 
  On Wed, Aug 17, 2011 at 5:28 PM, Brijesh Upadhyay 
 
 
 
 
 
 
 
  brijeshupadhyay...@gmail.com wrote:
   has anyone given MMT written test.??  please reply , what is the
   pattern of the paper?
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

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


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


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


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



Re: [algogeeks] Syllogism

2011-08-20 Thread Nitin Nizhawan
Statement:
Some girls are beautiful'  Ex B(x) , there exist at least one girl who is
beautiful
Some girls are not beautiful Ex !B(x), there exist at least one girl who
is beautiful

I do not think first implies the second.



On Sat, Aug 20, 2011 at 3:13 PM, vikas singh shyguy1...@gmail.com wrote:



 On Sat, Aug 20, 2011 at 10:26 AM, geek_one 
 abhishekgupta.it...@gmail.comwrote:

 Statement: Some girls are beautiful.
 Conclusion: Some girls are not beautiful.

 is the conclusion is true on the basis of Statement?


 I think there is a doubt in this statement. you can't say ,some girls are
 not beautiful.
 Because, it may so happen that
 All girls are beautiful. ( All is a particular case of some, you must be
 knowing it.)
 and here lies the conflict, so, some girls are not beautiful is not the
 answer.


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




 --
 Thanks and Regards
 VIKAS SINGH
 MCA- final year
 NIT DURGAPUR
 email:
  vikas.singh1...@gmail.com
  shyguy1...@gmail.com
 http://smrit.wordpress.com


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


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

2011-08-20 Thread Nitin Nizhawan
there was a small typo in my last mail, corrected here

Statement:
Some girls are beautiful'  Ex B(x) , there exist at least one girl who is
beautiful
Some girls are not beautiful Ex !B(x), there exist at least one girl who
is NOT beautiful

I do not think first implies the second.

On Sat, Aug 20, 2011 at 6:49 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote:

 Statement:
 Some girls are beautiful'  Ex B(x) , there exist at least one girl who is
 beautiful
 Some girls are not beautiful Ex !B(x), there exist at least one girl who
 is beautiful

 I do not think first implies the second.



 On Sat, Aug 20, 2011 at 3:13 PM, vikas singh shyguy1...@gmail.com wrote:



 On Sat, Aug 20, 2011 at 10:26 AM, geek_one abhishekgupta.it...@gmail.com
  wrote:

 Statement: Some girls are beautiful.
 Conclusion: Some girls are not beautiful.

 is the conclusion is true on the basis of Statement?


 I think there is a doubt in this statement. you can't say ,some girls are
 not beautiful.
 Because, it may so happen that
 All girls are beautiful. ( All is a particular case of some, you must be
 knowing it.)
 and here lies the conflict, so, some girls are not beautiful is not the
 answer.


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




 --
 Thanks and Regards
 VIKAS SINGH
 MCA- final year
 NIT DURGAPUR
 email:
  vikas.singh1...@gmail.com
  shyguy1...@gmail.com
 http://smrit.wordpress.com


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




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

2011-08-20 Thread Nitin Nizhawan
@geek_one, its false, some girls are beautiful does not imply that some
girls are not beautiful

On Sat, Aug 20, 2011 at 10:36 PM, Yogesh Bhati ybha...@gmail.com wrote:

 conclusion :
 Is at least some girls are beautiful

 dnt knw abt rest bt some are

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


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



[algogeeks] c question

2011-08-20 Thread Nitin
#includestdio.h
main()
{
  struct value
{
  int bit1:1;
int bit2:4;
int bit3:4;
}bit={1,2,2};
printf(%d%d%d,bit.bit1,bit.bit2,bit.bit3);
}

output is -1,2,2;
can anybody tell me the reason that y it is giving -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] Novell questions

2011-08-18 Thread Nitin Gupta
can anyone post some written and interview question asked by Novell?

On Thu, Aug 11, 2011 at 11:17 PM, mohit verma mohit89m...@gmail.com wrote:

 +1


 On Thu, Aug 11, 2011 at 11:14 PM, manvir siyo manis...@gmail.com wrote:

 can anyone tell me abt the written test of d e shaw
 On Thu, Aug 11, 2011 at 11:13 PM, mohit verma mohit89m...@gmail.comwrote:

 Hey guys,

 can anyone post some written and interview question asked by Novell?

 --
 
 *MOHIT VERMA*

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


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




 --
 
 *MOHIT VERMA*

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




-- 
Nitin Gupta
B Tech 3rd yr
Information Technology
National Institute of Technology, 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] Prime numbers

2011-08-17 Thread Nitin Nizhawan
Hi Dod,

  Could you pls expalin what this algorithm is doing and from where you got
it.

Thanks
Nitin
On Wed, Aug 17, 2011 at 2:56 AM, Don dondod...@gmail.com wrote:

 I wrote a program to print prime numbers, but it is not very fast. Can
 someone help me figure out why?


 #include stdio.h

 /* This program implements a blindingly fast algorithm
   to find prime numbers, using an elegant recursive method. */
 int _(int n, int m, int d, int t=0)
 {
int r;
if (t) return d?1+_(n,m,d-1,d):n?_(n-1,m,m,n):0;
for(r=m!=n; d*(tn); ++t)
r = _(n,_(t,m,0,1),d-1)|!_(t,1,t);
return r*n;
 }


 /*--
  Print primes up to the requested value
 */
 int main(int argc, char* argv[])
 {
for(int n = 2; n = 1000; n++)
printf(%d is%s prime\n,n, _(n,1,n,0)?: not);

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



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



Re: [algogeeks] SISO

2011-08-17 Thread Nitin Gupta
what package is being offered by SISO??

On Mon, Aug 15, 2011 at 12:35 PM, vikas singh shyguy1...@gmail.com wrote:

 yes, they all follow the same pattern provided by GLOBAL SAMSUNG APTITUDE
 TEST (GSAT)

 On Sun, Aug 14, 2011 at 8:26 PM, parag khanna khanna.para...@gmail.comwrote:

 itz the same procedure as that of Samsung SEL

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




 --
 Thanks and Regards
 VIKAS SINGH
 MCA- final year
 NIT DURGAPUR
 email:
  vikas.singh1...@gmail.com
  shyguy1...@gmail.com
 http://smrit.wordpress.com


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




-- 
Nitin Gupta
B Tech 3rd yr
Information Technology
National Institute of Technology, 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: Number theory

2011-08-17 Thread Nitin Nizhawan
@Puneet, you are right but we can have only n-1 dividers.

On Wed, Aug 17, 2011 at 4:15 PM, Puneet Goyal puneetgoya...@gmail.comwrote:

 I think it should be 2^n -1

 Explanation
 We can visualize it as n balls are placed and we have to place some
 dividers (max=n) in betweek to divide them into groups.

 If we choose no divider its nC0 , but we dont have to include it
 With 1 divider its nC1
 and so on..
 So the total no. of ways will be
 (nC0+nC1+nC2..nCn)-nC0= 2^n-1

 Regards,
 Puneet

 On Wed, Aug 17, 2011 at 4:05 PM, Rohit Srivastava 
 access2ro...@gmail.comwrote:

 +1 to nitin


 On Wed, Aug 17, 2011 at 2:48 PM, Vijay Kansal vijaykans...@gmail.comwrote:

 my bad 2^(n-1)...

 On Aug 17, 2:17 pm, Vijay Kansal vijaykans...@gmail.com wrote:
  @nitin it must be 2^n i think
 
  On Aug 17, 3:48 am, Bharat Kul Ratan bharat.kra...@gmail.com wrote:
 
 
 
 
 
 
 
   It might be useful:
 http://www.artofproblemsolving.com/Wiki/index.php/Partition_%28combin...

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




 --
 ---
 Puneet Goyal
 Student of B. Tech. III Year (Software Engineering)
 Delhi Technological University, 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.



Re: [algogeeks] Factorial Algorithms

2011-08-17 Thread Nitin Nizhawan
@Gaurav , if you are able to find any resource that explains the logic of
these algos, please let me know.

On Sat, Aug 13, 2011 at 9:50 AM, Gaurav Menghani
gaurav.mengh...@gmail.comwrote:

 Thanks for the link. I was unaware of such algorithms. These would
 come handy in programming contests.

 On Fri, Aug 12, 2011 at 3:00 PM, Nitin Nizhawan
 nitin.nizha...@gmail.com wrote:
  http://www.luschny.de/math/factorial/FastFactorialFunctions.htm
  Does anyone know of resource for good/detailed explanation  of factorial
  algorithms on this site?
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 



 --
 Gaurav Menghani

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



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

2011-08-17 Thread Nitin Nizhawan
a = (1-0.2)
b = (1-0.3)
c = (1- 0.4)

a*b*(1-c) + a*(1-b)*c + (1-a)*b*c + a*b*c = 0.788

On Wed, Aug 17, 2011 at 5:08 PM, Romil ... vamosro...@gmail.com wrote:

 @Priya: A mistake from my side. The answer should be 1-0.212 i.e. 0.788
 Sorry for this mistake.
 @Kumar: Yours is wrong. Check it again.


 On Wed, Aug 17, 2011 at 4:42 PM, Romil ... vamosro...@gmail.comwrote:

 Kumar's approach would not do perhaps. I simply eliminated the undesired
 cases. Those include the one when none of them is active and when only one
 of them is active.
 @Kumar: You should have also added the term abc.


 On Wed, Aug 17, 2011 at 4:39 PM, priya ramesh 
 love.for.programm...@gmail.com wrote:

 @romil: how did you solve this??

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




 --
 Romil





 --
 Romil


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


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



Re: [algogeeks] What is the reason??

2011-08-17 Thread Nitin Nizhawan
I think this happens because EOF on stream is set when fscanf actually tries
to read beyond EOF but reads 0 characters and therefore printf prints the
previous value in s.

On Wed, Aug 17, 2011 at 5:11 PM, kumar raja rajkumar.cs...@gmail.comwrote:




 while(!feof(fp))
 {

   fscanf(fp,%s,s);

printf(%s,s);

 }


 The last word in the file is printing twice .What is the reason for this to
 happen???


 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in
 7797137043.
 09491690115.

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


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



Re: [algogeeks] What is the reason??

2011-08-17 Thread Nitin Nizhawan
It seems this is the way it is designed to work, some operation has to read
the EOF to acually set the EOF flag on the stream. In this case its fscanf.
 feof() function does not try to read next to see if EOF is reached it just
check a flag on the stream which is set when some operation encounters EOF.

On Wed, Aug 17, 2011 at 5:45 PM, kumar raja rajkumar.cs...@gmail.comwrote:

 Actually when all the words are over then it should reach end of file
 marker which is typically some ascii character  ,not on reading it again
 using fscanf... Why it will set only after fscanf is failed to read from
 it??


 On 17 August 2011 17:19, Nitin Nizhawan nitin.nizha...@gmail.com wrote:

 I think this happens because EOF on stream is set when fscanf actually
 tries to read beyond EOF but reads 0 characters and therefore printf prints
 the previous value in s.

 On Wed, Aug 17, 2011 at 5:11 PM, kumar raja rajkumar.cs...@gmail.comwrote:




 while(!feof(fp))
 {

   fscanf(fp,%s,s);

printf(%s,s);

 }


 The last word in the file is printing twice .What is the reason for this
 to happen???


 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in
 7797137043.
 09491690115.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in
 7797137043.
 09491690115.

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


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



Re: [algogeeks] De shaw ques!

2011-08-17 Thread Nitin Nizhawan
N = 935*q + 69

N%38 = 31, 16, 1, 24, 9, 32, 17, 2 for { q = 0,1,2,3,4,5,6,7. }

On Wed, Aug 17, 2011 at 5:54 PM, aditya kumar
aditya.kumar130...@gmail.comwrote:

 @priya . i have shown you my method . write your method and we shall
 discuss it .


 On Wed, Aug 17, 2011 at 5:52 PM, sukran dhawan sukrandha...@gmail.comwrote:



 On Wed, Aug 17, 2011 at 5:39 PM, priya ramesh 
 love.for.programm...@gmail.com wrote:

 if a number is divided by 935 remainder is 69. if same no. is divided by
 38, what will be the remainder?

 -- answer is 16.t

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


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


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


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

2011-08-17 Thread Nitin Gupta
which college?

On Wed, Aug 17, 2011 at 2:36 PM, rajoo king without sing rajoo...@gmail.com
 wrote:

 in my college samsung lab was come on 23 july. i was seated in recrument
 process.
 the recruiment process are
 written test followed by two round
 apptitude (50 objective question  in 1 hour) and
 coding test(2 subjective question in 1 hour)
 after then interview
 2 technical interview and 1HR interview
 so i hope Samsung india Software operations may follow the same pattern.

 BEST OF LUCK


 On Sun, Aug 14, 2011 at 5:13 PM, parag khanna khanna.para...@gmail.comwrote:

 Samsung india Software operations is visiting our campus ... can u plz
 tell about the recruitment 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.




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




-- 
Nitin Gupta
B Tech 3rd yr
Information Technology
National Institute of Technology, 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: Algorithms For Interviews

2011-08-16 Thread Nitin Nizhawan
http://www.fileflyer.com/view/XyBZGA8

On Tue, Aug 16, 2011 at 8:07 PM, Yasir yasir@gmail.com wrote:

 Typo: achieves -- archives

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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



Re: [algogeeks] Re: Algorithms For Interviews

2011-08-16 Thread Nitin Nizhawan
sent to you ravi

On Tue, Aug 16, 2011 at 8:16 PM, ravi kumar ravikumar...@gmail.com wrote:


 heyy nitin.. it says da file izz locked .. can u mail me da buk.. thanx in
 advance

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


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



Re: [algogeeks] Number theory

2011-08-16 Thread Nitin Nizhawan
I think 2^(n-1) - 1

On Tue, Aug 16, 2011 at 8:36 PM, sameer gupta gupta.sameer...@gmail.comwrote:

  no. of ways you can write a no. as sum of other non-zero positive
 integers
 like 3 can be written in
 3 ways:
 1+1+1,
 1+2
 2+1
  imp. 2+1 and 1+2 are different
 find the answer and give and prove formula for any value '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.



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

2011-08-16 Thread Nitin Nizhawan
Can someone pls explain what dod's algorithm is doing?
Dod, from where did you get this recursive algo?

On Wed, Aug 17, 2011 at 8:45 AM, Dipankar Patro dip10c...@gmail.com wrote:

 Sieve's is the fastest in generating prime numbers. +1 to Sandeep and
 Sanjay


 On 17 August 2011 08:21, Sanjay Rajpal sanjay.raj...@live.in wrote:

 Agree with Sandeep :)
 Try this link http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes.
 Hope it helps :)


 Sanjay Kumar
 B.Tech Final Year
 Department of Computer Engineering
 National Institute of Technology Kurukshetra
 Kurukshetra - 136119
 Haryana, India


 On Tue, Aug 16, 2011 at 2:28 PM, sandeep pandey 
 sandeep.masum4...@gmail.com wrote:

 try to implement sieve.
 it,s a well known algorithm to find out d prime frequently.

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




 --

 ___

 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.


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

2011-08-15 Thread Nitin
 #includestdio.h
#define fun(arg) do\
{\
if(arg)\
printf(have fun...,\n);\
}while(i--)

main()
{
int i=6;
fun(i5);
}

give the answer and please give the reason for this

#includestdio.h
#define fun(a,b) a##b
 main()
{
int a, b, ab;
a = 1, b = 2, ab = 3;
printf(%d %d, fun(a,b), ab);
return -1;

}
please tell me the use of this # in this program
~

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

2011-08-15 Thread Nitin
#includestdio.h
main()
{
int arr[3]={2,3,4};
char *p;
p=arr;
p=(char *)((int *)(p));
printf(%d,*p);
p=(char *)((int *)(p+1));
printf(%d,*p);
}
it is giving 2,0 why it is giving 0 ..??

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

2011-08-12 Thread Nitin Nizhawan
radix sort the digits wrong way (left most digit first), and then
concatenate

On Fri, Aug 12, 2011 at 6:12 PM, Yasir yasir@gmail.com wrote:

 Kindly  check it with both the examples. It won't work.

 --
 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/-/VlT1DNH-vPkJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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



[algogeeks] Factorial Algorithms

2011-08-12 Thread Nitin Nizhawan
http://www.luschny.de/math/factorial/FastFactorialFunctions.htm
Does anyone know of resource for good/detailed explanation  of factorial
algorithms on this site?

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

2011-08-11 Thread Nitin Nizhawan
i guess answer is c. 4

n*i+1

On Thu, Aug 11, 2011 at 8:01 PM, rShetty rajeevr...@gmail.com wrote:

  A complete n- array tree in which each node has n children or no
 children, let i be the number of internal nodes and L be the number of
 leaves in a complete n- array tree. If L=41 and i=10 what is the value
 of n.

 a. 3b. 6   c. 4


 How to solve such problems??

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



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



Re: [algogeeks] Re: Trees

2011-08-11 Thread Nitin Nizhawan
I am also getting , 5 as answer now. here is what I did.

In any n-ary tree we can add one internal node by adding n-children to any
one of its leaf nodes. This operation creates one internal node and at the
cost one leaf node and adds n new leaf nodes.
L(i) be leaf nodes in a tree with i internal nodes, then
L(i+1) = L(i) + n  - 1
L(0) = 1 , since tree with root node has 0 internal nodes and one leave node
L(i) = L(0) + i*(n-1)
or L(i) = i*(n-1) + 1

On Thu, Aug 11, 2011 at 11:34 PM, Raman raman.u...@gmail.com wrote:

 How is this formula obtained?

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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



Re: [algogeeks] Design .. how to attack ???

2011-08-11 Thread Nitin Nizhawan
I feel such questions are asked to test OO skills so try to identify all the
entities and verbs in the system. Also describing key interfaces in detail
should help.

On Fri, Aug 12, 2011 at 11:20 AM, MAC macatad...@gmail.com wrote:

 Hi guys ,

 Can anyone help me in understanding what is expected when some some one
  asks you  design a car rental system . Exactly what all is required to be
 told to the interviewer .

 --
 thanks
 --mac

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


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



Re: [algogeeks] Re: SPOJ CENCRY

2011-08-10 Thread Nitin Nizhawan
3
eee
cjpvbhntzgm

aeiouaeiouae
vfghjklwerf
eouaeioicou

On Wed, Aug 10, 2011 at 12:06 PM, kartik sachan kartik.sac...@gmail.comwrote:

 any body tell the test 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.


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

2011-08-10 Thread Nitin Nizhawan
inp:
3
eee

vfghjklwerf

out:
cjpvbhntzgm
aeiouaeiouae
eouaeioicou

On Wed, Aug 10, 2011 at 12:40 PM, Nitin Nizhawan
nitin.nizha...@gmail.comwrote:

 3
 eee
 cjpvbhntzgm
 
 aeiouaeiouae
 vfghjklwerf
 eouaeioicou

 On Wed, Aug 10, 2011 at 12:06 PM, kartik sachan 
 kartik.sac...@gmail.comwrote:

 any body tell the test 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.




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

2011-08-10 Thread Nitin Nizhawan
what is comp in your code?


On Wed, Aug 10, 2011 at 6:19 PM, aanchal goyal goyal.aanch...@gmail.comwrote:

 I have a vector of stuct, how to sort this vector?
 problem is I can't overload the '' operator in struct definition, as i
 want to sort by 'x' one time, and then by 'y'. I tried to write the
 comparator function separatley but its no working. How to do it?

 #includeiostream
 #includealgorithm
 #includevector

 using namespace std;


 typedef struct
 {
  int x;
  int y;
 }point;

 struct comp_x
 {
  bool operator()(point a, point b)
   return a.xb.x;
 }

 struct comp_y
 {
  bool operator()(point a, point b)
   return a.yb.y;
 }

 int main()
 {
  vectorpoint vc;
  int n;
  cinn;
  point a;

  for(int i=0;in;i++)
  {
   cina.x;
   cina.y;
   vc.push_back(a);
  }
  coutendl;
  sort(vc.begin(), vc.end(), comp);

  for(int i=0;in;i++)
  {
   coutvc[i].x vc[i].yendl;
  }

  system(pause);
  return 0;
 }


 --
 Regards,*
 Aanchal Goyal*.

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


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



Re: [algogeeks] STL sort

2011-08-10 Thread Nitin Nizhawan
bool operator()(point a, point b){
   return a.xb.x;
 }

remove references it should work. following is working code.
#includeiostream
#includealgorithm
#includevector

using namespace std;


typedef struct
{
 int x;
 int y;
}point;

struct comp_x
{
 bool operator()(point a, point b){
   return a.xb.x;
 }
} compx;

struct comp_y
{
 bool operator()(point a, point b){
  return a.yb.y;
 }
} compy;

int main()
{
 vectorpoint vc;
 int n;
 cinn;
 point a;

 for(int i=0;in;i++)
 {
  cina.x;
  cina.y;
  vc.push_back(a);
 }
 coutendl;

 sort(vc.begin(), vc.end(), compx);
 coutBy X\n;
 for(int i=0;in;i++)
 {
  coutvc[i].x vc[i].yendl;
 }
 sort(vc.begin(), vc.end(), compy);
coutBy Y\n;
for(int i=0;in;i++)
 {
  coutvc[i].x vc[i].yendl;
 }

 return 0;
}


On Wed, Aug 10, 2011 at 6:31 PM, aanchal goyal goyal.aanch...@gmail.comwrote:

 sorry, comp is either comp_x or comp_y


 On Wed, Aug 10, 2011 at 6:24 PM, Nitin Nizhawan 
 nitin.nizha...@gmail.comwrote:

 what is comp in your code?


 On Wed, Aug 10, 2011 at 6:19 PM, aanchal goyal 
 goyal.aanch...@gmail.comwrote:

 I have a vector of stuct, how to sort this vector?
 problem is I can't overload the '' operator in struct definition, as i
 want to sort by 'x' one time, and then by 'y'. I tried to write the
 comparator function separatley but its no working. How to do it?

 #includeiostream
 #includealgorithm
 #includevector

 using namespace std;


 typedef struct
 {
  int x;
  int y;
 }point;

 struct comp_x
 {
  bool operator()(point a, point b)
   return a.xb.x;
 }

 struct comp_y
 {
  bool operator()(point a, point b)
   return a.yb.y;
 }

 int main()
 {
  vectorpoint vc;
  int n;
  cinn;
  point a;

  for(int i=0;in;i++)
  {
   cina.x;
   cina.y;
   vc.push_back(a);
  }
  coutendl;
  sort(vc.begin(), vc.end(), comp);

  for(int i=0;in;i++)
  {
   coutvc[i].x vc[i].yendl;
  }

  system(pause);
  return 0;
 }


 --
 Regards,*
 Aanchal Goyal*.

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

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


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



Re: [algogeeks] m'th max element

2011-08-08 Thread Nitin Nizhawan
Selection algorithm, http://en.wikipedia.org/wiki/Selection_algorithm

On Mon, Aug 8, 2011 at 3:59 PM, nick tarunguptaa...@gmail.com wrote:

 how will you find the m'th maximum element in an unsorted array of
 integers?

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


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



Re: [algogeeks] Random number

2011-08-08 Thread Nitin Nizhawan
following solution should work but it uses an array so its ST is O(N)

#include stdio.h
#include time.h
#define MAX 500
/** copied from wikipedia
  *
  */
unsigned m_w = time(NULL);/* must not be zero */
unsigned m_z = 300;/* must not be zero */

unsigned long get_random()
{
m_z = 36969 * (m_z  65535) + (m_z  16);
m_w = 18000 * (m_w  65535) + (m_w  16);
return (m_z  16) + m_w;  /* 32-bit result */
}

// CLRS
void randomize(int list[],int size){
  for(int i=0;isize;i++){
  int rand = i+get_random()%(size-i);

  // swap
  int tmp = list[i];
  list[i] = list[rand];
  list[rand] = tmp;
  }
}

int main(){
  int A[MAX];
  int N,M; // assuming NMAX , MN
  scanf(%d,N);
  scanf(%d,M);
  for(int i=0;iN;i++){
  A[i]=i;
  }
  randomize(A,N);
  for(int i=0;iM;i++){
  printf(%d ,A[i]);
  }
}

On Mon, Aug 8, 2011 at 6:02 PM, Gaurav Menghani
gaurav.mengh...@gmail.comwrote:

 The space complexity is O(1)

 I know about hash-tables. Can you implement with O(1) space complexity?

 On Mon, Aug 8, 2011 at 10:56 AM, 석문기 smgs2...@gmail.com wrote:
  Box-muller method is the good solution without a lot of computation
 overhead
 
  2011/8/8 Puneet Gautam puneet.nsi...@gmail.com
 
  You may be right..we cant remove collisions in O(1) time...
 
  But hey, hash table is still an effective way..
 
 
  On 8/8/11, Puneet Gautam puneet.nsi...@gmail.com wrote:
   Hey avoiding collisions using hash table can be real easy :
   eg:
   if 192 is the no generated let it hash to say index 7 of hash
   table...so when it is again generated, it hashes to the same 7th index
   of hash table, but we have a non zero value already present at that
   index , 192 so we can reject this generated no. and proceed to the
   next one..
  
   Whereas in an array , avoiding collision is a really hectic way...u
   need to scan all the previously generated no.s for duplicacy...well
   that aint gonna run in O(1) time..
  
   So implementing hash table reduces that overhead and runs it in O(1)
   time..(it just has to check one if condition)with a bigger
   constant.
  
   And moreover, we may even dont want an ordered sequence...just put the
   generated no.s in hash table as soon as they are generated...dats it..
  
   then afterwards display that hash table..
  
   Did u get me...?
  
  
   On 8/7/11, Gaurav Menghani gaurav.mengh...@gmail.com wrote:
   We can have a sorted sequence and display them in random order, but
   that is the same problem. How do we display them in random order? We
   need to have a sequence of random indices, that is the same problem
 as
   having random numbers, isn't it.
  
   Moreover, I don't think collisions can be avoided in less than O(n).
   We can have an efficient hash-table, but I am not sure how it can be
   done in O(1) or better.
  
   On Sat, Aug 6, 2011 at 12:37 PM, Puneet Gautam
   puneet.nsi...@gmail.com
   wrote:
   I rhink to avoid collisions altogether we should generate an ordered
   sequence , in a dec. or inc. order and
   display them randomly, i mean:
  
   Let say a[10] contains all the random no.s , map all the 10 indexes
 to
   a hash table and then display the arrays with the hashed index...
  
   I think it may work...
  
   what say..?
  
  
   On 8/5/11, Gaurav Menghani gaurav.mengh...@gmail.com wrote:
   1. Get a good seed.
   2. Increase the degree of the polynomial.
  
   This is no fixed algorithm, if you find that more than T steps have
   passed and a new number has not been generated, you can always
 change
   the polynomial. And, please remember it is a 'pseudo-random number
   generator'. You can read the theory about PRNGs and LFSRs, all of
   them
   repeat.
  
   On Fri, Aug 5, 2011 at 7:14 PM, payel roy smithpa...@gmail.com
   wrote:
   How do you guarantee termination of your algorithm if duplication
   occurs
   ??
  
   On 5 August 2011 18:25, Gaurav Menghani 
 gaurav.mengh...@gmail.com
   wrote:
  
   You might want to read the theory on Pseudo-Random Number
   Generators
   [0] and Linear Feedback Shift Register [1]
  
   The basic way of generating a random number is taking up a
   polynomial,
   f(x) = ax^n + bx^(n-1) + .. + yx + z, and finding f(i + seed) %
 N,
   where i is the ith random number you want, and seed can be
 anything
   random available, for example, you can find the current
 millisecond
   using time.h functions.
  
   A simple implementation, without the time thing is below:
  
   #includeiostream
   using namespace std;
  
   int poly[10],pn,N,M;
   int get(int seed)
   {
  int t=0;
  for(int i=0;ipn;i++)
  {
  int res=poly[i];
  for(int j=1;j=(i+1);j++) { res = (res*seed);
   if(res=N)
   res%=N; }
  t+=res;
  if(t=N) t%=N;
  }
  t=(t+seed);
  t%=N;
  return t;
   }
  
   void setup_prng()
   {
  pn=5;
  poly[0]=2; poly[1]=3; poly[2]=5; poly[3]=7; poly[4]=11;
  N=200; 

Re: [algogeeks] suggest simple code for

2011-08-08 Thread Nitin Nizhawan
I think this should work

void finddepth(Node *node,int depth){
  if(node!=NULL){
 depth = max( finddepth(node-left,depth+1),
 finddepth(node-right,depth+1) );
  }
  return depth;
}

On Mon, Aug 8, 2011 at 6:33 PM, jagrati verma
jagrativermamn...@gmail.comwrote:

  finding the depth or height of a tree.

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



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



[algogeeks] pre-post decrement

2011-08-08 Thread Nitin
main()
{
int i=10;
int z;
z=--i--;
}
this gives an lvalue required error ,what i want to know is when the post
decrement gets executed then whether the expression should be --i or --10,as
it is --10 thats y its givin lvalue required error but y is it so as if we
increment or decrement using post or pre operator variable is updated not it
is replaced by value.???

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



Re: [algogeeks] Re: nlogn, in-place, iterative mergesort?

2011-08-07 Thread Nitin Nizhawan
Thanks everyone,

  Achieving nlogn, interative, and in-place separately is easy. But I did
not know of algo that achieves all these simultaneously for merge sort.
  Thanks DK for pointing to that paper I wonder if algorithm presented in
paper is also stable.

--Nitin

On Sun, Aug 7, 2011 at 5:10 PM, immanuel kingston 
kingston.imman...@gmail.com wrote:

 @DK and Amit, thanks for correcting my understanding.



 On Sun, Aug 7, 2011 at 3:51 PM, amit karmakar 
 amit.codenam...@gmail.comwrote:

 @DK
 Hmm, i do understand what you said. Maybe, i should make it clear that
 i just wanted to tell that implementing a non-recursive merge-sort
 will not require explicit stacks and is actually easier to implement.
 This was because someone mentioned using stacks to remove recursion. I
 didn't mean to tell anything more than that. :)

 On Aug 7, 3:07 pm, DK divyekap...@gmail.com wrote:
  @Amit and @Immanuel: You're not getting the point. Merge sort is not
  in-place because it requires an extra O(N) array during the merge step.
  The problem asks not to remove the recursive nature of the merge-sort
 but to
  remove the non-in-place nature of merge sort by removing the need for
 that
  extra array. This is a research problem that has been solved and there
 have
  been multiple papers on the topic. I've posted the earliest one that
 forms
  the basis of this field.
 
  --
  DK
 
 
 http://gplus.to/divyekapoorhttp://twitter.com/divyekapoorhttp://www.divye.in

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


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


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



Re: [algogeeks] Re: nlogn, in-place, iterative mergesort?

2011-08-07 Thread Nitin Nizhawan
good Joke :)

On Mon, Aug 8, 2011 at 1:43 AM, DK divyekap...@gmail.com wrote:

 @Nitin: In-place merge sorts are not stable (atleast I haven't come across
 a stable one - you might want to create one as research? ;) ).

 --
 DK

 http://twitter.com/divyekapoor
 http://gplus.to/divyekapoor
 http://www.divye.in

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/8r0X6w8Z3eIJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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



Re: [algogeeks] Re: adobe

2011-08-06 Thread Nitin Nizhawan
http://trickofmind.com/?p=1080
i think this will help, we need to find Carmichael number or somthing
related to ETF for the input number.

On Sat, Aug 6, 2011 at 12:24 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 @sumit, these numbers containing all ones are not in binary representation.
 They are in decimal system.


 On Sat, Aug 6, 2011 at 9:51 AM, sahil gujral gujralsa...@gmail.comwrote:

 yes u r wrong..
 1 is nt divisible by 23


 On Sat, Aug 6, 2011 at 9:15 AM, sumit sumitispar...@gmail.com wrote:

 This looks quite simple.
 Every number ending in 3 follows a pattern.eg-
 3 - 111
 13 - 11
 23 - 1 etc
 we can find the reauired no. by :
 suppose input no. is 33
 In every case leave the no at 1's place(least significant) i.e. 3, In
 33 you will be left with 3(after removal of 3 at first place).
 Now ,3 *(rest of nos +1 ) is your answer (in case of 33 it is 3*(3+1)
 = 12 i.e  ).
 for 103 it is 3*(10+1) = 33 1's.

 Correct if I am wrong.


 On Aug 5, 4:33 pm, Manee mani.ma...@gmail.com wrote:
  ADOBE asks the very basic C/C++ questions
 
  one of their toughest however was :
 
  every number ending in 3 has a multiple of the form 111...111
 
  e.g 3 has 111
   13 has 11
  so on..
 
  find the algo for finding the number for an input number ending in 3.
 
  On Aug 5, 2:33 pm, Agyat jalsa.n.sa...@gmail.com wrote:
 
 
 
 
 
 
 
   hey, guys adobe is visiting our campus. So those who know questions
   that adobe asked in written or interview, please post here as it will
   be of great help (as adobe has visited some colleges already).
   Thank you in advance.

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


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




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

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


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



Re: [algogeeks] Directi Question

2011-08-06 Thread Nitin Gupta
1/6*5/6*5/6*3+ 1/6*1/6*5/6*3+ 1/6*1/6*1/6 =91/216

On Sat, Aug 6, 2011 at 8:24 PM, muthu raj muthura...@gmail.com wrote:

 Microsoft written:

 What is the probability of getting atleast one 6 in  3 attempts of a dice?


 *Muthuraj R
 IV th Year , ISE
 PESIT , Bangalore*




 On Sat, Aug 6, 2011 at 7:34 AM, shady sinv...@gmail.com wrote:

 Hi,

 A fair dice is rolled. Each time the value is noted and running sum is
 maintained. What is the expected number of runs needed so that the sum is
 even ?
 Can anyone tell how to solve this problem ? as well as other related
 problems of such sort

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


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


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



Re: [algogeeks] size -------

2011-08-06 Thread Nitin
I am also getting 24 bytes but y it is taking it every data type as 8,8,8 as
if we take it alone it is 1 for char and 4 for int and 8 for doble as it is
giving 24 which means it is setting every data type as 8 bytes.

On Sat, Aug 6, 2011 at 9:28 PM, Aditya Virmani virmanisadi...@gmail.comwrote:

 i guess it depends on ur system configuration...for 32 bit
 machines...respective sizes allocated would be 4,4,8 :giving 16
  on 64 bit machines it wud be 8,8,8: giving 24. Correct me if i am wrong.


 On Sat, Aug 6, 2011 at 9:24 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote:

 @ sukran , nitish :
 guys, i dnt knw about the output from these online compliers..


 On Sat, Aug 6, 2011 at 9:20 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote:


 @payel : according to u,,starting address cannot be 4.. ok.
 but wat if i hav used the following structure before that structure

 struct demo1
 {
 char a;
 int b;
 char c;

 }


 On Sat, Aug 6, 2011 at 9:06 PM, Nitish Garg nitishgarg1...@gmail.comwrote:

 Why does Ideone https://ideone.com/1Uwxx gives 16?

 --
 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/-/L-zANxDDTUQJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



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


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


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



Re: [algogeeks] nlogn, in-place, iterative mergesort?

2011-08-06 Thread Nitin Nizhawan
inplace?

On Sat, Aug 6, 2011 at 10:27 PM, immanuel kingston 
kingston.imman...@gmail.com wrote:

 Yes. just remove the recursive part using 2 stacks.

 Thanks,
 Immanuel

 On Fri, Aug 5, 2011 at 6:51 PM, Nitin Nizhawan 
 nitin.nizha...@gmail.comwrote:

  does anyone know of any in-place, iterative mergesort algorithm with
 nlogN worst case complexity? It would be good if it is stable also.

 TIA
 Nitin

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


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


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



Re: [algogeeks] pls help

2011-08-05 Thread Nitin Nizhawan
Or one could just simulate a counting from 0 to (numchars^N)-1 in base
numchars.
...
code:
void printit(int N,char chars[],int index[]){
for(int i=0;iN;i++){
printf(%c,chars[index[i]]);
}
printf(\n);
}
void generate(int numchars,char chars[],int N){
int index[100]={0};
int allmax=0;
int maxdigit=numchars-1;
printit(N,chars,index);
while(!allmax){
   // add one;
   index[0]++;
   allmax=0;
   for(int i=0;iN;i++){
if(index[i]=numchars){
 index[i]=0; index[i+1]++;
}
if(i==0index[i]==maxdigit){
   allmax=1;
}

   allmax = (index[i]==maxdigit)?allmax1:0;

   }
   printit(N,chars,index);
}
}
int  main(){
 char chars [] ={'p','o'};
 int numchars =sizeof(chars)/sizeof(char);
 int N=3;
 generate(numchars,chars,N);
}

On Fri, Aug 5, 2011 at 12:58 PM, Gaurav Menghani
gaurav.mengh...@gmail.comwrote:

 An Implementation:

 #includeiostream
 #includestring
 using namespace std;

 string alphabet;
 int maxlen;
 void backtrack(string s,int l)
 {
  if(l==maxlen) { coutsendl; return; }
  s.push_back('-');
  for(int i=0;ialphabet.size();i++)
{ s[l]=alphabet[i]; backtrack(s,l+1); }
 }

 int main()
 {
  maxlen=3;
  alphabet=op;
  backtrack(,0);
  return 0;
 }


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



 --
 Gaurav Menghani

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



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

On Fri, Aug 5, 2011 at 2:53 PM, Gaurav Menghani
gaurav.mengh...@gmail.comwrote:

 Even if the number of elements is more than two, it is possible with
 bitwise operations, but it gets clumsy.

 Suppose your alphabet has 4 characters. You can either:
 - Count from 0 to (14*n)-1 and use four bits to denote the selection
 of the alphabet. Also, only one bit amongst those four should be set.
 It is highly inefficient.
 - Keep n nested loops and inside each loop you iterate from 0 to
 (14)-1 and use the standard bitwise operations. The con here is that
 you have to hardcode the number of nested loops.

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



 --
 Gaurav Menghani

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



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post

Re: [algogeeks] probabilty

2011-08-05 Thread Nitin Nizhawan
1/8

On Fri, Aug 5, 2011 at 4:19 PM, nethaji guru nethaji.1...@gmail.com wrote:

 3 /4

 --
 With regards,
  Nethaji Guru

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


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



Re: [algogeeks] probabilty

2011-08-05 Thread Nitin Nizhawan
yes it cant be 1/8 I was wrong.

On Fri, Aug 5, 2011 at 4:23 PM, coder dumca coder.du...@gmail.com wrote:

 i think it should  be 3/4


 On Fri, Aug 5, 2011 at 4:20 PM, aditi garg aditi.garg.6...@gmail.comwrote:

 1/8

 On Fri, Aug 5, 2011 at 4:14 PM, coder dumca coder.du...@gmail.comwrote:

  A man speaks truth 3 out of 4 times. He throws a die and reports it to
 be a 6.
 What is the probability of it being a 6?

 1 /2
 3 /4
 5 /8
 1 /8

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




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


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


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


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



Re: [algogeeks] probabilty

2011-08-05 Thread Nitin Nizhawan
A dice is 6
B reports 6


P(A) = 1/6
P(!A) = 5/6
P(B|!A) =(1/4)*(1/5)
P(B|A) =  (3/4)


P(A|B) = P(B|A)*P(A)/( P(B|A)*P(A) + P(B|!A)*P(!A))
 =((3/4)*(1/6))/( (3/4)*(1/6) + (1/4)*(1/5)*(5/6))
 = 3/4

On Fri, Aug 5, 2011 at 4:50 PM, tarang dawer tarrang1...@gmail.com wrote:

 1/2



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


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



[algogeeks] Samsung Written

2011-08-05 Thread Nitin
can anybody give details for smasung written and interview ?

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

2011-08-05 Thread Nitin Nizhawan
x = x16 | (0xx)16
this line exchanges ls 16bits with ms 16bits, i.e. 1 pair of 16bit

this logic of exchanging bits is the used for 2 pairs of 8bits each, then
for 4 pairs of 4bit, then for 8 pairs of 2 bit and finally 16 pairs of 1bit.


On Fri, Aug 5, 2011 at 6:04 PM, rShetty rajeevr...@gmail.com wrote:

 This is the code to reverse the bits in an unsigned integer .
 Could anyone please explain the logic of this approach ? Thank You !!

 #define reverse(x) \
 (x=x16|(0xx)16, \
 x=(0xff00ff00x)8|(0x00ff00ffx)8, \
 x=(0xf0f0f0f0x)4|(0x0f0f0f0fx)4, \
 x=(0xx)2|(0xx)2, \
 x=(0xx)1|(0xx)1)

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



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



Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-05 Thread Nitin Nizhawan
if input starts with one or more characters from the string A telephone
girl then it will give SEG FAULT because it scanf will try to write to CS,
else initial value junk will be printed

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

 for some inputs its giving junk as the answer and for others its giving
 segmentation fault

 could u plese explain why

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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



[algogeeks] nlogn, in-place, iterative mergesort?

2011-08-05 Thread Nitin Nizhawan
 does anyone know of any in-place, iterative mergesort algorithm with nlogN
worst case complexity? It would be good if it is stable also.

TIA
Nitin

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



  1   2   >