Re: [algogeeks] [URGENNT] : naukri.com paper pattern

2012-03-28 Thread Aman Goyal
10 multiple choice questions on C : very easy , Kanetkar will suffice.

Aptitude : subjective , with mostly mathematical puzzles . Lengthy due to
time consuming problems. Focus on accuracy .Series completion, Time speed
distance,permutation and combination is what i can recall in the aptitude
paper.

On Tue, Mar 27, 2012 at 8:07 PM, aditya gupta g.aditya.i...@gmail.comwrote:

 Hi all,

 nauri.com is visiting at my friend's college , can someone plz tell the
 pattern of its 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.



Re: [algogeeks] Apti

2011-08-23 Thread Aman Goyal
ans is 12, but instead of counting i am looking for some better solution.

On Tue, Aug 23, 2011 at 10:48 PM, manish patel manispatel...@gmail.comwrote:


 (24,33),(12,66),(8,99),(6,132),(4,198),(3,254),(2,396),(1,792),(792,1),(72,11),(264,3),(33,24)

 On Tue, Aug 23, 2011 at 10:18 PM, Aman Goyal aman.goya...@gmail.comwrote:

 Let a natural number N be such that N = a × b where a and b are the
 factors of N. How many such sets of (a, b) can be formed in which the
 selection of the two numbers a and b is distinctly different if N = 24 × 33?

 Please explain your solution also.

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




 --
 With Regards

 Manish Patel
 BTech 3rd Year
 Computer Science And Engineering
 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.


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

2011-08-06 Thread Aman Goyal
Can anyone suggests a good data structure for n-ary tree.. where n is the
input by the user...

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

2011-08-06 Thread Aman Goyal
thanks, by no means we can add the child nodes dynamically to the father
node??

On Sat, Aug 6, 2011 at 5:33 PM, rohit q.ro...@gmail.com wrote:

 use a linked list to store child nodes, a tree node will hold pointer
 to next sibling and a pointer to its first child.
 typedef struct TreeNode{
 struct TreeNode * nextSibling;
 struct TreeNode * fistChild;
 //rest things
 }

 On Aug 6, 4:10 pm, Aman Goyal aman.goya...@gmail.com wrote:
  Can anyone suggests a good data structure for n-ary tree.. where n is the
  input by the user...

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



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

2011-08-06 Thread Aman Goyal
.. pseudo code for finding inorder successor of a node without parent
field..

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, 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 Aman Goyal
as an eg.
let ab be the string, and 3 characters length string is wht is expected..

a - -
b - -

a a -
a b -

b a -
b b -


a a a
a a b

a b a
a b b

b a a
b a b

b b a
b b b






On Fri, Aug 5, 2011 at 12:49 PM, Gaurav Menghani
gaurav.mengh...@gmail.comwrote:

 The basic idea is that for every position of the string, you fill it
 with all possible alphabets in your set of allowed alphabets, let the
 set be called alphabet.

 Now, you can do this recursively.
 backtrack(s,l) denotes, a string s has been formed, and is of length
 l. Now we need to add more letters to it. If l is equal to the maximum
 length, then you just print the string s, and return.

 Otherwise, append the characters available to you. For example, if in
 the current scenario, the call is backtrack(po,2), and alphabet =
 {'o','p'} and maxlen=3, then we can append 'o' and 'p' to the string
 po, and hence call backtrack(poo,3) and backtrack(pop,3).

 You start the process by calling backtrack(,0), and setting maxlen
 and alphabet to the appropriate values.

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

2011-08-05 Thread Aman Goyal
physical address i suppose...

On Fri, Aug 5, 2011 at 1:09 PM, anurag anurag19aggar...@gmail.com wrote:

 What will be the output.

 int i=5;
 printf(%u,i);
 What it will print:
 i. 5
 ii. Base address of the memory
 iii. Physical address
 iv. Logical address

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



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

2011-08-04 Thread Aman Goyal
How to find the largest BST in a binary tree.



