Re: [algogeeks] Openings in Flipkart BLR

2015-09-05 Thread arun tiwari
On Tue, Sep 1, 2015 at 9:37 PM, Sachin Chitale 
wrote:

> Hi folks,
>
> There are following open position in  flipkart if someone is interested do
> send your resume.
>
> 1. SDE2/SDET 2/UI2 (2+ yrs)
> 2. APM/PM/EM
> 3. Engineering Directors
> 4. Architect
> 5. Data Scientist
>
> Regards,
> Sachin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

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


Arun_Latest_Resume.doc
Description: MS-Word document


[algogeeks] Fwd: PM Modi's touching tribute to Dr APJ Abdul Kalam

2015-07-29 Thread ARUN M Shankar
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=e506695fb1379a49a76c1cbaf073597b13f58f68
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=6a6c8fb26792e70dc15e1287861f2cdbf3acce6a
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=34d4498e8b36b66ca3ed1db1d33d19323474a685
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=2d74af5e18f1732dcefc234f78a6cbdc55842f08
  Join PM on Social Media Interact with PM Know the PM Give
your Suggestions
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=f3c2f8ff9f3846ebf37d5f0cb03f11ead6d6d10b
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=cc9ffed377b15618c37c00bddd33c7d60315d7ab
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=35dc90f55f86aaa136277353b61ee4b7d0dbb343
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=2e953bb419a9849e36a03681b1cda13c90ed3c3b
http://jan-sampark.nic.in/jansampark/click.jsp?tab=pmolat=00100urlid=fe6315ad0f4b7e341bc731b89870d249686245d5
 Forward it to a friend
http://jan-sampark.nic.in/jansampark/forward.jsp?tab=pmolat=00100mid=56d989401115f2258ca28c77505c6f80570bf5a7
   This message was sent to arunshanka...@gmail.com from Prime Minister's
Office http://pmindia.gov.in through no-re...@sampark.gov.in
--
 If you would prefer not to receive these emails please click unsubscribe
http://jan-sampark.nic.in/jansampark/unsubscribe.jsp?tab=pmolat=00100mid=56d989401115f2258ca28c77505c6f80570bf5a7

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


[algogeeks] Renaming namespaces c++

2013-07-30 Thread Arun Vishwanathan
Hi all,

I went through the following post on Stack overflow:
http://stackoverflow.com/questions/6108704/renaming-namespaces

but I have questions on the solution given,

The question mentions about change of namespace from old to _new::nested
for the class because of which any reference to SomeClass in already
existing code will need to adjusted without much work.

So as mentioned in the question one way is to use
namespace old
{
typedef _new::nested::SomeClass Someclass;
}

so that any reference to Someclass in the form of old::Someclass obj;
or as
namespace old
{
Someclass Obj
};

in the CPP file is properly understood.

However in the ideone solution given in the first response to this
question, the declaration of the variable inside int main() is changed to
adjust to this new namespace.I think two here refers to the new namespace
and one to the old.  Is not this slightly impractical since Someclass class
object could be created at multiple places in a huge code base and scoping
each object declaration to adjust to the new namesapce is time
consuming?That way is not the solution mentioned in the question itself
fine since the CPP code where the class is used can be untouched with
Someclass automatically now referring to the updated namespace due to the
typedef?

Am I missing something here?

Arun

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




[algogeeks] why does this work?

2013-07-18 Thread Arun Vishwanathan
I tried the following on ideone

#include stdio.h
 int main(){
int *temp;
printf 
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(value
is %p\n,temp);
return 0;}


 it prints that :
value is (nil)
which am assuming is NULL

if I try to print *temp it gives me segv which I would expect.

However if I do something as
*temp=5;

it does not segv. How does this happen? If it was a NULL pointer it cannot
dereference it right?

Arun

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




[algogeeks] how to solve this?

2013-04-04 Thread arun kumar
Given an expression in the form of a string, solve for x. The highest power
of x in the expression will be equal to 1. Operators allowed are +, * and
-. These are all binary operators. So, 2x would be written as 2*x. Every
operator will be followed by a single term or a constant.

For example, consider the following equation:

2*x+5-(4*x-7+(4-2))=10*x-9 Given such an equation, we need to find a
solution to x

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




Re: [algogeeks] Re: Amazon Interview Question

2013-02-13 Thread arun singh chauhan
@Sachin Chitale : Very good approach dude .
thumbs up +1

-- 
Arun Singh Chauhan
Engineer (RnD 2), Samsung Electronics 
Software Engineering Lab, Noida


On Tuesday, February 12, 2013 11:44:08 PM UTC+5:30, Sachin Chitale wrote:

 use ex-or operation for all array elements..
 a^a=0
 a^a^a=a


 On Sun, Feb 10, 2013 at 8:22 AM, Mohanabalan D B 
 mohana...@gmail.comjavascript:
  wrote:

 can use counting sort


 On Sun, Jul 15, 2012 at 6:37 PM, santosh thota 
 santosh...@gmail.comjavascript:
  wrote:

 If we can retrieve ith prime efficiently, we can do the following...
 1.maintain a prod=1, start from 1st element, say a[0]=n find n th prime
 2.check if (prod% (ith_prime * ith_prime )==0) then return i;
else prod=prod*ith_prime;
 3.repeat it till end



 On Thursday, 12 July 2012 10:55:02 UTC+5:30, algo bard wrote:

 Given an array of integers where some numbers repeat once, some numbers 
 repeat twice and only one number repeats thrice, how do you find the 
 number 
 that gets repeated 3 times?

 Does this problem have an O(n) time and O(1) space solution?
 No hashmaps please!

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

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


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




 -- 
 Regards,
 Sachin Chitale
 Application Engineer SCJP, SCWCD
 Contact# : +91 8086284349, 9892159511
 Oracle Corporation 


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




Re: [algogeeks] Pointers Usage

2013-01-03 Thread Arun Vishwanathan
@atul/shady: why is it that pointer takes 8 bytes ? So the takes a memory
location whose value is the address of the element it points to. Why does
the pointer value have to take 8 bytes? I am sorry if I am missing
something silly here.


On Thu, Jan 3, 2013 at 3:11 AM, Debabrata Das 
debabrata.barunhal...@gmail.com wrote:

 array would be allocated in stack and stack is very limited compared
 to heap.If you want temporary data storage go for stack which will be
 freed from stack once array goes out of scope else heap is preferred.

 On Thu, Jan 3, 2013 at 1:01 AM, Rahul raikra...@gmail.com wrote:
  Take a look at the linux kernel .
  Or VLC player 's source code.
  You will not ask this question again.

 --





-- 
 Even the measly pawn draws respect from the powerful king as it has the
power to become a queen one day..Respect everyone in life!

-- 




Re: [algogeeks] Re: parameters to non-const and const reference concept-C++

2012-12-23 Thread Arun Vishwanathan
@Lucifer: Thanks a lot for the explanation


On Sun, Dec 23, 2012 at 4:51 AM, Lucifer sourabhd2...@gmail.com wrote:

 @phoenix

 The reason is not an implication of using references.
 If u are passing emptyvec() as an argument then the vector returned by
 emptyvec() is a temp object ( as its not being assigned to a obj var
 created by the programmer), which means that the user/programmer shouldn't
 be able to change it. Because temp objects are not under the control or
 rather can't be explicitly created/handled by the programmer. Hence, it
 won't allow u to modify the temp object. Now when a temp object is assigned
 to a const ref, it automatically means that u can use but can't modify it
 which is expected. But, if its a non-const ref, then that means one can
 modify a temp object which ideally a programmer doesn't have a control on.



 On Sunday, 23 December 2012 07:33:48 UTC+5:30, phoenix wrote:

 Hi,

 Could someone explain the logic behind the following:

 Arguments that correspond to non-const reference parameters must be
 lvalues-that is they must be non-temporary objects. Arguments that are
 passed by value or bound to a const reference can be any value

 Suppose a function returns an empty vector
 vectordouble emptyvec()
 {
  vector doublev;
 return v;
 }

 Now calling another function which accepts const reference as a parameter
 does not error out but function which accepts non-const reference parameter
 errors when passing emptyvec() to it.Why? I do not understand the concept.

 This emptyvec() function returns a copy of v to the caller and destroys v
 which is local to emptyvec(). So why cannot this copy be passed without
 error as a non-const reference. Why is the behavior different between const
 and non-const reference.?

   --






-- 
 Even the measly pawn draws respect from the powerful king as it has the
power to become a queen one day..Respect everyone in life!

-- 




[algogeeks] parameters to non-const and const reference concept-C++

2012-12-22 Thread Arun Vishwanathan
Hi,

Could someone explain the logic behind the following:

Arguments that correspond to non-const reference parameters must be
lvalues-that is they must be non-temporary objects. Arguments that are
passed by value or bound to a const reference can be any value

Suppose a function returns an empty vector
vectordouble emptyvec()
{
 vector doublev;
return v;
}

Now calling another function which accepts const reference as a parameter
does not error out but function which accepts non-const reference parameter
errors when passing emptyvec() to it.Why? I do not understand the concept.

This emptyvec() function returns a copy of v to the caller and destroys v
which is local to emptyvec(). So why cannot this copy be passed without
error as a non-const reference. Why is the behavior different between const
and non-const reference.?

-- 




[algogeeks] Array Problem

2012-11-15 Thread Arun Kindra
Given an unsorted array, how to divide them into two equal arrays whose
difference of sum is minimum.

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



Re: [algogeeks] Problem

2012-11-01 Thread Arun Kindra
@prankur
can we do in this manner, first find the middle of the array and make it as
a root, and call recursively from 0 to mid-1 for left subtree and mid+1 to
len-1 for right subtree..?

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

2012-10-31 Thread Arun Kindra
Ques - *

struct node
{
int parentValue;
int childValue;
}str[10];

how to construct a BT,given an array of structure containing parent and
child 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] finding element in array with minimum of comparing

2012-10-08 Thread Arun Vishwanathan
@Dave: Nice solution. Can you clarify why you need to store the first
element in a temp variable and put 'elem' in the first position? If elem
was already first in array then it makes no difference. If elem was not
first but somewhere in between, the loop will break there when coming from
behind and size will have the index right? Why do we need to store elem in
first position according to your code?