15
/ \
10__ 20
/ \
5 _7
/ \
2_ __5
/ \/
0 8 3

The largest BST (may or may not include all of its descendants) from the
above example should be:

15
/ \
_10 20
/
5


Please do not post working code, logic/algorithm or link would be preferred.
I know it will be through recursion  , still the logic part of recursion is
not clear.. would be thankful if anyone could 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] Data Structure to design logn LCA

2011-08-04 Thread Aman Goyal
* Nearest Common Ancestor*

 Given a rooted tree of size * n *. You receive a series of online queries :
* Give nearest common ancestor of u,v  *. Your objective is to preprocess
the tree in * O(n) * time to get a data structure of size * O(n) * so that
you can answer any such query in * O(log n) * time.

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



Re: [algogeeks] Largest Bst in a binary tree.

2011-08-04 Thread Aman Goyal
while dequing  a node from the queue, how will u check whether a bst
property is sattisfied or not ?..

On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.com wrote:

 I have some upto this much currently.
 Modify the Breadth First traversal (BFT) a bit. maintain two queues, one is
 for original traversal.

 Start from root,  BFT. when you dequeue a node, check if it satisfies the
 condition for BST. if yes add the the node to auxiliary queue, if not, leave
 it and add it's original children to the original queue in both cases.
 Some further modifications can the done to have multiple auxiliary queues
 and keep track of their heights.

 What say?


 On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote:

 Yes, that can be a liable case definitely!!!


 On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro dip10c...@gmail.comwrote:

 The question is a bit tricky.
 Is it possible that the largest BST is somewhere in deeper depth, i.e. it
 is not necessarily consisting of the root?

 On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote:

 How to find the largest BST in a binary tree.



 15
 / \
 10__ 20
 / \
 5 _7
 / \
 2_ __5
 / \/
 0 8 3

 The largest BST (may or may not include all of its descendants) from the
 above example should be:

 15
 / \
 _10 20
 /
 5


 Please do not post working code, logic/algorithm or link would be
 preferred.
 I know it will be through recursion  , still the logic part of recursion
 is not clear.. would be thankful if anyone could 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.




 --

 ___

 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.




 --

 ___

 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.



Re: [algogeeks] Largest Bst in a binary tree.

2011-08-04 Thread Aman Goyal
@sagar : I m confused of how that can be done..

could u elaborate

On Fri, Aug 5, 2011 at 10:00 AM, Aman Goyal aman.goya...@gmail.com wrote:

 while dequing  a node from the queue, how will u check whether a bst
 property is sattisfied or not ?..


 On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.comwrote:

 I have some upto this much currently.
 Modify the Breadth First traversal (BFT) a bit. maintain two queues, one
 is for original traversal.

 Start from root,  BFT. when you dequeue a node, check if it satisfies the
 condition for BST. if yes add the the node to auxiliary queue, if not, leave
 it and add it's original children to the original queue in both cases.
 Some further modifications can the done to have multiple auxiliary queues
 and keep track of their heights.

 What say?


 On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote:

 Yes, that can be a liable case definitely!!!


 On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro dip10c...@gmail.comwrote:

 The question is a bit tricky.
 Is it possible that the largest BST is somewhere in deeper depth, i.e.
 it is not necessarily consisting of the root?

 On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote:

 How to find the largest BST in a binary tree.



 15
 / \
 10__ 20
 / \
 5 _7
 / \
 2_ __5
 / \/
 0 8 3

 The largest BST (may or may not include all of its descendants) from
 the above example should be:

 15
 / \
 _10 20
 /
 5


 Please do not post working code, logic/algorithm or link would be
 preferred.
 I know it will be through recursion  , still the logic part of
 recursion is not clear.. would be thankful if anyone could 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.




 --

 ___

 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.




 --

 ___

 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.



Re: [algogeeks] Largest Bst in a binary tree.

2011-08-04 Thread Aman Goyal
@siddharam: nice approach, just a query increasing inorder traversal of
a tree is a sufficient condition to check for a BST ?

On Fri, Aug 5, 2011 at 10:05 AM, siddharam suresh
siddharam@gmail.comwrote:

 my idea is go for inorder traversal find the longest sorted sequence in
 traversal thats the *'largest BST in a binary tree.'* 
 Thank you,
 Siddharam



 On Fri, Aug 5, 2011 at 10:00 AM, Aman Goyal aman.goya...@gmail.comwrote:

 while dequing  a node from the queue, how will u check whether a bst
 property is sattisfied or not ?..


 On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.comwrote:

 I have some upto this much currently.
 Modify the Breadth First traversal (BFT) a bit. maintain two queues, one
 is for original traversal.

 Start from root,  BFT. when you dequeue a node, check if it satisfies the
 condition for BST. if yes add the the node to auxiliary queue, if not, leave
 it and add it's original children to the original queue in both cases.
 Some further modifications can the done to have multiple auxiliary queues
 and keep track of their heights.

 What say?


 On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote:

 Yes, that can be a liable case definitely!!!


 On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro dip10c...@gmail.comwrote:

 The question is a bit tricky.
 Is it possible that the largest BST is somewhere in deeper depth, i.e.
 it is not necessarily consisting of the root?

 On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote:

 How to find the largest BST in a binary tree.



 15
 / \
 10__ 20
 / \
 5 _7
 / \
 2_ __5
 / \/
 0 8 3

 The largest BST (may or may not include all of its descendants) from
 the above example should be:

 15
 / \
 _10 20
 /
 5


 Please do not post working code, logic/algorithm or link would be
 preferred.
 I know it will be through recursion  , still the logic part of
 recursion is not clear.. would be thankful if anyone could 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.




 --

 ___

 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.




 --

 ___

 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.


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


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

2011-08-04 Thread Aman Goyal
You are given two height balanced binary search trees T and T', storing m
and n elements respectively. Every element of tree T is smaller than every
element of tree T'. Every node u also stores height of the subtree rooted at
it. Using this extra information how can you merge the two trees in time
O(log m + log n) (preserving both the height balance and the order)?

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



Re: [algogeeks] Data Structure to design logn LCA

2011-08-04 Thread Aman Goyal
thanks gaurav !

On Fri, Aug 5, 2011 at 9:45 AM, Gaurav Menghani
gaurav.mengh...@gmail.comwrote:

 On Fri, Aug 5, 2011 at 9:41 AM, Aman Goyal aman.goya...@gmail.com wrote:
  You receive a series of online queries : Give nearest common ancestor of
  u,v  . Your objective is to preprocess the tree in O(n) time to get a
 data
  structure of size O(n) so that you can answer any such query in O(log n)
  time.

 Segment tree [0] is what you are looking for.

 [0]
 http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor


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



[algogeeks] C output

2011-07-28 Thread Aman Goyal
#include‹stdio.h›
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}

ouput: compiler error.

Any logical reasons?

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



Re: [algogeeks] direct i ..ques

2011-07-28 Thread Aman Goyal
c(n,2) * c(n,2)