On Sun, Oct 7, 2012 at 3:01 PM, Mangal Dev Gupta dev.it...@gmail.comwrote:

 *@Dave  while( arr[--size] != elem );*

 *Exception will come when it will encounter a[-1]*
 *i dont know if this loop will ever end... very poor solution i will say
 *

 On Sat, Oct 6, 2012 at 10:00 PM, Umer Farooq the.um...@gmail.com wrote:

 Well actually, I've just gone through Dave's code thoroughly and I
 believe that his code is most appropriate.

 Thanks viper11 for providing the explanation.

 As for my code, I'd like to replace

 while (i!=j)

 with

 while (i  j)

 because != won't work for middle element if the number of elements are
 odd ... and it also won't work if the number of elements are even.

 Anyway, thanks Dave for providing us with such a great solution. Please
 keep posting! :-)

 And others, thanks for pointing out the issue in my code.

 On Sat, Oct 6, 2012 at 9:03 PM, Kalidhakani J kanikali...@gmail.comwrote:

 @umer - what if the element to be searched is at the middle of the
 array? your code doesn't handles this. check out.


 On Sat, Oct 6, 2012 at 3:38 AM, icy` vipe...@gmail.com wrote:

 nice solution, Dave!

 @Umer -- if the sought ele is first, then Dave's code has it sitting in
 the variable temp for a little while.   Loop will stop when size is 0,
 since arr[0]==elem.  Now he throws temp back into arr[0], which will return
 index 0 from the last compare line.

 On Wednesday, October 3, 2012 2:08:56 AM UTC-4, Umer Farooq wrote:

 @Dave Thanks for pointing that out.

 But I still can't get what if elem is on first element or it is not
 present in the array? How is your code going to handle that situation?

 @Atul, Well yes, In the given question, the number of iterations were
 2n. Which I have reduced to n+n/2.





 On Tue, Oct 2, 2012 at 11:13 PM, atul anand atul.8...@gmail.comwrote:

 @umer : how no. of comparison are reduced to half by moving both
 sidesyou have 2 if condition inside, so you are making 2
 comparisons at each iteration + n/2 comparison for while loop so
 number of comparisons are n+n/2

 On 10/2/12, Umer Farooq the@gmail.com wrote:
  why don't we try it from both ends ... something like this:
 
  int i = 0; j = size-1;
 
  while (i != j)
  {
  if (arr[i] == elem)
return arr[i];
  if (arr[j] == elem)
 return arr[j];
  }
 
  this way, we have eliminated half of the comparisons in for loop?
 What do
  you guys say?
 
  On Tue, Oct 2, 2012 at 12:18 PM, rafi rafiw...@gmail.com wrote:
 
  Vikas is right!
  while (n) is equal to (while n!=0)
  you have 2n compares!
 
  בתאריך יום שני, 1 באוקטובר 2012 12:12:21 UTC+2, מאת vikas:
 
  still there is no improvement, compiler will generate the code to
  compare
  with zero here. what you have accomplished is , hide it from
 human eyes
 
  On Monday, 1 October 2012 15:25:09 UTC+5:30, Navin Kumar wrote:
 
  @atul:
  still it won't compare 0 th element. Slight modification in your
 code:
 
  n=*sizeof(arr)*;
  do
  {
   if(elem==arr[*--n*])
   print found;
 
  }while(n);
 
  On Mon, Oct 1, 2012 at 9:50 AM, atul anand atul.8...@gmail.com
 wrote:
 
  yes, but there no need of checking outside the loop
 
  n=sizeof(arr)-1;
  do
  {
   if(elem==arr[n])
   print found;
  n--;
 
  }while(n);
 
 
 
  On Mon, Oct 1, 2012 at 9:33 AM, Navin Kumar
  algorit...@gmail.comwrote:
 
  @atul: keep one more checking outside loop for element at 0 th
 index.
  Because when n = 0  the your loop come out from the loop
 without
  comparing
  it.
 
 
  On Mon, Oct 1, 2012 at 8:55 AM, atul anand
  atul.8...@gmail.comwrote:
 
  n=sizeof(arr);
  n--;
 
  while(n)
  {
   if(elem=arr[n])
print found;
 
  n--;
 
  }
 
  On Sun, Sep 30, 2012 at 2:56 PM, רפי וינר rafiw...@gmail.com
 
  wrote:
 
  Hi
  i was in an interview and was given a simple function
  int arrExsits(int* arr,int size,int elem){
  for (int i=0;isize;++i)
  if(elem==arr[i])
 return i;
  return -1;
  }
  this function does 2n compares
  n- the if statment
  n-check that i is smaller then size
  i was suppose to give an optimal (less compares) solution so
 i gave
 
  int arrExsits(int* arr,int size,int elem){
  if (arr[size-1]==elem)
  return size-1;
  arr[size-1]=elem]
  for (int i=0;;++i)
  if(elem==arr[i]){
  if (i!=size-1)
  return i;
  return -1;
  }
  this solution works and it has n+2 compares the first one
 another n
  and the second inner if.
  they told me it's good (and I've passed) but they told just
 for my
  knowledge that there is a better N compare solution.
  I've 

[algogeeks] Matrix Searching

2012-09-14 Thread Arun Kindra
*You have given any n*n matrix in which characters are stored and you have
to search that a given word is present or not.(words can be horizontally,
vertically, diagonally)*

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

2012-08-22 Thread Arun Kindra
Anyone know the paper pattern or ques of snapdeal? And What they demand(any
specific language)?

-- 
Regards:

*Arun Kindra*

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



Re: [algogeeks] question

2012-08-21 Thread Arun Kindra
a) count total no of bit set in given no
b) increment the given no by one and count the no of bit set in it if it
equal to the above count then return else increment the no till u get the
count equals the above one.

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



Re: [algogeeks] Indus Valley Partners Paper Pattern

2012-08-20 Thread Arun Kindra
Is it for campus recruitment process or Off campus?
And can u specify the Apti topic, and is there any analytical reasoning?
If possible plz share Coding ques.

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

2012-08-18 Thread Arun Kindra
Can anyone know Indus Valley Partners Paper Pattern and ques?

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



Re: [algogeeks] MICROSOFT QUESTION

2012-08-17 Thread Arun Kindra
http://geeksforgeeks.org/forum/topic/algorithm-15?replies=6#post-39220

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

2012-08-12 Thread arun
Can anyone pls share some real world examples for each datastructure nd 
sorting algos..

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



Re: [algogeeks] Constant time solution needed

2012-08-12 Thread Arun Kindra
You can traverse in spiral order and add each element with the specified
co-ordinate.

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



Re: [algogeeks] Constant time solution needed

2012-08-12 Thread Arun Kindra
*within

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

2012-08-05 Thread Arun Kindra
@harsha : yes, the problem is if u r finding only min and max value, it
might happen that u sell the stock before buying. Ex-  int a [ ] = { 5, 10,
4, 6, 7 }; the min value is 4 and max is 10 and 10 comes before 4, means u
sell the stock before buying.
and i think the sol given by mukul does the same mistake.we need to keep
track this case also whether the day(array index) i m buying is not more
than the day(array index) we are selling the stock.

*correct me if  m wrong*.

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



Re: [algogeeks] national instruments on campus interview procedure

2012-08-04 Thread Arun Kindra
http://www.krishnabharadwaj.info/national-instruments/

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

2012-07-27 Thread Arun Kindra
@Dave Sir : Sir if u sort the array(given above) the array would be:
-20,-8-2,4,9,10,12,14,17, and according to ur suggestion, the only ans is
{9,10}...but one of the ans {9,-8} is also possible...as he is asking
the difference in absolute values.

correct me if i m wrong...

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



Re: [algogeeks] what will be output for this program ?

2012-07-27 Thread Arun Kindra
compiler dependent

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

2012-07-23 Thread Arun Kindra
This will help u
http://www.geeksforgeeks.org/archives/570

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

2012-06-05 Thread arun prakash
Can anyone pls mail me good datastrucutre and algo books..or any link to 
download those books..thanks in advance 

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



Re: [algogeeks] GPU doubt

2012-04-08 Thread Arun Vishwanathan
Thanks IIya

On Sat, Apr 7, 2012 at 3:53 PM, Ilya Albrekht ilya.albre...@gmail.comwrote:

 I'm absolutely didn't get your explanation... What is the connection
 between O(n^3) algorithms and staff you are talking about?


 On Saturday, 7 April 2012 03:22:29 UTC-7, SAMMM wrote:

 This is becoz the GPU is multithreaded . In graphics there are three main
 steps , Application based work where vertex Processing , read the data ,
 pixel processing are done .
 Secondly come the Culling which which determimes which portion will be
 shown given the Line of sight . This also checks for any intersection with
 other objects . For instance a man is present behind the building ,so he
 should not be visible to us in Graphics or some portion of this body will
 be shown , This intersection is called redering .

 The third step if draw . to finally draw the model .

 These three process are done multithreaded parallerly given 3x Processing
 speed .
 You can refer this link below :-   http://www.panda3d.org/manual/**
 index.php/Multithreaded_**Render_Pipelinehttp://www.panda3d.org/manual/index.php/Multithreaded_Render_Pipeline



  --
 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/-/3yqKSMvngHMJ.

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



Re: [algogeeks] GPU doubt

2012-04-07 Thread Arun Vishwanathan
@SAMM: what about general mathematical computations such as matrix
multiplication which is O(n^3) as such? How do you relate your explanation
to such math computations or any algorithm of atleast O(n^3)?

On Sat, Apr 7, 2012 at 3:22 AM, SAMM somnath.nit...@gmail.com wrote:

 This is becoz the GPU is multithreaded . In graphics there are three main
 steps , Application based work where vertex Processing , read the data ,
 pixel processing are done .
 Secondly come the Culling which which determimes which portion will be
 shown given the Line of sight . This also checks for any intersection with
 other objects . For instance a man is present behind the building ,so he
 should not be visible to us in Graphics or some portion of this body will
 be shown , This intersection is called redering .

 The third step if draw . to finally draw the model .

 These three process are done multithreaded parallerly given 3x Processing
 speed .
 You can refer this link below :-
 http://www.panda3d.org/manual/index.php/Multithreaded_Render_Pipeline



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



[algogeeks] binary search tree over btree

2012-04-01 Thread arun kumar
hi i just like to know when you will go for binary search tree over
btree. advantage and disadvantage, application of both of them.
thank you in advance
Regards,
Arun kumar

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



Re: [algogeeks] hadoop anyone?

2012-03-31 Thread Arun Vishwanathan
@karthikeyan: Thanks for that info. So in the sample wordcount program
using Hadoop pipes in c++ if i want to see data each node has got, I shd
query namenode? Is namenode a class or something which contains information
or which variable should I check out?
Thanks

On Sat, Mar 31, 2012 at 2:23 AM, bharat b bagana.bharatku...@gmail.comwrote:

 but, how can it split the data, if there are dependencies in job ? unless
 we write parallel program, Does hadoop do any thing faster than usual
 processor?


 On Sat, Mar 31, 2012 at 10:32 AM, Karthikeyan V.B kartmu...@gmail.comwrote:

 Hi,

 The NameNode splits the job into several tasks and submits to the
 different DataNode(i.e nodes) , the split size varies from 64KB to 128MB.
 The NameNode assigns the data split to a datanod.

 Namenode actually has a table to store the mappings of data node and
 block stored in it.

 it is possible to query the namenode and get data from it.

 Regards,
 Karthikeyan

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

 Bharat B | M.Tech II  | C.S.E | IITM
 *
 *
 *Ph: +91 8056127652*


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



Re: [algogeeks] hadoop anyone?

2012-03-31 Thread Arun Vishwanathan
@karthikeyan: Thanks again but I was looking to find that information out
from writing code to do so than to use a command on the command line
prompt.Any idea?

On Sat, Mar 31, 2012 at 10:40 AM, Karthikeyan V.B kartmu...@gmail.comwrote:

 @bharat : hadoop has a* job tracker* which *resolves the dependencies*and
 *splits the job into blocks* and *assigns to datanodes*

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



[algogeeks] hadoop anyone?

2012-03-29 Thread Arun Vishwanathan
Hi all,

Has anyone worked on Hadoop before? I ran the wordcount program with Hadoop
but I am unable to understand how to find out which node in the cluster got
which data? Any experts out here who can suggest?

Arun

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

2012-03-28 Thread Arun Vishwanathan
@Don: I am not clear with your explanation. Please can you give me an
example?

On Wed, Mar 28, 2012 at 6:19 AM, Don dondod...@gmail.com wrote:

 If you have n processors, start with the n possible ways to select
 from log2 n items. Assign each processor to find a solution based on
 the resulting subset of remaining items. Each processor should be able
 to work fairly independently, and when they are done, they can compare
 results and find the best one.
 Don

 On Mar 27, 10:47 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  Hi all,
 
  I am planning to implement a parallel version of the 0-1 knapsack
 problem.
  I tried reading up a bit and there are few suggestions here and there.
  However I would like to know if anyone has an idea or links that I cud
  refer for this? The main problem in parallelizing a DP algorithm is the
  dependencies due to recursion? Is there an effective strategy for this??
  Using shared memory or message passing approach?
 
  Arun

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



Re: [algogeeks] Re: need suggestions

2012-03-28 Thread Arun Vishwanathan
Thanks Don!

On Wed, Mar 28, 2012 at 7:09 AM, Don dondod...@gmail.com wrote:

 Let's say that you have 16 processors. You are trying to solve the 0-1
 knapsack problem for 40 items.
 Each item i has size S[i], and you need to find the subset of items
 which sums as close to T as possible without exceeding T.

 Pick four of items. There are 16 possible combinations of those items:
  (none of those 4 items included)
 0001 (only item #1 included)
 ...
  (all four items included)

 You will essentially ask each of the 16 processors to solve the
 knapsack problem for 36 items, starting with one of the 16 possible
 combiations of the 4 items. Processor 0 will start with none of the
 first 4 items. Processor 15 will start with all of them, and the other
 processors will start with a different subset of the items. It may
 seem like solving the problem for 36 items is not much different than
 40, but it requires 1/16th of the work. When each processor is done,
 it knows the best solution including its assigned items from among the
 first 4 items. To find the overall best solution you just need to
 compare the 16 solutions and pick the one best.

 A possible improvement is to divide up the problem into more parts and
 farm them out to the processors as they become available. This would
 work better if you don't have a power of 2 number of processors. It
 also would reduce the tendancy for some processors to finish early and
 sit idle while one or two take longer to finish their portion of the
 work.

 Don

 On Mar 28, 9:51 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  @Don: I am not clear with your explanation. Please can you give me an
  example?
 
 
 
 
 
  On Wed, Mar 28, 2012 at 6:19 AM, Don dondod...@gmail.com wrote:
   If you have n processors, start with the n possible ways to select
   from log2 n items. Assign each processor to find a solution based on
   the resulting subset of remaining items. Each processor should be able
   to work fairly independently, and when they are done, they can compare
   results and find the best one.
   Don
 
   On Mar 27, 10:47 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
Hi all,
 
I am planning to implement a parallel version of the 0-1 knapsack
   problem.
I tried reading up a bit and there are few suggestions here and
 there.
However I would like to know if anyone has an idea or links that I
 cud
refer for this? The main problem in parallelizing a DP algorithm is
 the
dependencies due to recursion? Is there an effective strategy for
 this??
Using shared memory or message passing approach?
 
Arun
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.- Hide quoted text -
 
  - Show quoted text -

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




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



[algogeeks] need suggestions

2012-03-27 Thread Arun Vishwanathan
Hi all,

I am planning to implement a parallel version of the 0-1 knapsack problem.
I tried reading up a bit and there are few suggestions here and there.
However I would like to know if anyone has an idea or links that I cud
refer for this? The main problem in parallelizing a DP algorithm is the
dependencies due to recursion? Is there an effective strategy for this??
Using shared memory or message passing approach?

Arun

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

2012-03-05 Thread Arun Vishwanathan
@Gene: if all matrices are of N x N , and my size of L1 cache is L1, then
If I need a block of A and B to fit in cache would I need it as 2 x
(blocksize )^2 x 8 ( bytes per data item-for example) = L1 ?? or would I
need it as 3 ( including C block ) x (blocksize)^2 x 8 = L1 ? Am confused.
I tried a sample and I think I got somewhat good speedup for block size 32
( for matrix dimension 512, 1024 etc )for my L1 of size 16 kbytes and L2
256 kbytes...Any comments or inferences?


On Wed, Feb 29, 2012 at 9:31 AM, Arun Vishwanathan
aaron.nar...@gmail.comwrote:

 @all: Thanks a lot


 On Wed, Feb 29, 2012 at 9:02 AM, Gene gene.ress...@gmail.com wrote:

 For big matrices, using all the caches well is very important.  The
 usual approach is block tiling as you say.  You want two blocks to fit
 nicely in the L1 cache.  The most highly optimized schemes will have a
 hierarchy of tiles where two tiles at the second level will fit in the
 L2 cache, etc. Additional levels can be based on memory interfaces,
 interleaving, page size, and even cylinder size on disk (for really
 huge matrices). The idea is _never_ to generate more cache misses than
 you need to. A miss causes a factor of 10 to 1 performance
 multiple on that operation.

 Multiplying within the innermost blocks should also consider prefetch:
 you'll get best performance touching locations in contiguous ascending
 order.  The inner loops are

 for i = 1 to ma
  for j = 1 to nb
for k = 1 to na
  r[i,j] += a[i,k] * b[k,j]

 This ignores that r[i,j] needs to be zeroed out somewhere.  But with
 this assumption, the loops can be juxtaposed in any order without
 changing the result. You should explore the 6 possible orderings for
 the best one.  Of course you also have to zero out the sums in the
 best possible manner.

 FWIW, a GPU will normally outperform a general purpose CPU with ease
 on this problem.  Since even cell phones are getting GPUs these days,
 tweaking single-processor matrix code is a dying art.

 Cheers.

 On Feb 27, 6:57 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  Hi all,
 
  We have this challenge to make the fastest executing serial matrix
  multiplication code. I have tried using matrix transpose( in C for row
  major ) and loop unrolling.I was able to obtain little speedup. Does
 anyone
  have any hints/papers that I could read upon and try to speed up
 further?I
  had tried a bit of block tiling but was not successful.
 
  Thanks
  Arun

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




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



Re: [algogeeks] Re: optimisation

2012-02-29 Thread Arun Vishwanathan
@all: Thanks a lot

On Wed, Feb 29, 2012 at 9:02 AM, Gene gene.ress...@gmail.com wrote:

 For big matrices, using all the caches well is very important.  The
 usual approach is block tiling as you say.  You want two blocks to fit
 nicely in the L1 cache.  The most highly optimized schemes will have a
 hierarchy of tiles where two tiles at the second level will fit in the
 L2 cache, etc. Additional levels can be based on memory interfaces,
 interleaving, page size, and even cylinder size on disk (for really
 huge matrices). The idea is _never_ to generate more cache misses than
 you need to. A miss causes a factor of 10 to 1 performance
 multiple on that operation.

 Multiplying within the innermost blocks should also consider prefetch:
 you'll get best performance touching locations in contiguous ascending
 order.  The inner loops are

 for i = 1 to ma
  for j = 1 to nb
for k = 1 to na
  r[i,j] += a[i,k] * b[k,j]

 This ignores that r[i,j] needs to be zeroed out somewhere.  But with
 this assumption, the loops can be juxtaposed in any order without
 changing the result. You should explore the 6 possible orderings for
 the best one.  Of course you also have to zero out the sums in the
 best possible manner.

 FWIW, a GPU will normally outperform a general purpose CPU with ease
 on this problem.  Since even cell phones are getting GPUs these days,
 tweaking single-processor matrix code is a dying art.

 Cheers.

 On Feb 27, 6:57 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  Hi all,
 
  We have this challenge to make the fastest executing serial matrix
  multiplication code. I have tried using matrix transpose( in C for row
  major ) and loop unrolling.I was able to obtain little speedup. Does
 anyone
  have any hints/papers that I could read upon and try to speed up
 further?I
  had tried a bit of block tiling but was not successful.
 
  Thanks
  Arun

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



[algogeeks] optimisation

2012-02-27 Thread Arun Vishwanathan
Hi all,

We have this challenge to make the fastest executing serial matrix
multiplication code. I have tried using matrix transpose( in C for row
major ) and loop unrolling.I was able to obtain little speedup. Does anyone
have any hints/papers that I could read upon and try to speed up further?I
had tried a bit of block tiling but was not successful.

Thanks
Arun

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

2012-02-12 Thread Arun Vishwanathan
hi,

I need to a final project in a course called Parallel Programming. Does
anyone have suggestions for a good topic to take up in this??Some
challenging problem maybe that is computationally intensive but can benefit
from multicore and parallel processing.

Thanks!


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



Re: [algogeeks] Re: suggestions?

2012-02-12 Thread Arun Vishwanathan
Thanks Gene!

On Sun, Feb 12, 2012 at 3:17 PM, Gene gene.ress...@gmail.com wrote:

 If you want to do something of practical importance that has not
 already been done many times, you can look at parallel collision
 detection.  Collision detection is very important in physical
 simulations (as in mechanical design tools, CGI, and computer games).


 On Feb 12, 10:58 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  hi,
 
  I need to a final project in a course called Parallel Programming. Does
  anyone have suggestions for a good topic to take up in this??Some
  challenging problem maybe that is computationally intensive but can
 benefit
  from multicore and parallel processing.
 
  Thanks!
 
  --
   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.




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



[algogeeks] openmp

2012-02-05 Thread Arun Vishwanathan
hi , i am trying to run this small code with open mp but I dont see any
threads created . The code compiles with -fopenmp but does not create
threads to run parallel.For example,

main()
{
  omp_set_num_threads(4);
 #pragma omp parallel
 printf( hello world from %d\n ,omp_get_thread_num());
return;

}
output: hello world from 0

what abt the other threads??
--

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



Re: [algogeeks] openmp

2012-02-05 Thread Arun Vishwanathan
I use g++

On Sun, Feb 5, 2012 at 12:39 PM, Rahul raikra...@gmail.com wrote:

 which compiler
 or which environment
 I use Microsoft Visual Studio
 with Microsoft HPC Pack
 A syntax error is visible
 use {


 On 2/6/12, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  hi , i am trying to run this small code with open mp but I dont see any
  threads created . The code compiles with -fopenmp but does not create
  threads to run parallel.For example,
 
  main()
  {
omp_set_num_threads(4);
   #pragma omp parallel
   printf( hello world from %d\n ,omp_get_thread_num());
  return;
 
  }
  output: hello world from 0
 
  what abt the other threads??
  --
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.



Re: [algogeeks] openmp

2012-02-05 Thread Arun Vishwanathan
hey , I just figured out the problem. the -fopenmp was to be included in a
couple of places in my makefile due to which the openmp library was not
getting recognised though code was compiling.
Anyways if it is just one line of code and  u dont need the braces after
omp parallel( it is just like a one line statement after 'if')
i have dual core.
thanks for yr help!

On Sun, Feb 5, 2012 at 12:49 PM, Rahul raikra...@gmail.com wrote:

 See a hello world tutorial
 as far as I can see is that
 you haven't put {}
 in the section of code you want to run parallel
 how many processors do you have
 try running without asking number of threads
 .you must see as many outputs as number of processors


 On 2/6/12, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  I use g++
 
  On Sun, Feb 5, 2012 at 12:39 PM, Rahul raikra...@gmail.com wrote:
 
  which compiler
  or which environment
  I use Microsoft Visual Studio
  with Microsoft HPC Pack
  A syntax error is visible
  use {
 
 
  On 2/6/12, Arun Vishwanathan aaron.nar...@gmail.com wrote:
   hi , i am trying to run this small code with open mp but I dont see
 any
   threads created . The code compiles with -fopenmp but does not create
   threads to run parallel.For example,
  
   main()
   {
 omp_set_num_threads(4);
#pragma omp parallel
printf( hello world from %d\n ,omp_get_thread_num());
   return;
  
   }
   output: hello world from 0
  
   what abt the other threads??
   --
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.
 
 

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



[algogeeks] java help

2012-02-02 Thread Arun Vishwanathan
Hi,
does anybody know how to take a screenshot of screen with java ?

I also need help regarding storing the screenshot image into a doc file or
so. Any suggestions?

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

2012-01-28 Thread Arun Vishwanathan
I wanted to gather some analysis on parallelism for matrix multiplication.
Amdahl 's law essentially compares speed when work is done serially to
speed when some parallelism is introduced in the system.

Say I have Tcount threads used for computation on a system having NCores number
of cores. Say dimension of all matrices is NxN.

If code was completely sequential then N^3 I guess would be amount of work
done. How would be the case when Tcount threads are used? say I have each
thread performing calculation for certain number of rows. So if I have
matrix dimension N and Tcount threads then each thread calculates
N/Tcountnumber
of rows , and for each row it takes N^ 2 work units serially. How much time
would it now take with threads?
I thought it would be n^3 work serially but if parallelism is involved it
would be (n/tcount)*n^2 *  tcount/ncores... But this causes tcount to
cancel out which looks absurd. Any suggestions?

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



Re: [algogeeks] MS Question -Reverse a Linked List in size of 2

2012-01-23 Thread Arun Vishwanathan
node *ptr =head;

//function call is reverse(head,NULL)

void reverse(node *ptr, node *follow)
{
   if(ptr-next!=NULL  ptr-next-next!=NULL)
   reverse(ptr-next-next,ptr);
  else
  if(ptr-next!=NULL  ptr-next-next==NULL)
{
  ptr-next-next=follow;
  head=ptr;
}
  ptr-next-next=follow;
  if(follow!=NULL)
  follow-next-next=NULL;
}

@ankur: if odd number of nodes then maybe just ask interviewer how he wants
it to be and try including that case ;)


}

On Mon, Jan 23, 2012 at 10:32 AM, Ankur Garg ankurga...@gmail.com wrote:

 wat if u have odd no of nodes



 On Tue, Jan 24, 2012 at 12:00 AM, atul anand atul.87fri...@gmail.comwrote:

 one simple way would be using stacks.
 push node,node-next;
 then pop() , and reversing the pointers.

 On Mon, Jan 23, 2012 at 11:46 PM, Ankur Garg ankurga...@gmail.comwrote:

 Say LL is

 1-2-3-4-5-6-7-8

 Then u need to return

 7-8-5-6-3-4-1-2

 U cant swap the values U have to rearrange the ptr...


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



Re: [algogeeks] Re: sort 2D array

2012-01-22 Thread Arun Vishwanathan
@lucifer:nice explanation !... just to make a small clarification, in your
stabilisation part u jus compare x with min (b,d)  , make a swap if
necessary and then next time u compare it shud be =min(b,d) and so u
break.

x   b   c

d   e   f

g   h   i

so now after breaking x is less than both b and d but present b could be
greater than e right? for example initally it cud be
8 5
6 7.
.
.
.
and we swap 8 and 5now 8 is above 7 after swap ...but is this taken
care of next iteration when we do swaps of a[row][col] with a[row+1][0]??
so is heapify sep in all just comparison of x with b and d only and swap if
needed??


On Sat, Jan 14, 2012 at 1:48 AM, Gaurav Kalra gvka...@gmail.com wrote:

 Bases on algorithm suggested by Lucifer, I have coded the problem in C
 (please see attachment).

 The code has been tested against the following test cases:

 1 3 4 8 9
 2 5 18 25 50
 6 7 22 45 55

 and

 1 2 7
 3 5 8
 4 6 9

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/kQ0gKL_2h7oJ.

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



Re: [algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-22 Thread Arun Vishwanathan
@lucifer: in yr code will not all the root-left be NULL for each iteration
as
startindex is always greater than endindex ( i.e i-1) in the recursive
function call??and so for each node only root-right is made?
On Fri, Dec 30, 2011 at 12:51 AM, praveen raj praveen0...@gmail.com wrote:

 yes... right...
 i forget to remove this statement..


 PRAVEEN RAJ
 DELHI COLLEGE OF ENGINEERING



 On Fri, Dec 30, 2011 at 2:17 PM, Lucifer sourabhd2...@gmail.com wrote:

 @praveen

 I think what u are doing above is the following:
 Say, F(n) denotes the no. of binary trees that can be formed using N
 elements given the inorder sequence..

 F(n) = SumOver(i= 1 to N) { F(i-1) * F(N-i) }

 which is nothing but..
 F(N) = (2n C n)/ (n+1) i.e. catalan's no.

 Also, i would like to mention that in ur code probably u need to
 remove the following condition otherwise u result outcome will always
 be zero..

 *
 if(N==0) return 0;


 On 30 Dec, 13:41, praveen raj praveen0...@gmail.com wrote:
  int countBT(int N)
  {
int count =0;
int count1;
if(N==0)
   return 0;
 if(N=1)
   return 1;
   else
 {
 for(int j=1;j=N;j++)
 {
count1 = countBT(j-1)
count2 =countBT(N-j);
count+=(count1*count2);
  }
return (count);
  }
 
  }
 
  PRAVEEN RAJ
  DELHI COLLEGE OF ENGINEERING

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


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



Re: [algogeeks] Re: sort 2D array

2012-01-22 Thread Arun Vishwanathan
@lucifer: yes I get that...I was just saying that after a swap has happened
within the while loop ( since x  min(b,d) might have been the case ) ,
then in the next looping within while,  break wud happen right? meaning it
doesnt stay in the while after a swap happens...

On Sun, Jan 22, 2012 at 3:25 PM, Lucifer sourabhd2...@gmail.com wrote:

 @Arun

 If you read the post in which i have explained the process properly,
 the following is also present:

 while(1)
 {
 If x = min (b,d ),
 /* here b is nothing but the element placed next to 'x' on the same
 row..
   d is the element placed right below 'x' in the same column...
  then we are done...*/
break;
 else
   swap ('x', min (b,d))
 }

 If you see in the comments i have mentioned that b and d are not
 exactly the same b and d as shown in the matrix.. but they are current
 right and current bottom elements of 'x'..
 Hence, the swaps go on till the condition  x = min (b,d )  is not
 satisfied..



 On Jan 23, 3:44 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  @lucifer:nice explanation !... just to make a small clarification, in
 your
  stabilisation part u jus compare x with min (b,d)  , make a swap if
  necessary and then next time u compare it shud be =min(b,d) and so u
  break.
 
  x   b   c
 
  d   e   f
 
  g   h   i
 
  so now after breaking x is less than both b and d but present b could be
  greater than e right? for example initally it cud be
  8 5
  6 7.
  .
  .
  .
  and we swap 8 and 5now 8 is above 7 after swap ...but is this taken
  care of next iteration when we do swaps of a[row][col] with a[row+1][0]??
  so is heapify sep in all just comparison of x with b and d only and swap
 if
  needed??
 
 
 
 
 
 
 
 
 
  On Sat, Jan 14, 2012 at 1:48 AM, Gaurav Kalra gvka...@gmail.com wrote:
   Bases on algorithm suggested by Lucifer, I have coded the problem in C
   (please see attachment).
 
   The code has been tested against the following test cases:
 
   1 3 4 8 9
   2 5 18 25 50
   6 7 22 45 55
 
   and
 
   1 2 7
   3 5 8
   4 6 9
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/kQ0gKL_2h7oJ.
 
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.




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



Re: [algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-22 Thread Arun Vishwanathan
@lucifer: sorry if i seem to be missing the ppoint...can u just clarify
what I am getting wrong here..

if array is a[0] a[1] a[2] a[3] a[4] say, i understand yr recursion goes as
follows:
the first node data is a[0], its left pointer is null ( since call is made
with startindex=1 and lastindex =0 and so null is returned ) and its right
pointer points to node whose data is a[1], whose left pointer is null
(since call made with startindeex =2 and lastindex =1 )and whose right
pointer points to node whose data is a[2] whose left pointer is null and
right points to node whose data is a[3] and so on..
am sorry if it sounds silly...can u clarify if am seeing it wrong??

On Sun, Jan 22, 2012 at 3:31 PM, Lucifer sourabhd2...@gmail.com wrote:

 @Arun..

 Are you referring to the following condition in 'GenerateBT':
 /*
  if ( startIndex  endIndex) return NULL;
 */

 If so, then answer is no. The above condition basically identifies
 that we have reached a leaf node and hence, the leaf node should have
 both its left and right pointers set to NULL.

 If you trace it. you will figure it out.
 In case there is a doubt do let me know..

 On Jan 23, 4:17 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  @lucifer: in yr code will not all the root-left be NULL for each
 iteration
  as
  startindex is always greater than endindex ( i.e i-1) in the recursive
  function call??and so for each node only root-right is made?
 
 
 
 
 
 
 
 
 
  On Fri, Dec 30, 2011 at 12:51 AM, praveen raj praveen0...@gmail.com
 wrote:
   yes... right...
   i forget to remove this statement..
 
   PRAVEEN RAJ
   DELHI COLLEGE OF ENGINEERING
 
   On Fri, Dec 30, 2011 at 2:17 PM, Lucifer sourabhd2...@gmail.com
 wrote:
 
   @praveen
 
   I think what u are doing above is the following:
   Say, F(n) denotes the no. of binary trees that can be formed using N
   elements given the inorder sequence..
 
   F(n) = SumOver(i= 1 to N) { F(i-1) * F(N-i) }
 
   which is nothing but..
   F(N) = (2n C n)/ (n+1) i.e. catalan's no.
 
   Also, i would like to mention that in ur code probably u need to
   remove the following condition otherwise u result outcome will always
   be zero..
 
   *
   if(N==0) return 0;
 
   On 30 Dec, 13:41, praveen raj praveen0...@gmail.com wrote:
int countBT(int N)
{
  int count =0;
  int count1;
  if(N==0)
 return 0;
   if(N=1)
 return 1;
 else
   {
   for(int j=1;j=N;j++)
   {
  count1 = countBT(j-1)
  count2 =countBT(N-j);
  count+=(count1*count2);
}
  return (count);
}
 
}
 
PRAVEEN RAJ
DELHI COLLEGE OF ENGINEERING
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.




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



Re: [algogeeks] Re: sort 2D array

2012-01-22 Thread Arun Vishwanathan
@ lucifer: thank you !

On Sun, Jan 22, 2012 at 4:12 PM, Lucifer sourabhd2...@gmail.com wrote:

 @Arun,

 Nope.. the loop exits only when there are no more swaps possible...

 Let me explain with an example..
 x  b  c
 d  e   f
 g   h  i

 say x  min(b,d) , where min(b,d) = b,

 Hence, swap happens..

 b  x  c
 d  e   f
 g   h  i

 say, x  min(c, e), where min(c,e) = e..
 Hence, swap takes place..

 b   e  c
 d   x  f
 g   h  i

 Now say,
 x = min(f,h)..

 Hence, we hit the break statement and exit from the loop..


 On Jan 23, 5:03 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  @lucifer: yes I get that...I was just saying that after a swap has
 happened
  within the while loop ( since x  min(b,d) might have been the case ) ,
  then in the next looping within while,  break wud happen right? meaning
 it
  doesnt stay in the while after a swap happens...
 
 
 
 
 
 
 
 
 
  On Sun, Jan 22, 2012 at 3:25 PM, Lucifer sourabhd2...@gmail.com wrote:
   @Arun
 
   If you read the post in which i have explained the process properly,
   the following is also present:
 
   while(1)
   {
   If x = min (b,d ),
   /* here b is nothing but the element placed next to 'x' on the same
   row..
 d is the element placed right below 'x' in the same column...
then we are done...*/
  break;
   else
 swap ('x', min (b,d))
   }
 
   If you see in the comments i have mentioned that b and d are not
   exactly the same b and d as shown in the matrix.. but they are current
   right and current bottom elements of 'x'..
   Hence, the swaps go on till the condition  x = min (b,d )  is not
   satisfied..
 
   On Jan 23, 3:44 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
@lucifer:nice explanation !... just to make a small clarification, in
   your
stabilisation part u jus compare x with min (b,d)  , make a swap if
necessary and then next time u compare it shud be =min(b,d) and so u
break.
 
x   b   c
 
d   e   f
 
g   h   i
 
so now after breaking x is less than both b and d but present b
 could be
greater than e right? for example initally it cud be
8 5
6 7.
.
.
.
and we swap 8 and 5now 8 is above 7 after swap ...but is this
 taken
care of next iteration when we do swaps of a[row][col] with
 a[row+1][0]??
so is heapify sep in all just comparison of x with b and d only and
 swap
   if
needed??
 
On Sat, Jan 14, 2012 at 1:48 AM, Gaurav Kalra gvka...@gmail.com
 wrote:
 Bases on algorithm suggested by Lucifer, I have coded the problem
 in C
 (please see attachment).
 
 The code has been tested against the following test cases:
 
 1 3 4 8 9
 2 5 18 25 50
 6 7 22 45 55
 
 and
 
 1 2 7
 3 5 8
 4 6 9
 
 --
 You received this message because you are subscribed to the Google
   Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/kQ0gKL_2h7oJ.
 
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.
 
  --
   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.




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



Re: [algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-22 Thread Arun Vishwanathan
@lucifer: my bad ...thanks a lot

On Sun, Jan 22, 2012 at 4:27 PM, Lucifer sourabhd2...@gmail.com wrote:

 @Arun..

 I think you are generating the bin-tree for ' i =startIndex' and not '
 i =startIndex +1'..

 Hence, if you just trace it for ' i =startIndex + 1' for all the
 recursive calls, you should get it...

 On Jan 23, 5:22 am, Lucifer sourabhd2...@gmail.com wrote:
  @Arun...
 
  You are not getting it wrong but then you have just generated one
  binary tree..
 
  What about the other bin-trees...?
  The bin-tree that you are generating is for the first recursive
  iteration..
 
  Let me give you a quick explanation...
 
  GenerateBT has the following loop..
  for (int i =startIndex ; i =endIndex; ++i)
  {}
 
  Now, the bin-tree that you are generating is for i = startIndex + 1,
  and also when you recursively go inside you are basically tracing it
  for 'i = startIndex + 1'..
 
  Try doing it for i = startIndex + 3 (say)..
  and also ensure that when you go inside recursively try to trace the
  case where 'i  startIndex + 1'
 
  and see if you get it..
 
  On Jan 23, 5:11 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
 
 
 
 
 
 
 
   @lucifer: sorry if i seem to be missing the ppoint...can u just clarify
   what I am getting wrong here..
 
   if array is a[0] a[1] a[2] a[3] a[4] say, i understand yr recursion
 goes as
   follows:
   the first node data is a[0], its left pointer is null ( since call is
 made
   with startindex=1 and lastindex =0 and so null is returned ) and its
 right
   pointer points to node whose data is a[1], whose left pointer is null
   (since call made with startindeex =2 and lastindex =1 )and whose right
   pointer points to node whose data is a[2] whose left pointer is null
 and
   right points to node whose data is a[3] and so on..
   am sorry if it sounds silly...can u clarify if am seeing it wrong??
 
   On Sun, Jan 22, 2012 at 3:31 PM, Lucifer sourabhd2...@gmail.com
 wrote:
@Arun..
 
Are you referring to the following condition in 'GenerateBT':
/*
 if ( startIndex  endIndex) return NULL;
*/
 
If so, then answer is no. The above condition basically identifies
that we have reached a leaf node and hence, the leaf node should have
both its left and right pointers set to NULL.
 
If you trace it. you will figure it out.
In case there is a doubt do let me know..
 
On Jan 23, 4:17 am, Arun Vishwanathan aaron.nar...@gmail.com
 wrote:
 @lucifer: in yr code will not all the root-left be NULL for each
iteration
 as
 startindex is always greater than endindex ( i.e i-1) in the
 recursive
 function call??and so for each node only root-right is made?
 
 On Fri, Dec 30, 2011 at 12:51 AM, praveen raj 
 praveen0...@gmail.com
wrote:
  yes... right...
  i forget to remove this statement..
 
  PRAVEEN RAJ
  DELHI COLLEGE OF ENGINEERING
 
  On Fri, Dec 30, 2011 at 2:17 PM, Lucifer sourabhd2...@gmail.com
 
wrote:
 
  @praveen
 
  I think what u are doing above is the following:
  Say, F(n) denotes the no. of binary trees that can be formed
 using N
  elements given the inorder sequence..
 
  F(n) = SumOver(i= 1 to N) { F(i-1) * F(N-i) }
 
  which is nothing but..
  F(N) = (2n C n)/ (n+1) i.e. catalan's no.
 
  Also, i would like to mention that in ur code probably u need to
  remove the following condition otherwise u result outcome will
 always
  be zero..
 
  *
  if(N==0) return 0;
 
  On 30 Dec, 13:41, praveen raj praveen0...@gmail.com wrote:
   int countBT(int N)
   {
 int count =0;
 int count1;
 if(N==0)
return 0;
  if(N=1)
return 1;
else
  {
  for(int j=1;j=N;j++)
  {
 count1 = countBT(j-1)
 count2 =countBT(N-j);
 count+=(count1*count2);
   }
 return (count);
   }
 
   }
 
   PRAVEEN RAJ
   DELHI COLLEGE OF ENGINEERING
 
  --
  You received this message because you are subscribed to the
 Google
Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com
 .
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
   --
  You received this message because you are subscribed to the
 Google
Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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

Re: [algogeeks] Re: Divisibility by five

2012-01-21 Thread Arun Vishwanathan
@dave or anyone: can u pls explain the logic of n3 in dave's solution? why
is it subtracted from n(which is divided by 4 using 2) and what does n 3
indicate?

On Sat, May 7, 2011 at 9:38 AM, Dave dave_and_da...@juno.com wrote:

 @Umer: Do you suppose that you can convert an int into a string
 without using division or mod, either directly or indirectly?

 Dave

 On May 4, 1:12 am, Umer Farooq the.um...@gmail.com wrote:
  I'm surprised to see that why are you guys making this problem so
 complex.
  This problem can be solved in two steps only.
 
  1- Convert the given int into string
  2- Check if the last character is 0 or 5. // it yes, then return true
 else
  return false
 
  for e.g.
 
  125 (last character is 5 ... therefore it is divisible by 5)
  120 (last character is 0 ... therefore it is divisible by 5)
  111 (last character is 1 ... therefore it is not divisible by 5)
 
  The pseudo-code has been written in my above email.
 
 
 
 
 
  On Wed, May 4, 2011 at 1:49 AM, Dave dave_and_da...@juno.com wrote:
   @anshu: Spoiler alert... I was thinking of something more along the
   line
 
   int DivisibleBy5 (int n)
   {
  n = n  0 ? n : -n;
  while( n  0 )
  n = (n  2) - (n  3);
  return (n == 0);
   }
 
   To see that it works, write n as n = 4*a + b, where 0 = b = 3. Then
   the iteration replaces n by a - b. Consider (4*a + b) + (a - b), the
   sum of two consecutive values of n. This simplifies to 5*a, which is a
   multiple of 5. Thus, n is a multiple of 5 before an iteration if and
   only if it also is a multiple of 5 afterwards,
 
   It is clearly log n because n is replaced by a number no greater than
   n/4 on each iteration.
 
   Examples:
   n = 125. The sequence of iterates is 30, 5, 0. Ergo, 125 is a multiple
   of 5.
   n = 84. The sequence of iterates is 21, 4, -1. Ergo, 84 is not a
   multiple of 5.
 
   Dave
 
   On May 3, 3:13 am, anshu anshumishra6...@gmail.com wrote:
algorithm:
 
if any number(a) is divisible by 5 it can be wriiten as 4*b + b --
this cleary shows the last two bit of a  b will be same.
 
lets understand by an example (35)10 = (100011)2
 
 xx1100
+   xx11
-
 100011
 
now this clearly shows we can calculate the unknowns(x) by traversing
right to left
 
code:
 
int main()
{
int n, m;
cin  n;
m = n;
 
int a, b;
int i=2;
 
a = (m3)2;
b = (m3);
m = 2;
 
bool rem = 0,s,r;
 
while (m3)
{
r = a(1i);
s = r^(m1)^rem;
b = b|(si);
a = a|(s(i+2));
rem = (rs)|(srem)|(rrem) ;
i++;
m = 1;
}
 
if (a+b == n) cout  yes\n;
else cout  no\n;
 
return 0;
 
}- Hide quoted text -
 
- Show quoted text -
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Umer- Hide quoted text -
 
  - Show quoted text -

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




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



Re: [algogeeks] how to convert a floating point number into binary representation.

2012-01-21 Thread Arun Vishwanathan
@immanuel:
in this part
 while (decimalPart  0  decimalPart  1  str.length  64) {
decimalPart *= 2;
str[str.length] = (decimalPart - 0) + '0';
}

is this decimalPart-0 correct here?
if decimalpart (say) starts as 0.584 then after doing that into 2 we 1.164.
What happens next according to your code?


On Tue, May 24, 2011 at 1:45 AM, immanuel kingston 
kingston.imman...@gmail.com wrote:

 correct me if I am wrong.

 String convertFloatToBinary(float num) {
String str = ;
int numBeforeDecimal = (int)num;
float decimalPart = num - (float)numBeforeDecimal;
int sign=1;
if (numBeforeDecimal  0 ) sign = -1;
if (sign  0) str[str.length] = '-';
while(numBeforeDecimal  0) {
  str[str.length] = numBeforeDecimal % 2 + '0';
  numBeforeDecimal /= 2;
}
str[str.length] = '.';
while (decimalPart  0  decimalPart  1  str.length  64) {
 decimalPart *= 2;
 str[str.length] = (decimalPart - 0) + '0';
}
return str;
 }

 Thanks,
 Immanuel


 On Tue, May 24, 2011 at 12:15 PM, Naveen Kumar naveenkumarve...@gmail.com
  wrote:

 http://kipirvine.com/asm/workbook/floating_tut.htm



 On Tue, May 24, 2011 at 12:09 PM, saurabh agrawal 
 saurabh...@gmail.comwrote:


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




 --
 Cheers
 Naveen Kumar

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



Re: [algogeeks] Re: distinct substring

2012-01-21 Thread Arun Vishwanathan
@juver: further explanation?

On Tue, Jan 25, 2011 at 6:27 AM, juver++ avpostni...@gmail.com wrote:

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




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



Re: [algogeeks] Re: google questions

2012-01-21 Thread Arun Vishwanathan
@all: how is the problem solved using a heap...can someone explain. did not
understand what was on the net...

On Thu, Feb 3, 2011 at 2:23 AM, Avik Mitra tutai...@gmail.com wrote:

 I am proposing a solution for problem 2..
 2.
  Given a text file, implement a solution to find out if a pattern
  similar to wild cards can be detected.
  fort example find if a*b*cd*, or *win or *def* exists in the text.

 Whatever be the pattern sort it must be regular expression. So in
 principle, there always exists a deterministic finite automata with
 exactly one finite state to accept the pattern.
 Thus, the problem can be solved. For example take the case for
 a*b*cd*. The automaton can  can written as:

 1.Set state=1.
 2. Scan the string until end of string is reached.
2.1. If state is 1 and the letter is a then do not change the
 state.
   If the state is 1 and the letter is b then go to state 2.
   if the state is 1 and the letter is c then go to state 3.
   if the state is 1 and the letter is d then go to state 4.

   if the state is 2 and letter is a then go to state 4.
   if the state is 2 and the letter is b then do not change
 the state.
   if the state is 2 and the letter is c the go to state 3.
   if the state is 2 and the letter is d then go to state 4.

   if the state is 3 and the letter is a,b or c then go to
 state 4.
   if the state is 3 and the letter is d then do not change
 state.

   if the state is 4 then do not change state.

   3. If the state is 3 output accept else output reject.

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



Re: [algogeeks] Re: Divisibility by five

2012-01-21 Thread Arun Vishwanathan
@dave: thanks for that..but i just wanted to know as to how u thot of
converting n to a-b in the iteration. when u say 4a +b is a multiple of 5
iff a-b is a muliple of 5 i was able to get that only when i tried an
example...if they ask divisbility by 3 or 6 or 7 how wud the logic change??

On Sat, Jan 21, 2012 at 9:34 AM, karthikeyan muthu 
keyankarthi1...@gmail.com wrote:

 check the last char ... it should be 0 or 5 , int to string without mod


 On Sat, Jan 21, 2012 at 10:05 PM, Dave dave_and_da...@juno.com wrote:

 @Karthikeyan: Is this supposed to relate to the question of
 determining divisibility by 5?

 Dave

 On Jan 21, 9:25 am, karthikeyan muthu keyankarthi1...@gmail.com
 wrote:
  @dave
 
  int no=10;
  char ans[100];
  sprintf(ans,%d,no);
  coutans;
 
  On Fri, Jan 20, 2012 at 10:29 PM, Arun Vishwanathan
  aaron.nar...@gmail.comwrote:
 
 
 
   @dave or anyone: can u pls explain the logic of n3 in dave's
 solution?
   why is it subtracted from n(which is divided by 4 using 2) and what
 does
   n 3 indicate?
 
   On Sat, May 7, 2011 at 9:38 AM, Dave dave_and_da...@juno.com wrote:
 
   @Umer: Do you suppose that you can convert an int into a string
   without using division or mod, either directly or indirectly?
 
   Dave
 
   On May 4, 1:12 am, Umer Farooq the.um...@gmail.com wrote:
I'm surprised to see that why are you guys making this problem so
   complex.
This problem can be solved in two steps only.
 
1- Convert the given int into string
2- Check if the last character is 0 or 5. // it yes, then return
 true
   else
return false
 
for e.g.
 
125 (last character is 5 ... therefore it is divisible by 5)
120 (last character is 0 ... therefore it is divisible by 5)
111 (last character is 1 ... therefore it is not divisible by 5)
 
The pseudo-code has been written in my above email.
 
On Wed, May 4, 2011 at 1:49 AM, Dave dave_and_da...@juno.com
 wrote:
 @anshu: Spoiler alert... I was thinking of something more along
 the
 line
 
 int DivisibleBy5 (int n)
 {
n = n  0 ? n : -n;
while( n  0 )
n = (n  2) - (n  3);
return (n == 0);
 }
 
 To see that it works, write n as n = 4*a + b, where 0 = b = 3.
 Then
 the iteration replaces n by a - b. Consider (4*a + b) + (a - b),
 the
 sum of two consecutive values of n. This simplifies to 5*a,
 which is a
 multiple of 5. Thus, n is a multiple of 5 before an iteration if
 and
 only if it also is a multiple of 5 afterwards,
 
 It is clearly log n because n is replaced by a number no greater
 than
 n/4 on each iteration.
 
 Examples:
 n = 125. The sequence of iterates is 30, 5, 0. Ergo, 125 is a
 multiple
 of 5.
 n = 84. The sequence of iterates is 21, 4, -1. Ergo, 84 is not a
 multiple of 5.
 
 Dave
 
 On May 3, 3:13 am, anshu anshumishra6...@gmail.com wrote:
  algorithm:
 
  if any number(a) is divisible by 5 it can be wriiten as 4*b +
 b --
  this cleary shows the last two bit of a  b will be same.
 
  lets understand by an example (35)10 = (100011)2
 
   xx1100
  +   xx11
  -
   100011
 
  now this clearly shows we can calculate the unknowns(x) by
   traversing
  right to left
 
  code:
 
  int main()
  {
  int n, m;
  cin  n;
  m = n;
 
  int a, b;
  int i=2;
 
  a = (m3)2;
  b = (m3);
  m = 2;
 
  bool rem = 0,s,r;
 
  while (m3)
  {
  r = a(1i);
  s = r^(m1)^rem;
  b = b|(si);
  a = a|(s(i+2));
  rem = (rs)|(srem)|(rrem) ;
  i++;
  m = 1;
  }
 
  if (a+b == n) cout  yes\n;
  else cout  no\n;
 
  return 0;
 
  }- Hide quoted text -
 
  - Show quoted text -
 
 --
 You received this message because you are subscribed to the
 Google
   Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
 
--
Umer- Hide quoted text -
 
- Show quoted text -
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
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

Re: [algogeeks] Re: vertical level sum in Binary tree

2012-01-21 Thread Arun Vishwanathan
my god why do companies question like this???

On Sat, Jan 21, 2012 at 4:10 AM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:

 yes atul I wanted to say only that may be not able to convey it . n is
 maximum number of vertical lines sum that you can calculate

 On 1/21/12, atul anand atul.87fri...@gmail.com wrote:
  @ UTKARSH : how will you calculate number of vertical lines before
 passing
  it to vsum().
 
  i guess n should be max(no. of nodes to the extreme left from the root ,
  no. of nodes to the extreme right from root)
 
  On Fri, Jan 20, 2012 at 10:35 PM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com
  wrote:
 
  void vsum(struct  node *p ,int i)
  {
  if(p)
  {
  sum[i] = sum[i] + p-data;
  vsum(p-left,i-1);
  vsum(p-right,i+1);
  }
  }
 
  construct an array of int sum[n] where n will be maximum no. of vertical
  lines and call vsum with vsum(root,n/2)
 
 
  On Fri, Jan 20, 2012 at 9:06 PM, sravanreddy001
  sravanreddy...@gmail.comwrote:
 
  what does it mean.. we cannot use an array? (a static array?)
 
  a vector is an array..but a dynamic one... what other DS can be used? a
  linked list allowed?
 
  (each of the two algorithms can be mate to work with linked list too...
  (except that it takes more time.. )
 
   --
  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/-/GN5SzfqtYlgJ.
 
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 


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




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



Re: [algogeeks] Re: vertical level sum in Binary tree

2012-01-21 Thread Arun Vishwanathan
no jst thinking if any practical application of this sort of thing..:)

On Sat, Jan 21, 2012 at 3:11 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:

 why arun?


 On Sun, Jan 22, 2012 at 1:44 AM, Arun Vishwanathan aaron.nar...@gmail.com
  wrote:

 my god why do companies question like this???


 On Sat, Jan 21, 2012 at 4:10 AM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:

 yes atul I wanted to say only that may be not able to convey it . n is
 maximum number of vertical lines sum that you can calculate

 On 1/21/12, atul anand atul.87fri...@gmail.com wrote:
  @ UTKARSH : how will you calculate number of vertical lines before
 passing
  it to vsum().
 
  i guess n should be max(no. of nodes to the extreme left from the root
 ,
  no. of nodes to the extreme right from root)
 
  On Fri, Jan 20, 2012 at 10:35 PM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com
  wrote:
 
  void vsum(struct  node *p ,int i)
  {
  if(p)
  {
  sum[i] = sum[i] + p-data;
  vsum(p-left,i-1);
  vsum(p-right,i+1);
  }
  }
 
  construct an array of int sum[n] where n will be maximum no. of
 vertical
  lines and call vsum with vsum(root,n/2)
 
 
  On Fri, Jan 20, 2012 at 9:06 PM, sravanreddy001
  sravanreddy...@gmail.comwrote:
 
  what does it mean.. we cannot use an array? (a static array?)
 
  a vector is an array..but a dynamic one... what other DS can be
 used? a
  linked list allowed?
 
  (each of the two algorithms can be mate to work with linked list
 too...
  (except that it takes more time.. )
 
   --
  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/-/GN5SzfqtYlgJ.
 
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 


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




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




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




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



Re: [algogeeks] segment tree

2012-01-21 Thread arun kumar
this link deal with applying lazy propagation for the problem LITE in spoj.
hope this one help you
http://apps.topcoder.com/forums/?module=ThreadthreadID=690098messageID=1298729mc=8view=tree#1298729
regards
arun

On Sat, Jan 21, 2012 at 6:10 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:

 Hi can anyone please give a good link to study lazy propagation in segment
 tree with example or code. I know segment tree but not about lazy
 propagation.

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



[algogeeks] anybody having K and R ebook?

2012-01-19 Thread Arun Vishwanathan
hey sorry if it seems offtopic to post here...but does anybody have an
ecopy of this book?I tried searching but cudnt find one properly.

thanks in advance!

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



Re: [algogeeks] Re: Amazon - Longest palindrome in a string in O(n)

2012-01-19 Thread Arun Vishwanathan
@varun : isn't the longest common subsequence  abccba and longest common
substring is
abc or cba?in any case what is the longest palindrom in the given string
abcdecba?? isnt it the individual letters itself ie length max is 1?
On Wed, Jun 22, 2011 at 10:45 AM, varun gupta varun.gt...@gmail.com wrote:

 That is what ankit said.


 Consider string: abcdecba
 Reverse of above string: abcedcba
 Longest common substring: abc and cba :

 you are calculating longest common *subsequence* not substring. Substring
 in continuous.


 On Wed, Jun 22, 2011 at 10:48 PM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 LCS stands for Longest Common Substring

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

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




 --
 Warm Regards,
 Varun Kumar
 Email Id: varun.gt...@gmail.com
 Contact: +91-9711751235

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



Re: [algogeeks] Re: Sorting for large data

2012-01-18 Thread Arun Vishwanathan
@ all : can someone provide me a good link to reading on external sort? and
k way merging?
is this also a useful way to sort when the number of records is large
compared to memory size but many entries in the records are repeated
elements?

On Tue, Jan 17, 2012 at 6:42 AM, sravanreddy001 sravanreddy...@gmail.comwrote:

 I agree with Gene,

 10^80 is of very larger magnitude, and is no way possible to solve given
 any amount of time,
 He might be testing you to '*think it practically before jumping to
 answer the question*' (or) he/you must have gone wrong somewhere.

 (even to read that input it takes for ever..)

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

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



[algogeeks] MS question

2012-01-18 Thread Arun Vishwanathan
Given large number of elements. All elements belong to range 1 to 27000.
First case no elements repeated and second case elements are repeated.
memory capacity is 4k. How to sort efficiently?

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

2012-01-18 Thread Arun Vishwanathan
@all : doesnt sudhir's solution seem to work??

@sudhir: can u explain yr logic?

On Wed, Sep 21, 2011 at 8:31 AM, annarao kataru kataruanna...@gmail.comwrote:

 can u explain the logic behind this

 thanks in advance

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




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



Re: [algogeeks] Re: Doubt in C++

2012-01-03 Thread Arun Vishwanathan
@lucifer: ok so you are saying that the constructor implicitly creates a
temporary 'string' object to hold this char string which is then assigned
to s2. Does this mean that if a constructor function was not specified
(unlike here where we have a parameterized constructor) this would not work
or does this sort of assingment require a single paramterized constructor?

On Tue, Jan 3, 2012 at 12:31 AM, Lucifer sourabhd2...@gmail.com wrote:

 @above..

 This is what i assume is happening ( apart from inherent compiler
 optimization is any)...Let me know if i m wrong..

 when s2=name; is done it should call the overloaded equal to
 operator..

 But, 'name' is not a string object, its basically a char pointer to a
 const string test..
 Now, for simplicity lets assume that name is char array..

 Now, given a binary operator, for the operation to take place both the
 operands ideally should be of the same type...

 For ex:
 int a;
 a = 10.0;
 Here, 10.0 is double and a is int, for the assignment to work first
 10.0 will be converted to int data type and then assigned to a..

 In case, the right hand side of a = operator cannot be converted to
 the left hand side type, then ideally an incompatible assignment shall
 be thrown..

 Going back to the above example... conversion of 10.0 to 10 is
 basically performed as part of implicit conversion or type propagation
 as part of basic data types (supported by the compiler)...

 Now class is a custom data type and hence, we don't expect the
 compiler to randomly convert from any data type to the class type for
 the '=' operator to work..
 Then how is it done..
 Basically constructors of a class act as implicit type converters as
 well...
 Hence, for statement similar to s2 = name;
 If 'name' is not of the type of s2 i.e.'string' type then it will try
 to look for implicit conversions..
 Now, a constructor of a class acts as an implicit converter as well..
 and a 'string' class has a constructor 'string(char *)', it will use
 'string(char*)' constructor to construct a temporary intermediate
 string object which will hold the value 'test' and then assign to
 s2...
 Once, assignment operation is over, the temporary string object
 containing the value 'test' will be destroyed..

 On Jan 3, 12:05 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  I just have a basic doubt..does the string s1,s2 statement call any
 default
  constructor?or is it that it is not performed since parameterised
  constructor is present?
 
  On Wed, Sep 21, 2011 at 1:31 AM, vijay singh vijaysinghb...@gmail.com
 wrote:
 
 
 
 
 
 
 
 
 
   It is because of the presence of the single parameterised constructor
 in
   the class definition.
   So, if we are writing the following statement...
   string s1;
   s1=test;
 
   It'll call the single parameterised constructor.
 
   But this only true in the case of single value assignment as in the
 above
   statement..
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.




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



Re: [algogeeks] Re: sqrt function...

2012-01-03 Thread Arun Vishwanathan
@gene:
I checked the wiki link given..In that it is mentioned that initial root is
chosen as 2.10^n or 6.10^n based on the number of digits being even or odd
in the number.
The concept of choosing 2 or 6 in this formula is based on some geometric
mean concept mentioned. Can you please clarify what they mean to say? I
wasnt able to follow that...

On Sun, Sep 25, 2011 at 3:06 AM, Gene gene.ress...@gmail.com wrote:

 Binary search isn't the right term.  Rather you want bisection.  But
 for each iteration it adds only one bit to the precision of the
 answer.

 You should also look at Newton's method. It doubles the number of bits
 of precision in each iteration.

 Algorithm: float sqrt(float x)
 root = intial guess
 while root^2 is not close enough to x do
  root = (x / root + root) / 2;
 return root;

 Wikipedia has a nice article with more details and in particular how
 to get a good initial guess.


 http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series

 On Sep 25, 8:29 am, Vikram Singh singhvikram...@gmail.com wrote:
  ok.. thanks guys...
  one doubt now... if this ques is asked in an interview(its already been
  asked in ms interview)... then u cant just write the code... u hv to
 explain
  the whole approach like why u r choosing that way to narrowing dowm the
  range...
 
  so pls explain how this sol is derived...
 
  On Sun, Sep 25, 2011 at 10:15 AM, keyan karthi 
 keyankarthi1...@gmail.comwrote:
 
 
 
   binary search!!! :)
 
   On Sat, Sep 24, 2011 at 11:38 PM, sunny agrawal 
 sunny816.i...@gmail.comwrote:
 
   let x be the number
   initialize ans to some value like x or x/2
 
   now repeatedly do the following
   ans  = (ans + x/ans)/2
   each time you perform this operation you will move closer to the sqrt
   value and depending upon the precision required stop
 
   On Sat, Sep 24, 2011 at 11:17 PM, siddharth srivastava 
   akssps...@gmail.com wrote:
 
   On 24 September 2011 13:45, shady sinv...@gmail.com wrote:
 
   one of the simplest way is to do binary search... :)
 
   +1
 
   On Sat, Sep 24, 2011 at 8:42 PM, teja bala 
 pawanjalsa.t...@gmail.comwrote:
 
  http://www.geeksforgeeks.org/archives/3187
 
   check dis one.
 
   --
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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
   Siddharth Srivastava
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
   Sunny Aggrawal
   B.Tech. V year,CSI
   Indian Institute Of Technology,Roorkee
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
 
  - Show quoted text -

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




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

Re: [algogeeks] Re: Doubt in C++

2012-01-03 Thread Arun Vishwanathan
@lucifer: thanks !

On Tue, Jan 3, 2012 at 9:02 AM, Lucifer sourabhd2...@gmail.com wrote:

 @Arun...

 Basically what u have asked boils down to 2 questions...

 1. First, this sort of assignment requires single parameterized
 constructor ?

 Yes ( and No as well in special cases.).
 But its not a mandate that the class defines...

 There is something called as implicit and explicit construction...

 Class X
 {
  public:
   X(){} // default constructor...
   X(int a) // single param constr
   X( int a, double b) // const with 2 parameters...
 };

 Now there are 2 ways of creating an object of class X which takes only
 one parameter..

 a)  X obj(10); // this is the most common way of doing it...
  // also here we are explicitly asking the compiler to use a
 particular constr whose prototype should match X(int );

 b) X obj = 10; // this is more uncommon way of doing it..
  // here , an implicit conversion happens and it goes as follows:
 /*
   i)  X temp = X(10); // creating temp object..
   ii) X obj = temp; // overloaded '=' operator called
   iii)  temp.~temp(); // destruct temp...

 Though, theoritically this is how it should create obj..
 But, due to compiler optimization a temporary object is not created
 and destroyed...

 But, to verify that there is a difference b/w implicit and explicit
 creation, u can look at generated assembly code and see that a
 reduntant copy operation is present in the assembly level code..
 This redundant copy code is to mimic the usage of default '='
 overloaded operator...i.e something similar to * mov bx, bx *

 */
 Given the above explanation we can say that we want to implicitly
 create an object which takes 2 parameters... Now, given the fact that
 '=' is a binary operator, there is no way we can use more than 2
 parameters in the expression..

 Say, i want to create:
  X obj(10, 2.0), implicitly... then ' X obj = 10 20 ' needs to be a
 valid expression.. Basically for this is happen there needs to be a
 way where the rhs can take more than 2 expression values.. which is
 not possible...

 Hence, implicit creation of objects only work with single
 parameterized constructors...

 Now, you must have seen that i have used the following statement
 above:
 *But its not a mandate that the class defines...* - the above
 explanation should justify this statement..

 *Yes ( and No as well in special cases.* - *Yes* is obvious as per the
 above explanation...
 Now, to show what *No* meant, say class X has the following
 constructor instead of the single parameterized constructor...
 ///
 X( int a, char *b = NULL, bool b = true);
 ///
 Now, by looking at it we can say that its not a single parameterized
 constr..hence it can't be used in implicit construction..
 But thats not true as the constructor as got default parameters except
 the first one which is int type...

 Hence, given the above constructor.. X obj = 10, is still valid...


 2. Does this mean that if a constructor function was not specified
 (unlike here where we have a parameterized constructor) this would not
 work ?

 Yes, should be self explanatory..


 

 Though its obvious but a conversion only works when RHS of '='
 operator can itself be assigned to the formal argument parameter of a
 constructor...
 Basically what i mean from the above statement is,
 apart from the basic types... it can also work for related(different
 not same) class types... say, the formal parameter of constrcutor has
 a base class type and the RHS of '=' has a derieved class type...



 On Jan 3, 7:52 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  @lucifer: ok so you are saying that the constructor implicitly creates a
  temporary 'string' object to hold this char string which is then assigned
  to s2. Does this mean that if a constructor function was not specified
  (unlike here where we have a parameterized constructor) this would not
 work
  or does this sort of assingment require a single paramterized
 constructor?
 
 
 
 
 
 
 
 
 
  On Tue, Jan 3, 2012 at 12:31 AM, Lucifer sourabhd2...@gmail.com wrote:
   @above..
 
   This is what i assume is happening ( apart from inherent compiler
   optimization is any)...Let me know if i m wrong..
 
   when s2=name; is done it should call the overloaded equal to
   operator..
 
   But, 'name' is not a string object, its basically a char pointer to a
   const string test..
   Now, for simplicity lets assume that name is char array..
 
   Now, given a binary operator, for the operation to take place both the
   operands ideally should be of the same type...
 
   For ex:
   int a;
   a = 10.0;
   Here, 10.0 is double and a is int, for the assignment to work first
   10.0 will be converted to int data type and then assigned to a..
 
   In case, the right hand side of a = operator cannot be converted to
   the left hand side type, then ideally an incompatible assignment shall

Re: [algogeeks] C output????

2012-01-03 Thread Arun Vishwanathan
actually is there any reason as to why same address is returned to the
pointer when both pointers(p and q) are initialised to persons unlike
when p[] and q[] =persons?

On Tue, Sep 6, 2011 at 9:08 AM, Sandy sandy.wad...@gmail.com wrote:

 String constants (literals) are saved into the .data section of the
 program,  Here is the sample program to show that.  if() is essentially
 comparing the addresses of two pointers which is same.

 int main()
 {
 char *p=persons;
 char *q=persons;
  char *r=persons;
 char *s=persons;
  printf(%x %x %x %x\n,p,q,r,s);
 if(p==persons)
 printf(technical %s,p);
  else
 printf(true %s,p);
 return 0;
 }
 -
 Output:
 403021 403021 403021 403021
 technical persons

 On Tue, Sep 6, 2011 at 9:04 PM, sivaviknesh s sivavikne...@gmail.comwrote:


 main()
 {
 char *p=persons;
 clrscr();
 if(p==persons)
 printf(technical %s,p);
 else
 printf(true %s,p);
 return 0;
 }

 ..op : technical persons ..plz explain .. how come it works like an
 strcmp operation???
 --
 Regards,
 $iva

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




 --

 *Sandeep Kumar,*
  ( Mobile +91-9866507368

 *“I believe in smart work, Believe Me”*


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




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



Re: [algogeeks] Explanation

2012-01-03 Thread Arun Vishwanathan
@Vrashabh: yea the explanation is kinda difficult to follow since f(1,2) is
once done first and once is not though the expressions look similarcan
u pls explain what decides the order of evaluation here

On Mon, Aug 29, 2011 at 6:23 AM, kartik sachan kartik.sac...@gmail.comwrote:

 see the out put will the help of gcc -E.u will get ur ans

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



Re: [algogeeks] Re: String passing

2012-01-03 Thread Arun Vishwanathan
if instead of passing hello directly to function if we passed char array
p then this would not show as an error right? and why is this so? is it due
to the fact tat p array was not possibly allocated in the read only segment
of memory and hence when passed it can be modified by function? so if const
string is passed directly what causes the error?

On Sat, Aug 27, 2011 at 11:28 AM, sagar pareek sagarpar...@gmail.comwrote:

 @raj

 u already mentioned that if we write :-
 char *p=hello;
 p[0]='k'; // gives runtime error


 so if we are passing arguments as

 modify(char a[],char *b)
 {
 .
 .
 }

 main()
 {
 .
 .
 modify(hello,hi);
 .
 .
 }


 then its actually
 char arr[]=hello;
 char *b=hi;

 so ofcourse now
 b[0]='a'; // give u runtime error

 now u may be confuse about
 arr[0]='a'; //gives runtime error

 here i would like to tell you that arr is char pointer not char array
 you can check by yourself in :-   http://www.ideone.com/EQrjj

 On Sat, Aug 27, 2011 at 10:39 PM, raj kumar megamonste...@gmail.comwrote:


 monsters are monsters



 -- Forwarded message --
 From: raj kumar megamonste...@gmail.com
 Date: Sat, Aug 27, 2011 at 10:30 PM
 Subject: Re: [algogeeks] Re: String passing
 To: algogeeks@googlegroups.com


 can't understand what are you trying to say

 source

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




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



Re: [algogeeks] Re: convert into palindrome

2012-01-02 Thread Arun Vishwanathan
@lucifer: can you please give a small example and explain?

Now, all we need to do is sequentially access the list and do the
following:
Given 2 pairs (xi, yi) and (x i+1, y i+1),
We will insert RevStr(yi .. y i+1) , excluding the extreme chars, just
before Str(x i+1)...


On Fri, Dec 16, 2011 at 4:26 AM, atul anand atul.87fri...@gmail.com wrote:

 Ignore my previous comment

 On 16 Dec 2011 17:35, atul anand atul.87fri...@gmail.com wrote:
 
  @All : can't we use Levenshtein algorithm to find min
 addition/deletion.??
 
 
  On Fri, Dec 16, 2011 at 2:50 PM, top coder topcode...@gmail.com wrote:
 
  @Lucifer
 
  I have got the intent of your logic.
 
  From the algo, We got to know how many characters need to be added.
  How do you concluded where do you need to add the characters exactly
  and What characters needs to be added?
  Also Could you comment on the time and space complexity?
 
 
  On Dec 15, 11:37 am, Lucifer sourabhd2...@gmail.com wrote:
   Correction:
  
   for NAN :
   N(IT)A + TI + N = NITATIN
  
   On Dec 15, 11:33 am, Lucifer sourabhd2...@gmail.com wrote:
  
  
  
@topcoder..
  
String: NITAN
  
RevStr: NATIN
  
LCS ( NITAN, NATIN) = { NIN , NAN }
  
Here all we care about the count which is 2. Hence, 2 additions
 would
be required to convert it into a palindrome..
  
The possible palindromes would be:
for NIN :
N + AT + I(TA)N = NATITAN
  
for NAN :
N + TI+ A(IT)N = NATITAN
  
On Dec 15, 11:24 am, top coder topcode...@gmail.com wrote:
  
 @Mohit
  
 Suppose for example
  
 String: NITAN
 LCS(Longest Common Subsequence) : NIN
  
 How do you get the palindrome with it?
  
 On Dec 15, 3:47 am, Lucifer sourabhd2...@gmail.com wrote:
  
  @Mohit
  
  I think what he meant is 2* strlen(Input String) - 2*
 (Length of
  LCS)
  
  On Dec 15, 3:44 am, Mohit kumar lal kumarmohit...@gmail.com
 wrote:
  
   @saurabh-as by the above example LCS of HELLO and its
 inverse would be
   LL and how can we form the word HELLOLLEH with it ...
   and is your ans for the word NITAN is NITATIN ...?
  
   On Wed, Dec 14, 2011 at 8:39 PM, saurabh singh 
 saurab...@gmail.com wrote:
Find the LCS of string with its reverse
  
On Wed, Dec 14, 2011 at 8:33 PM, top coder 
 topcode...@gmail.com wrote:
  
Given a word, convert it into a palindrome with minimum
 addition of
letters to it. letters can be added anywhere in the word.
  
. for eg if hello is given, result should be hellolleh
  
--
You received this message because you are subscribed to
 the Google Groups
Algorithm Geeks group.
To post to this group, send email to
 algogeeks@googlegroups.com.
To unsubscribe from 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.
  
   --
   Mohit kumar lal
   rit2009014
   IIIT ALLAHABAD
   contact@9454681805
   kumarmohit...@gmail.com
   mohitkumar...@yahoo.com
   rit2009...@iiita.ac.inhttp://
 profile.iiita.ac.in/rit2009014-Hidequotedtext -
  
  - Show quoted text -- Hide quoted text -
  
   - Show quoted text -
 
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 

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




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



Re: [algogeeks] Amazon Interview Question

2012-01-02 Thread Arun Vishwanathan
@utkarsh: in yr code it shud be two-- after the swap function and not
before for case 2

On Thu, Nov 10, 2011 at 1:25 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:



 sorry it was incomplete


 On Fri, Nov 11, 2011 at 2:53 AM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:
 one = zero = 0;
 two = n-1; //n is length of string

 while(two=one)
 {
   switch(a[one])
   {
   case '0' : swap(a[zero],z[one]);
one++;zero++;break;
 case '1' : one++;
break;
   case '2' : two--;
 swap(a[one],a[two]);

 }
 }




 On Mon, Oct 24, 2011 at 9:50 PM, praveen raj praveen0...@gmail.comwrote:

 This can be done in O(n)..

 first shift all the 2's to the right side in O(n)...

 then again shift 1to the right shift b efore 2's. in O(n)...


 With regards,

 Praveen Raj
 DCE-IT 3rd yr
 735993
 praveen0...@gmail.com




 On Mon, Sep 26, 2011 at 6:23 PM, Naren s sweetna...@gmail.com wrote:

 dutch national flag problem..search in wiki...classical.

 On Sat, Sep 24, 2011 at 9:39 AM, VIHARRI viharri@gmail.com wrote:

 You are given a string (consisting of 0's, 1's or 2's) where 0
 represents a blue ball, 1 a
 red ball, and 2 a black ball. Using only swap operations (counting
 sort not allowed)
 rearrange the string such that all blue balls are together on one
 side, followed by all red
 balls, and then all black balls. You can iterate through the string
 only once.
 Eg 102112011 should 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.




 --
 *Narayanan S,*
 B.E., C.S.E., (final year),
 College Of Engineering Guindy,
 Anna University,
 Chennai-25.


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





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




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



Re: [algogeeks] Amazon Interview Question

2012-01-02 Thread Arun Vishwanathan
also I dont think that for case 0 we do not need to have one ++. I guess it
fails for this example

2200101

On Mon, Jan 2, 2012 at 5:36 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote:

 @utkarsh: in yr code it shud be two-- after the swap function and not
 before for case 2


 On Thu, Nov 10, 2011 at 1:25 PM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:



 sorry it was incomplete


 On Fri, Nov 11, 2011 at 2:53 AM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:
 one = zero = 0;
 two = n-1; //n is length of string

 while(two=one)
 {
   switch(a[one])
   {
   case '0' : swap(a[zero],z[one]);
one++;zero++;break;
 case '1' : one++;
break;
   case '2' : two--;
 swap(a[one],a[two]);

 }
 }




 On Mon, Oct 24, 2011 at 9:50 PM, praveen raj praveen0...@gmail.comwrote:

 This can be done in O(n)..

 first shift all the 2's to the right side in O(n)...

 then again shift 1to the right shift b efore 2's. in O(n)...


 With regards,

 Praveen Raj
 DCE-IT 3rd yr
 735993
 praveen0...@gmail.com




 On Mon, Sep 26, 2011 at 6:23 PM, Naren s sweetna...@gmail.com wrote:

 dutch national flag problem..search in wiki...classical.

 On Sat, Sep 24, 2011 at 9:39 AM, VIHARRI viharri@gmail.comwrote:

 You are given a string (consisting of 0's, 1's or 2's) where 0
 represents a blue ball, 1 a
 red ball, and 2 a black ball. Using only swap operations (counting
 sort not allowed)
 rearrange the string such that all blue balls are together on one
 side, followed by all red
 balls, and then all black balls. You can iterate through the string
 only once.
 Eg 102112011 should 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.




 --
 *Narayanan S,*
 B.E., C.S.E., (final year),
 College Of Engineering Guindy,
 Anna University,
 Chennai-25.


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





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




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




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



Re: [algogeeks] Doubt in C++

2012-01-02 Thread Arun Vishwanathan
I just have a basic doubt..does the string s1,s2 statement call any default
constructor?or is it that it is not performed since parameterised
constructor is present?

On Wed, Sep 21, 2011 at 1:31 AM, vijay singh vijaysinghb...@gmail.comwrote:

 It is because of the presence of the single parameterised constructor in
 the class definition.
 So, if we are writing the following statement...
 string s1;
 s1=test;

 It'll call the single parameterised constructor.

 But this only true in the case of single value assignment as in the above
 statement..

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



Re: [algogeeks] Sum of Four Numbers in an Array (Amazon)

2012-01-01 Thread Arun Vishwanathan
does this make sense?
1)sort array  O(nlogn)
2)keep 4 pointer to last 4 elements of array. At each point in the
algorithm we need to ensure than ijkl where i j k and l are positions of
the 4 pointers.
3)if(sum of those 4 elements  k) there exists no such combination
else
do binary search with all 4 pointers in nested loop fashion
for example if 20 elements in array , say with binary search last pointer
starts pointing to position 10. then 3rd last pointer will point to 10/2=5
and 2nd last pointer points to 5/2 =2and first pointer points to 2/2 =1st
position. After first pointer is done with binary search, then second
pointer moves to next position according to binary search (less than
position of 3rd pointer )and then first pointer again does binary search in
this new space etc etc...basically it is something like
O(logn*logn*logn*logn)...I guess this is less than O(n^3)??




On Sun, Jan 1, 2012 at 10:31 AM, atul anand atul.87fri...@gmail.com wrote:

 sort(arr);
 min=arr[0]+arr[1]+arr[2]+arr[3];
 max=arr[n-1]+arr[n-2]+arr[n-3]+arr[n-4];

 for(i=0;in-3;i++)
 {
  a=arr[i];
  k=i+1;
  l=n-1;
  m=n-2;
  while(kl)
  {
   b=arr[k];
   c=arr[l];
   d=arr[m];
   if(a+b+c+d == num)
   {

  printf(\nNumber found (%d + %d + %d + %d ) = %d,a,b,c,d,num);
  flag=1;
  break;
   }
   else if(a+b+c+d  num)
   {
 l--;
  m--;
   }
   else
   {
   k++;

   }

  }

 if(flag)
   break;
 }


 complexity = O(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.




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



Re: [algogeeks] Re: given a stream of numbers FIND MEDIAN

2011-12-26 Thread Arun Vishwanathan
@lucifer: can you explain to me in the current median calculation why if
there is a Diff =1 or -1 you are using M and top(maxh) or M and top(minh)
for median calculation. If the number of elements from the stream so far is
odd then median is just one element and not average of 2 elements right?


On Fri, Dec 16, 2011 at 2:06 AM, Lucifer sourabhd2...@gmail.com wrote:

 @sangeeta

 I think your question is, given an input stream of nos., at any random
 time, we need to find what's the current median.

 For eg- say 4 nos have been read till now, hence, whats the median in
 those 4 nos. Say now, 7 nos have been read till now from the stream so
 which is the current median.. Am i ryt?

 If my above understanding is correct.. then the following approach
 might work..

 Take a variable to store the actual median, say M.
 Take 2 heaps, one min-heap and one max heap say, minH and maxH.
 Take a variable to store the difference in the no. of elements stored
 by both the heaps i.e { count(maxH) - count(minH) }

 We need to maintain the following constraint :-
 The size of minH and maxH shouldn't differ by more than one.

 Say, currently the no. of elements scanned is odd hence, the storage
 state will be as follows:

 1) sizeof minH = size of maxH
 2) M will give u the median.

 Say, currently the no. of elements scanned is even hence, the storage
 state will be as follows:

 1) abs(sizeof maxH - size of minH) = 1
 2) M will give u the median.
 3) Ideally there are 2 median elements in this case, hence to get the
 second median get the top element of the heap which has more no. of
 elements.
 i.e If sizeof minH  sizeof maxH, then top(minH) is the other median,
 apart from M, else top(maxH) is the other median.

 Algorithm :

 Say, the difference of the size of the heaps is stored in variable,
 Diff = size(maxH) - size(minH)
 // Diff can have values -1, 0, 1..
  0- size(minH) = size(maxH),
 -1 - size(minH) = size(maxH) + 1
  1 - size(maxH) = size(minH) + 1

 Get the no. from the stream, say X...
  a) If M is empty then put M = X;
  b) Else,
  If (Diff == 0)
  {
  If (M= X)
Add X to maxH; Diff = 1;
  else
Add X to minH; Diff = -1;
  }
  else If (Diff == -1)
  {
  if (M=X)
Add X to maxH;
  else
   {
 Add M to maxH;
 If (X = top(minH))
M = X;
 else
 {
M = top(minH);
top(minH) = X;
heapify for top(minH);
 }
   }
   Diff = 0;
   }
  else
  {
  if (X=M)
Add X to minH;
  else
   {
 Add M to minH;
 If (X = top(maxH))
M = X;
 else
 {
M = top(maxH);
top(maxH) = X;
heapify for top(maxH);
 }
   }
   Diff = 0;
   }

 To get the current median:
 if (Diff == 0)
Current median = M;
 else if (Diff == -1 )
   Current median = top(minH) and M;
 else
   Current median = M and top(maxH);


 On Dec 16, 12:50 pm, arvind kumar thebossku...@gmail.com wrote:
  Hi,have a look at this,n revert back in case of doubts:
 http://www.cs.cmu.edu/~avrim/451/lectures/lect0903.pdf
 
 
 
 
 
 
 
  On Fri, Dec 16, 2011 at 12:56 PM, Sangeeta sangeeta15...@gmail.com
 wrote:
   You are given a stream of numbers which can be positive or negative.
   You are
   required to provide an operation FIND MEDIAN..which when invoked
   should be
   able return the median of the numbers in stream (in sorted order) 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 athttp://
 groups.google.com/group/algogeeks?hl=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.



Re: [algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-22 Thread Arun Vishwanathan
@atul: can you explain what this is doing?
for(i=0;in;i++)
{

 pre=reverse(root-children[i],NULL);

 if(pre)
 {
  pre-children[i]=root;
 }
 }

when u do tree reversal I see that child points to parent( basically
direction reversed). Now if
1
   /|\
 234
  //\
5   6  7
 /\
89

in the last iteration along leftmost path , pointer to 8 is returned(pre)
whose child is then assigned as 5 using pre-children[0]=root
if 5 had another child say 'x' then after x is returned from thr recursive
call, u wud assign pre-children[1]=root where root is pointer to 5
here..but 8 and x have only one child which is 5  and indexes used for each
are 0 and 1 instead of just 0..am i understanding it wrongly?


On Wed, Dec 21, 2011 at 8:37 PM, atul anand atul.87fri...@gmail.com wrote:

 adding one more check :- this one is updated


 node *Reverse(node *root,node *pre)
 {
  flag=0;

 for i=0 to n
if (root-children[i]!=NULL)
{
  flag=1;
  break;
}
 end for

 if( ! flag)
 {
   add root to the list;
   return root;
 }

 for(i=0;in;i++)
 {
 if(root-children[i]!=NULL)
  {
 pre=reverse(root-children[i],NULL);

   if(pre)
   {
   pre-children[i]=root;
   }
   }
 }

 return root;

 }


 On Thu, Dec 22, 2011 at 9:35 AM, atul anand atul.87fri...@gmail.comwrote:

 adding break to first loop...just to avoid unnecessary iterations.
 if (root-children[i]!=NULL)
{
  flag=1;
  break;

}
 end for


 On Wed, Dec 21, 2011 at 10:59 PM, atul anand atul.87fri...@gmail.comwrote:

 @shashank:

 yeah here is the algo , please me know if you find any bug:-


 node *Reverse(node *root,node *pre)
 {
  flag=0;

 for i=0 to n
if (root-children[i]!=NULL)
{
  flag=1;
}
 end for

 if( ! flag)
 {
   add root to the list;
   return root;
 }

 for(i=0;in;i++)
 {

  pre=reverse(root-children[i],NULL);

  if(pre)
  {
   pre-children[i]=root;
  }
  }

 return root;

 }




 On Wed, Dec 21, 2011 at 1:08 PM, WgpShashank shashank7andr...@gmail.com
  wrote:

 @atul,, yeah , but can you write some proper psuedo code/ Algorithm
 then we can discus more about test cases.

 Thanks
 Shashank

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

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



Re: [algogeeks] Return index of first mismatch bracket ( or )

2011-12-20 Thread Arun Vishwanathan
@shady: I guess first mismatch means the innermost open brace that doesnt
have a close brace. U cannot know that the first brace does not have a
closing one unless u look at the entire string.

On Tue, Dec 20, 2011 at 9:23 AM, shady sinv...@gmail.com wrote:

 ( ( ) ( ( ) ( ( ) ) (  )  for this SAMM faulty index is 0, because the
 first bracket has itself found no matching

 @atul
 ( ( ( () ) ) for this first bracket is faulty as it couldn't find a
 closing bracket, , ,
 you can keep a stack with map as element
 stack mapint, char 

 mapint, char where integer is the index of the bracket, which is stored
 as char
 idea is similar to don's.


 On Tue, Dec 20, 2011 at 10:42 PM, atul anand atul.87fri...@gmail.comwrote:

 there are multiple mismatch or only one mis-match in the input string.

 if the given string as below :-

 ( ( ( () ) ) - for this is missing match is for 1st , 2nd or 3rd
 bracket.

 what would be the answer for this.

 On Tue, Dec 20, 2011 at 8:10 PM, zeroByZero shri.nit...@gmail.comwrote:

 In a given string arrary arr[] = ((()()) or any other string return
 index for which no match is found as for this example is index 0 and
 for ()()()(() is index 6

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



[algogeeks] ACM-ICPC Kanpur 2011 LCM Extreme

2011-12-18 Thread arun kumar
long long function( int n ) {
long long res = 0;
for( int i = 1; i = n; i++ )
for( int j = i+1; j = n; j++ )
  res+=lcm(i,j);
return res;
}

N=5*10^6 and TestCases=25000.. TimeLimit=5s
Can anyone give hints to solve this ?
Thanks in advance !

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



Re: [algogeeks] find numbers if pair wise sums are given

2011-12-13 Thread Arun Vishwanathan
how is the case taken of when 2 pairs add to the same sum?...

On Tue, Dec 13, 2011 at 11:35 AM, atul anand atul.87fri...@gmail.comwrote:

 hmmm i guess i screwed by taking least element as a part of the output set
 directly.




 On Wed, Dec 14, 2011 at 12:57 AM, sayan nayak sayanna...@gmail.comwrote:

 @atul:
 Suppose the input is :(7,8,9)

 So output should be (3,4,5)

 then ur approach is not giving the answers..

 Regards,
 Sayan

 On Tue, Dec 13, 2011 at 11:51 PM, atul anand atul.87fri...@gmail.comwrote:

 i am not sure , but this came to me when i first read it

 here is the idea:-
 given : 4 5 7 10 12 13

 4 should be there boz it is the least.

 next is 5 , 5-4 =1 which is less that 4 , so 1 should be there

 next is 7 , 7-4 = 3 which is less than 4 , so 3 should be there

 next is 10 , 10-4 = 6 which is greater then 4 , so add previous found
 elements
 i.e 1,3,4 add them 1+3+4 = 8 , add 1 to 8 = 9

 now check ,can we use this number(i.e 9 ) and previous found elements (
 1,3,4) to
 form 10 ( 9 +1) : yes - so 9 should be there

 next is 12 , 12-4 = 8 ( but now greatest element among 1,3,4,9 is 9) and
 8  9 ,so skip;

 next is 13 , 13-4 = 9 same reason for skipping as for number 12 before.



 On Tue, Dec 13, 2011 at 10:28 PM, top coder topcode...@gmail.comwrote:

 If pairwise sums of 'n' numbers are given in non-decreasing order
 identify the individual numbers. If the sum is corrupted print -1
 Example:
 i/p:
 4
 4 5 7 10 12 13

 o/p:
 1 3 4 9

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




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



[algogeeks] median from continuous stream

2011-11-08 Thread Arun Vishwanathan
Hi to find running median from a stream of random generated numbers I have
heard of the 2 heap ( min and max heap ) solution but I fail to understand
it...could someone please explain with a small example or so ??

thanks!

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



Re: [algogeeks] Re: Searching In a large file

2011-10-29 Thread Arun Vishwanathan
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.



[algogeeks] finding anagrams in file

2011-10-18 Thread Arun Vishwanathan
Hi all,

How to find all the anagrams in a large file containing n words and max
length of a word is m letters??

so if file contains add dad abc ced cba it shud say adc dad are anagrams and
abc cba are anagrams.
time needed is 0(nlogn)


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



Re: [algogeeks] Re: finding anagrams in file

2011-10-18 Thread Arun Vishwanathan
Hmm I see but if there are m max letters in each word and there are n words
in the file, then each word sort is O(mlogm) and for n words so wont it be
O(nmlogm)?

On Tue, Oct 18, 2011 at 12:55 PM, WgpShashank shashank7andr...@gmail.comwrote:

 Sort the all the string , Calculate hash-value , if the two has same hash
 vale they have to be anagram. put in group on the basis of anagram.
 leme know if i missed anything ?

 TC O(nlogm) n =number of words m is length of max string


 Shashank
 CSE,BIT Mesra

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



Re: [algogeeks] Re: finding anagrams in file

2011-10-18 Thread Arun Vishwanathan
also what would be a suitable hash function for the string?

On Tue, Oct 18, 2011 at 1:21 PM, Arun Vishwanathan
aaron.nar...@gmail.comwrote:

 Hmm I see but if there are m max letters in each word and there are n words
 in the file, then each word sort is O(mlogm) and for n words so wont it be
 O(nmlogm)?


 On Tue, Oct 18, 2011 at 12:55 PM, WgpShashank 
 shashank7andr...@gmail.comwrote:

 Sort the all the string , Calculate hash-value , if the two has same hash
 vale they have to be anagram. put in group on the basis of anagram.
 leme know if i missed anything ?

 TC O(nlogm) n =number of words m is length of max string


 Shashank
 CSE,BIT Mesra

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




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



[algogeeks] MS-IT

2011-09-21 Thread ankit arun
hi!! MS-IT is visiting our college. could anyone plz help me in knowing what 
kind of questions(interview) they asked/asking.

Thanks in advance.


Ankit Arun
NIT Durgapur

-- 
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/-/H09-9Q6HMUIJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] complement

2011-09-18 Thread Arun Vishwanathan
Hi all,

When I take negation of an integer in C, 0 is displayed as -1
~5 is displayed as -6.
Can some one tell me the logic of how this conversion is happening in C?

Arun

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

2011-09-18 Thread Arun Vishwanathan
Thanks Dave , appreciate it

On Sun, Sep 18, 2011 at 7:15 PM, Dave dave_and_da...@juno.com wrote:

 @Arun: This is the way two's complement arithmetic works. For any x, -
 x = ~x + 1. This says that to negate a number, complement it and add
 1.

 Technically speaking, two's complement is a weighted code. Each bit
 position has a certain weight that is added in if the bit in that
 position is a 1. Counting from the right (low-order bit), the weights
 are 1, 2, 4, 8, ..., -2^(n-1), where n is the number of bits in the
 integer. Thus, for example, for 8 bit integers, the weights are 1, 2,
 4, 8, 16, 32, 64, and -128.

 Let bi be the ith bit of the number, counting from the right with
 the low order bit being bit 0. Let wi be the weight of the ith bit.
 Then the value of the number is

 V = sum from i = 0 to n-1 of (bi * wi).

 The value of the complement of the number is

 ~V = sum from i = 0 to n-1 of ((1 - bi) * wi),

 where 1 - bi is the complement of bit i, i.e., ~bi. Then

 V + ~V = sum from i = 0 to n-1 of wi since bi cancels -bi for
 every i.

 The sum of the weights is -1. Thus, V + ~V = -1, from which -V = ~V +
 1.

 Dave

 On Sep 18, 5:26 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
  Hi all,
 
  When I take negation of an integer in C, 0 is displayed as -1
  ~5 is displayed as -6.
  Can some one tell me the logic of how this conversion is happening in C?
 
  Arun

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



[algogeeks] Re: K-LCS

2011-09-18 Thread Arun
Suffix Tree

On Sep 18, 4:17 pm, pooja pooja27tan...@gmail.com wrote:
 Can some one please help me with this..
 the problem is to find  the longest substring in a list of around 100
 strings..??
 any 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.



Re: [algogeeks] Linkedlist problem

2011-09-06 Thread Arun prasath
if(nodeptr) {


 }

On Mon, Sep 5, 2011 at 5:29 PM, $hr! k@nth srithb...@gmail.com wrote:

 Hi guyz,

 *Given only a pointer to a node to be deleted in a singly linked list, how
 do you delete it?*

 if that node is in between the list, we can copy the data from next node
 into this node and we can delete the next node.
 what if the node to be deleted is last node ??
 if the list is circular linked list, does it make any difference??

 --
 Regards,
 $hr!k@nth

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

2011-09-01 Thread ankit arun
@ raj

which clg r u from? I would say btr to choose its branch in Singapore.

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

2011-08-26 Thread ankit arun
thanks everybody for so many suggestions... :)

On Sat, Aug 27, 2011 at 6:40 AM, Rahul raikra...@gmail.com wrote:

 If the seeker wants to do entire self study , then I would suggest CS
 106B Reader , it's in C ++ , BUT ideal for people who rely only on
 internet.  ALso that Data STructure USing C ,Book by Y. KAnitikar , I
 never saw any math in any chapters  for analysis of  algorithms they
 write
 . lol. Google it as CS106B reader.

 On 8/26/11, sukran dhawan sukrandha...@gmail.com wrote:
  wat are u tying to say :P ? is that a good book or wat ?
 
  On Fri, Aug 26, 2011 at 7:55 PM, saurabh singh saurab...@gmail.com
 wrote:
 
  Yayashwant kanitekar and deepali srivastava are great books
 
  If you find all the mistakes that they have made you have learned DS(and
  coding style) quite well.:p
 
  On Fri, Aug 26, 2011 at 2:44 PM, Suraj Fale surajfa...@gmail.com
 wrote:
 
  A book by 'Yashwant Kanetkar'
 
 
  On Fri, Aug 26, 2011 at 9:03 AM, Navneet navneetn...@gmail.com
 wrote:
 
  Ankit, i would also like to mention Mark Allan Weiss book on Data
  Structures. Available in both C and C++ (different books)
 
  On Aug 25, 3:59 pm, Abhishek mailatabhishekgu...@gmail.com wrote:
   for simplicity use,
   Data Structures Through C in Depth -S. K. Srivastava, Deepali
  Srivastava
  
   all the topics are discussed in very simple manner.
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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
  Suraj Fale
  +91-9766103115
 
 
   --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 


 --
 Rahul

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




-- 
*Thanks  Regards*
*Ankit Arun
Training Placement Representative
Information Technology
NIT Durgapur
BLOG*: www.obeyurthirst.blogspot.com http://www.obeyankit.blogspot.com

*Mobile No. - +91 9635333100*

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

2011-08-26 Thread ankit arun
Ya sure... :)
After posting it Igot even more confused...

On Sat, Aug 27, 2011 at 9:33 AM, siddharth srivastava
akssps...@gmail.comwrote:



 On 27 August 2011 08:48, ankit arun talk.ankit...@gmail.com wrote:

 thanks everybody for so many suggestions... :)



 so let us know when you finish all those :P




 On Sat, Aug 27, 2011 at 6:40 AM, Rahul raikra...@gmail.com wrote:

 If the seeker wants to do entire self study , then I would suggest CS
 106B Reader , it's in C ++ , BUT ideal for people who rely only on
 internet.  ALso that Data STructure USing C ,Book by Y. KAnitikar , I
 never saw any math in any chapters  for analysis of  algorithms they
 write
 . lol. Google it as CS106B reader.

 On 8/26/11, sukran dhawan sukrandha...@gmail.com wrote:
  wat are u tying to say :P ? is that a good book or wat ?
 
  On Fri, Aug 26, 2011 at 7:55 PM, saurabh singh saurab...@gmail.com
 wrote:
 
  Yayashwant kanitekar and deepali srivastava are great books
 
  If you find all the mistakes that they have made you have learned
 DS(and
  coding style) quite well.:p
 
  On Fri, Aug 26, 2011 at 2:44 PM, Suraj Fale surajfa...@gmail.com
 wrote:
 
  A book by 'Yashwant Kanetkar'
 
 
  On Fri, Aug 26, 2011 at 9:03 AM, Navneet navneetn...@gmail.com
 wrote:
 
  Ankit, i would also like to mention Mark Allan Weiss book on Data
  Structures. Available in both C and C++ (different books)
 
  On Aug 25, 3:59 pm, Abhishek mailatabhishekgu...@gmail.com wrote:
   for simplicity use,
   Data Structures Through C in Depth -S. K. Srivastava, Deepali
  Srivastava
  
   all the topics are discussed in very simple manner.
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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
  Suraj Fale
  +91-9766103115
 
 
   --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.
 
 


 --
 Rahul

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




 --
 *Thanks  Regards*
 *Ankit Arun
 Training Placement Representative
 Information Technology
 NIT Durgapur
 BLOG*: www.obeyurthirst.blogspot.com http://www.obeyankit.blogspot.com

 *Mobile No. - +91 9635333100*

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


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




-- 
*Thanks  Regards*
*Ankit Arun
Training Placement Representative
Information Technology
NIT Durgapur
BLOG*: www.obeyurthirst.blogspot.com http://www.obeyankit.blogspot.com

*Mobile No. - +91 9635333100*

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

[algogeeks] Suggestion

2011-08-25 Thread ankit arun
Plz suggest me a good book for Data structure in C.

-- 
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/-/q93wVIu_W9IJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, 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: Remove all Duplicates Words

2011-08-25 Thread Arun Vishwanathan
@anup: can u provide a sort of pseudocode as to how ur code is O(n)?firstly
u need to find out which word might have a repetition. so u compare first
character of first word with all the other first characters.if there is not
repetition , then u have to compare first character of second word with all
the first character of words ahead of it and so on till u might sense a
repetition.once u find a repetition u shift all the remaining words over the
duplicated word.this is O(n) again.
so are u doing this with a lot of pointers or how is that u keep it O(n)
overall?

On Thu, Aug 25, 2011 at 9:56 AM, sagar pareek sagarpar...@gmail.com wrote:

 thanks ankur khurana

 @dave
 May be u never did any mistake in posting and reading the problems.
 But dont think urself superior.
 Yeah i did mistake in reading the question so u must either ignore it or
 request me to not repeat it in future.
 You are behaving like its my daily routine of doing such kind of things.


 On Thu, Aug 25, 2011 at 11:56 AM, Anup Ghatage ghat...@gmail.com wrote:

 Actually, this method will be O(n) for any number of occurrences of a
 single word, but It will go into O(n^2) for multiple occurrences of multiple
 words.

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




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



Re: [algogeeks] Re: C doubt

2011-08-24 Thread Arun Vishwanathan
thanks guys!

On Wed, Aug 24, 2011 at 6:37 PM, Don dondod...@gmail.com wrote:

 Yes, the memory provided by malloc will not be in the structure. Only
 the pointer to that memory will be in the structure. The size of a
 struct is defined at compile time, so it can't be dynamically sized at
 run time.

 struct junk
 {
  int size;
  int *data;
 };

 Somewhere in the code:

 struct junk myJunk;
 myJunk.size = n;
 myJunk.data = (int *)malloc(n * sizeof(int));

 for(i = 0; i  n; ++i)
  myJunk.data[i] = i;

 That should work for values of n which your memory can support.
 sizeof(struct junk) is eight bytes even if it contains a pointer to a
 million integers.

 Don

 On Aug 24, 11:04 am, sagar pareek sagarpar...@gmail.com wrote:
  See if we use dynamic memory allocation then still the size of pointer
 will
  be 4 bytes only
  Mean that int* pointer still have the size equals to pointer ... malloc
 only
  returns new alloted memory which is now only  *pointed *by that pointer
 
  check this out :-http://www.ideone.com/20ayq
 
 
 
  On Wed, Aug 24, 2011 at 8:10 PM, Don dondod...@gmail.com wrote:
   If you are working in C++, stl has a vector container class which will
   do this. Otherwise, declare an integer pointer in the struct and use
   malloc to allocate memory for it. Then you can use it like an array.
   Don
 
   On Aug 23, 11:51 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote:
say that you have a structure with some fields of known size and
 unknown
size.For example, a char, an integer and an integer array.I do not
 know
   the
size of the integer array until the user mentions the number of bytes
 he
needs this integer array to cover in the command line as an
 argument.Is
   it
possible to have a structure with an integer dynamic array?
 
Arun
 
--
 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.
 
  --
  **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.




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



[algogeeks] C-hexadecimal doubt

2011-08-24 Thread Arun Vishwanathan
Hi all,

I need to store a hexadecimal value in C( which would be used as a request
type in a  network) of around 4digits( or 16 bits-2 bytes ) in a packet
structure.If my system keeps 4 bytes for an integers, is it necessary that I
have to declare the hex value as of type short int or so, so that it takes
up only 2 bytes in my packet ? What if it was required to have a hex value
of 3 bytes or so? How could i store it then?
Also if hex value was to be of a multiple of 4 bytes would i need to use
something like an integer array to store them or a float maybe?

thanks!

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



  1   2   3   >