On Wed, Jul 27, 2011 at 11:07 PM, siva viknesh sivavikne...@gmail.comwrote:

 No. rectangles in NxN matrix

 ... is it   n^2 + (n-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.



Re: [algogeeks] self referential struct. Contd.

2011-07-28 Thread Aman Goyal
yes this will be the case.

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

 @nikhil:So what u mean is that if i have:

 struct{
 int a;
 char b[5];
 };

 the size of this struct's node will be 12 not 9.., to make it a multiple of
 4??



 On 7/26/11, Nikhil Gupta nikhilgupta2...@gmail.com wrote:
  Padding is not a topic of self referential structure.
 
  Padding means that extra spaces of memory are used by the compiler to
  allocate memory. This is done to have the memory address as a multiple of
  the size of the variable. This speeds up the processing of these
 variables
  by the compiler.
 
  On Tue, Jul 26, 2011 at 8:09 PM, Puneet Gautam
  puneet.nsi...@gmail.comwrote:
 
  what is meant by padding in self_referenced structure?
  Is it always necessary?
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.



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

2011-07-28 Thread Aman Goyal
(C(n+1,2))* (C(n+1,2))

choosing any two rows from n+1 rows, and any two columns from n+1 columns
will yield a rectangle .
So solution is the no of possible combinations.

On Wed, Jul 27, 2011 at 11:23 PM, Abhinav Arora
abhinavdgr8b...@gmail.comwrote:

 It will be (1+2+3+,,,+n)^2.u can verify it for a chess board hich will
 have 1296 rectangles for n=8

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

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


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

2011-07-21 Thread Aman Goyal
I think it is kind of illegal to use it, cos i tried this code on gcc
compiler oof ubuntu(code b) and the result is infinite loop, which doesnt go
with our logic at all.

On Thu, Jul 21, 2011 at 5:45 PM, karthiga m karthichandr...@gmail.comwrote:

 no it is legal only... its working 

 On 7/21/11, Reynald Suz reynaldsus...@gmail.com wrote:
  I tried in Dev C++,code-B executes infinitely. Why?
 
  On Thu, Jul 21, 2011 at 4:13 PM, Gaurav Popli abeygau...@gmail.com
 wrote:
 
  dont you think it is illegal using x=x-- or x=--x;??
 
  On Thu, Jul 21, 2011 at 2:56 PM, karthiga m karthichandr...@gmail.com
  wrote:
   in code  A using pr e- decrement  therefore i gets decremented when
   checking while condition so
   it will print as 9 8 7  6 5 4 3 2 1 .
   in code B using post-decrement  it will prints like 9 8 7 6 5 4 3 2 1
 0
   here why zero printing means while checking while condition x-- have
   previous value..therefore at tht time x-- is 1 so while condition
   executing and prints x value as zero.
  
   On 7/21/11, Reynald reynaldsus...@gmail.com wrote:
   Code: A
   int main()
   {
   int x = 10;
   while ( x = --x)
   printf(  %d , x);
   getchar();
   }
  
   Code: B
   int main()
   {
   int x = 10;
   while ( x = x--)
   printf(  %d , x);
   getchar();
   }
  
   Does Code-A and Code-B work similar? Justify.
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
  Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
  
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Regards
  Reynald Reni
  Masters in Software Engineering
  CIT - India
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

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



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

2011-07-21 Thread Aman Goyal
they start shooting the person standing next to their neighbour

On Thu, Jul 21, 2011 at 4:38 PM, Vivek Srivastava 
srivastava.vivek1...@gmail.com wrote:

 No,That is not the sequence?As I said 'I' will kill '3' as 3 is next to i's
 neighbour.

 On Thu, Jul 21, 2011 at 4:16 PM, SAMMM somnath.nit...@gmail.com wrote:

 Consider this Example:-



  1 2 3 4 5 6 7 1 In CIrcle 

  1 kills 2
  3 kills 4
  5 kills 6
  7 kills 1

 Remaining ppl :- 3 5 7

 3 kills 5
 7 kills 3

 Remain- 7


 This  is the sequence .. i guess   Isit

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


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


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



Re: [algogeeks] MS: Testing

2011-07-21 Thread Aman Goyal
Please specify the format of the date..!

On Thu, Jul 21, 2011 at 3:28 PM, Radhika Renganathan
radi.coo...@gmail.comwrote:

 Write test cases for a program which finds the next palindromic date given
 a date.

 --
  radhika ..

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


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

2011-07-21 Thread Aman Goyal
My mistake, i forgot to initiate x.

Sorry for the mistake. But for devc it is infinite, then  should we ignore
that?

On Thu, Jul 21, 2011 at 7:40 PM, poised dip10c...@gmail.com wrote:

 Both the codes work perfectly on Ubuntu 11.04. (gcc)

 first code gives 0 in output.
 second one doesn't give 0 in output.

 both work as intended.

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

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


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



Re: [algogeeks] Re: Microsoft Question!

2011-07-21 Thread Aman Goyal
@ankit gupta: superb solutn

On Thu, Jul 21, 2011 at 8:09 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:

 To get complete 32 bit inverse :

 x=((x1)0x) | ((x1)0x);
 x=((x2)0x) | ((x2)0x);
 x=((x4)0x0F0F0F0F) | ((x4)0xF0F0F0F0);
 x=((x8)0x00FF00FF) | ((x8)0xFF00FF00);
 x=((x16)0x) | ((x16)0x);

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


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



Re: [algogeeks] BIT MANIPULATION

2011-07-09 Thread Aman Goyal
Solutn:

1101000

Start from rightmost bit-leftmost bit

Find the starting and ending 1’s positions, here 3 and 7

If any 0 bw them… while traversing.. (bitwise r-l)..  make it 1 and other
adjacent right ” 1” as  “0”. And this is your new no. here 111


If you find no “0” in bw ( eg for 00)

Then ,a bit will be increased.

Make first  bit from left 1 and  set the lower order  (total_set_bits-1)
bits..  this will be the new no.

Here : 1000111.


On Sat, Jul 9, 2011 at 2:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:

 I found a good question to try for bit manipulation.Try it... :)

 Given an integer x, find out the smallest integer which has same
 number of set bits as x and is greater than x.

 For example if the input integer is 12 (1100) then your function
 should return 17(10001). If the input integer is 3(11) then your
 function should return 5(101)

 --
 *Piyush Sinha*
 *IIIT, Allahabad*
 *+91-8792136657*
 *+91-7483122727*
 *https://www.facebook.com/profile.php?id=10655377926 *

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



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



Re: [algogeeks] puzzle

2011-07-09 Thread Aman Goyal
210 for the last one you posted

On Sat, Jul 9, 2011 at 4:33 PM, amit the cool amitthecoo...@gmail.comwrote:

 6,24,60,120,_

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



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



Re: [algogeeks] Google Question

2011-07-08 Thread Aman Goyal
may be by checking the server logs !!


On Fri, Jul 8, 2011 at 11:48 AM, Vishal Thanki vishaltha...@gmail.comwrote:

 google this question!!

 On Fri, Jul 8, 2011 at 11:47 AM, priyanshu priyanshuro...@gmail.com
 wrote:
  How to find the number users connected to the web??
 
  --
  You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 

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



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

2011-07-08 Thread Aman Goyal
Algo:

1 3 77 78 90
2 5 79 81

compare 1 2 =1
compare 3 2 =2 and call binary search on 2nd array widot 2 to identify a
proper position for 3 and place it there.
now arrays

1 2 77 78 90
3 5 79 81
3 and 77= swap + binary

compare 3 and 77, swap them
find position of 77 in second array and place there. using binary search

1 2 3 78 90
5 77 79 81
78 and 5 = swap + binary search

1 2 3 5 90
77 78 79 81

90 and 77= swap+ binary

1 2 3 5 77
78 79 81 90

ans found

O(nlogn)
binary search is O(logn) .

On Fri, Jul 8, 2011 at 8:29 AM, durgesh kumar durgesh1...@gmail.com wrote:


 @dumanshu

  ok ! i got a O(n lgn) finally
  i don know exact complexity
  Let N = size of first array
  Find the first N smallest elements using one pointer in each array
  now swap the list of elements  from index 0 to second-pointer in
  second array to first array
  with first_poiner+1 to N in first Array
  now,after swapnig we need to sort both array




 so complexity= n + n log n+ m log m (n is the size of of first array and m
 is the size of second array)
  .
 . . O(n) = (n log n ) or (m log m)
 thanks
 Durgesh

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


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



Re: [algogeeks] puzzle

2011-07-08 Thread Aman Goyal
Now let x be the answer we want, the number of drops required.

So if the first egg breaks maximum we can have x-1 drops and so we must
always put the first egg from height x. So we have determined that for a
given x we must drop the first ball from x height. And now if the first drop
of the first egg doesn’t breaks we can have x-2 drops for the second egg if
the first egg breaks in the second drop.

Taking an example, lets say 16 is my answer. That I need 16 drops to find
out the answer. Lets see whether we can find out the height in 16 drops.
First we drop from height 16,and if it breaks we try all floors from 1 to
15.If the egg don’t break then we have left 15 drops, so we will drop it
from 16+15+1 =32nd floor. The reason being if it breaks at 32nd floor we can
try all the floors from 17 to 31 in 14 drops (total of 16 drops). Now if it
did not break then we have left 13 drops. and we can figure out whether we
can find out whether we can figure out the floor in 16 drops.

Lets take the case with 16 as the answer

1 + 15 16 if breaks at 16 checks from 1 to 15 in 15 drops
1 + 14 31 if breaks at 31 checks from 17 to 30 in 14 drops
1 + 13 45 .
1 + 12 58
1 + 11 70
1 + 10 81
1 + 9 91
1 + 8 100 We can easily do in the end as we have enough drops to accomplish
the task


Now finding out the optimal one we can see that we could have done it in
either 15 or 14 drops only but how can we find the optimal one. From the
above table we can see that the optimal one will be needing 0 linear trials
in the last step.

So we could write it as

(1+p) + (1+(p-1))+ (1+(p-2)) + .+ (1+0) = 100.

Let 1+p=q which is the answer we are looking for

q (q+1)/2 =100

Solving for 100 you get q=14.
So the answer is: 14
Drop first orb from floors 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99,
100... (i.e. move up 14 then 13, then 12 floors, etc) until it breaks (or
doesn't at 100).



On Fri, Jul 8, 2011 at 1:07 AM, Sumit chauhan sumitchauhan...@gmail.comwrote:

 @sunny
 dude i got so excited after finding this solution i did not bother to check
 for 14

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


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

2011-07-08 Thread Aman Goyal
i dint get you..

one loop to access the first array elements and compare with second array,
and one logn (for) loop to binary search the second array , thts it..
O(mlogn) is what i am able to understand.

On Fri, Jul 8, 2011 at 5:52 PM, Apoorve Mohan apoorvemo...@gmail.comwrote:

 @aman:

 Let size of *first array be m* and that of the *second array be* *n*.

 For m elements in first array you perform binary search therefore time
 O(mlogn)

 And for those some elements of the first array you perform shifting in
 array two...in the worst case for all the elements of first array
 you might have to perform shifting in second array and also you might just
 have to shift all the present (n-1) elements each time...so again in worst
 case this whole procedure will take O(mn) time

 so total coplexity of your idea is: O(mlogn) + O(mn)

 And if m is of the O(n) then this will take O(n^2) time in worst case.


 On Fri, Jul 8, 2011 at 2:40 PM, Aman Goyal aman.goya...@gmail.com wrote:

 Algo:


 1 3 77 78 90
 2 5 79 81

 compare 1 2 =1
 compare 3 2 =2 and call binary search on 2nd array widot 2 to identify a
 proper position for 3 and place it there.
 now arrays

 1 2 77 78 90
 3 5 79 81
 3 and 77= swap + binary

 compare 3 and 77, swap them
 find position of 77 in second array and place there. using binary search

 1 2 3 78 90
 5 77 79 81
 78 and 5 = swap + binary search

 1 2 3 5 90
 77 78 79 81

 90 and 77= swap+ binary


 1 2 3 5 77
 78 79 81 90

 ans found

 O(nlogn)
 binary search is O(logn) .


 On Fri, Jul 8, 2011 at 8:29 AM, durgesh kumar durgesh1...@gmail.comwrote:


 @dumanshu

  ok ! i got a O(n lgn) finally
  i don know exact complexity
  Let N = size of first array
  Find the first N smallest elements using one pointer in each array
  now swap the list of elements  from index 0 to second-pointer in
  second array to first array
  with first_poiner+1 to N in first Array
  now,after swapnig we need to sort both array




 so complexity= n + n log n+ m log m (n is the size of of first array and
 m is the size of second array)
  .
 . . O(n) = (n log n ) or (m log m)
 thanks
 Durgesh

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


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

 Apoorve Mohan


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


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



Re: [algogeeks] Interview Questions ebook

2011-07-01 Thread Aman Goyal
Go for crack the interview.

On Fri, Jul 1, 2011 at 9:06 AM, Antony Kotre antonyko...@gmail.com wrote:

 please suggest me or mail me a good interview questions ebook
 thanks

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



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



[algogeeks] Earn a ipod with just a facebook like

2011-02-04 Thread Aman Goyal
 http://www.studyshare.in/share/content.php?195

I have received a apple shuffle few days back with just liking a facebook
video. I am still boggled, but I want all of you earn it.

Yes, this may sound spam, but it is a real story. pre Congrats for an
ipod/tshirt/mug who are going to 'like' this facebook video. Just make sure
your address is correctly entered on your facebook account.

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

2011-02-02 Thread Aman Goyal
go on www.studyshare.in .. if u click 'like' on SECOND LAST video you can
win a lucky draw with prizes such as t-shirts and mugs even ipods, provided
u have given correct address at your facebook account.
IT IS NOT SPAM. you can really experience it.

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



Re: [algogeeks] Re: first larger element in unsorted array...

2011-02-01 Thread Aman Goyal
this code will work only for this test case, it is wrong for all
cases...eg3 4 9 8 6 7 10
there will be -1 output for 8 and 9 which is actually wrong..

On Tue, Feb 1, 2011 at 6:01 PM, Veenus Gupta smartvee...@gmail.com wrote:

 #define N 7
 int main()

 {
int a[N]={1,3,5,7,6,4,8};
int m[N];
m[N-1]=-1;
for(int i=N-2;i=0;i--)
{
if(a[i]=a[i+1])
 m[i]=a[i+1];
else
 m[i]=m[i+1];
}
for(int i=0;iN;i++)
  coutm[i]\t;
system(pause);
 }

 On Feb 1, 1:06 pm, abc abc may.i.answ...@gmail.com wrote:
  Guys please check correctness of your algorithm before posting
 
 
 
 
 
 
 
  On Mon, Jan 31, 2011 at 11:47 PM, ritu ritugarg.c...@gmail.com wrote:
   @Ralph
   Build a data structure on array B[1..n]  in O(n) time such that
the following problem can be solved in O(log n) time:
Given an index i and value  v,  find the index j of the first
element in  B  such that  j = i and B[j]  v.
Return  -1 if no such j exists.

 
   then it ll take n*lg(n) time ... while a o(n) solution exists
 
   On Jan 31, 9:25 pm, Ralph Boland rpbol...@gmail.com wrote:
On Jan 30, 11:00 pm, ritu ritugarg.c...@gmail.com wrote:
 
 You are given an array (unsorted) and for every element i, find the
 first occurance of an element j (in the remaining array) that is
 greater than or equal to i. If no such j occurs then print -1.
 Eg: Input--- A={1,3,5,7,6,4,8}
 Output--- 3 5 7 8 8 8 -1
 Time Complexity:O(n)
 Space Complexity:O(n)
 
I solved a version of this problem in my thesis.
 
Build a data structure on array B[1..n]  in O(n) time such that
the following problem can be solved in O(log n) time:
Given an index i and value  v,  find the index j of the first
element in  B  such that  j = i and B[j]  v.
Return  -1 if no such j exists.
 
I have an application of this data structure in my thesis (which
is why I invented it) but I would love to hear other applications.
 
Ralph Boland
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2Bunsubscribe@googlegroups .com
   .
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

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



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

2011-02-01 Thread Aman Goyal
we can create a height balanced tree with all nodes having their value and
also their index value.. can be done in o(n)
then we need to look to d right side of the node and check for index(greater
).. which will be o(log(n))
correct me if i m wrong..

On Tue, Feb 1, 2011 at 7:50 PM, Aman Goyal aman.goya...@gmail.com wrote:

 this code will work only for this test case, it is wrong for all
 cases...eg3 4 9 8 6 7 10
 there will be -1 output for 8 and 9 which is actually wrong..


 On Tue, Feb 1, 2011 at 6:01 PM, Veenus Gupta smartvee...@gmail.comwrote:

 #define N 7
 int main()

 {
int a[N]={1,3,5,7,6,4,8};
int m[N];
m[N-1]=-1;
for(int i=N-2;i=0;i--)
{
if(a[i]=a[i+1])
 m[i]=a[i+1];
else
 m[i]=m[i+1];
}
for(int i=0;iN;i++)
  coutm[i]\t;
system(pause);
 }

 On Feb 1, 1:06 pm, abc abc may.i.answ...@gmail.com wrote:
  Guys please check correctness of your algorithm before posting
 
 
 
 
 
 
 
  On Mon, Jan 31, 2011 at 11:47 PM, ritu ritugarg.c...@gmail.com wrote:
   @Ralph
   Build a data structure on array B[1..n]  in O(n) time such that
the following problem can be solved in O(log n) time:
Given an index i and value  v,  find the index j of the first
element in  B  such that  j = i and B[j]  v.
Return  -1 if no such j exists.

 
   then it ll take n*lg(n) time ... while a o(n) solution exists
 
   On Jan 31, 9:25 pm, Ralph Boland rpbol...@gmail.com wrote:
On Jan 30, 11:00 pm, ritu ritugarg.c...@gmail.com wrote:
 
 You are given an array (unsorted) and for every element i, find
 the
 first occurance of an element j (in the remaining array) that is
 greater than or equal to i. If no such j occurs then print -1.
 Eg: Input--- A={1,3,5,7,6,4,8}
 Output--- 3 5 7 8 8 8 -1
 Time Complexity:O(n)
 Space Complexity:O(n)
 
I solved a version of this problem in my thesis.
 
Build a data structure on array B[1..n]  in O(n) time such that
the following problem can be solved in O(log n) time:
Given an index i and value  v,  find the index j of the first
element in  B  such that  j = i and B[j]  v.
Return  -1 if no such j exists.
 
I have an application of this data structure in my thesis (which
is why I invented it) but I would love to hear other applications.
 
Ralph Boland
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2Bunsubscribe@googlegroups .com
   .
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

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




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



Re: [algogeeks] basic problem

2010-03-24 Thread aman goyal
thanx to all.special one to Sathaiah Dontula ..i got ur point and it is
completely valid..!!!

On Wed, Mar 24, 2010 at 1:37 PM, TurksHead Education 
turksheadeducat...@gmail.com wrote:

 This is because by definition linked lists are dynamic.. If they reside on
 stack they cannot be dynamic (extensible in size)

 On Wed, Mar 24, 2010 at 2:42 AM, aman goyal aman...@gmail.com wrote:

 why do we use malloc funtcn to allocate memory for a stuct node variable
 pointer..
 why dont we simply write struct node p;
 instead we do
 struct node *p
 p=malloc();

 any valid reasons for this??

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


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


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



[algogeeks] basic problem

2010-03-23 Thread aman goyal
why do we use malloc funtcn to allocate memory for a stuct node variable
pointer..
why dont we simply write struct node p;
instead we do
struct node *p
p=malloc();

any valid reasons for this??

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