Re: [algogeeks] One question on Heap sort

2010-06-05 Thread Rohit Saraf
try running it on a data sample.
only that can make it clear.

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] Re: sorted 2-d array

2010-06-05 Thread vinayan c
assuimg the array is sorted likeeach number below is less than the one
above and more than the one right to it

start from the bottom right ..start moving right until u reach anumber less
than zerocalcuate the num of negative elements in that row(n-current
columng pos)..and then move upwards until u find one higher than zero..while
moving keep on counting the numbr of negative elemts in that row..(n-current
columng pos)...and then again move right from there...go on in this format
until u reach some end



On Sun, Jun 6, 2010 at 8:57 AM, Minotauraus  wrote:

> 1. check arr[0][0]. If this is non negative, there are 0 negative
> numbers. (assuming sorting is ascending)
> 2. for arr[i][j], increment j until you hit a non-negative number.
> this index will be limitRow
> 3. increment i, until you hit a non-negative number, this index will
> be limitColumn,
>  for i for jif(arr[i][j] <0)
> negativeCount++;
> limitColumn=j;
>   if(limitColumn == 1) break;
>
> This is 
>
> On Jun 5, 12:08 pm, divya  wrote:
> > Given an n X n array with rows sorted and cols sorted, find the number
> > of negative elements in most efficient way
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] One question on Heap sort

2010-06-05 Thread Anand
@Rohit I could understand your solution.

second step is sort the element using heap sort.

On Sat, Jun 5, 2010 at 9:04 PM, Rohit Saraf wrote:

> Can u elaborate on the 2nd step.
> btw, did u understand my soln?
>
> --
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] Re: partion of array

2010-06-05 Thread Rohit Saraf
This is almost the most basic dp. Read some of the examples from eva
tardos. That would help.

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] One question on Heap sort

2010-06-05 Thread Rohit Saraf
Can u elaborate on the 2nd step.
btw, did u understand my soln?

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] Re: Largest even length palindrome in a string!!

2010-06-05 Thread Rohit Saraf
Just read your code. It wont even work.
Do you assume only one even length palindrome!?

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] One question on Heap sort

2010-06-05 Thread Anand
My approach:

let's say we have two sorted arrays.
array1= x1, x2 x3
array2 = y1, y2, y3
array3= z1, z2,z3
all three arrays are sorted.

1. sort x1,y1,z1 using heap sort.
2. do this for rest of the elements of the array to create a final sorted
array in O(nlogk)


On Sat, Jun 5, 2010 at 8:45 PM, Anand  wrote:

> Add all the arrays to the heap comparision being only from the first
> element.
>
> "Can you elaborate this statement Could not understand."
>
>
> On Sat, Jun 5, 2010 at 8:20 PM, Rohit Saraf 
> wrote:
>
>> Did not understand what u said but it is extremely straight forward
>>
>> Add all the arrays to the heap comparision being only from the first
>> element. Now remove the root, take the first element of root array and
>> reinsert the rest of the array. Just keep doin this.
>>
>> To save space you might want to avoid adding the whole array and just
>> add some reqd pointers. But the algo remains the same.
>>
>> --
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>

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



Re: [algogeeks] One question on Heap sort

2010-06-05 Thread Anand
Add all the arrays to the heap comparision being only from the first
element.

"Can you elaborate this statement Could not understand."

On Sat, Jun 5, 2010 at 8:20 PM, Rohit Saraf wrote:

> Did not understand what u said but it is extremely straight forward
>
> Add all the arrays to the heap comparision being only from the first
> element. Now remove the root, take the first element of root array and
> reinsert the rest of the array. Just keep doin this.
>
> To save space you might want to avoid adding the whole array and just
> add some reqd pointers. But the algo remains the same.
>
> --
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



[algogeeks] Re: sorted 2-d array

2010-06-05 Thread Minotauraus
1. check arr[0][0]. If this is non negative, there are 0 negative
numbers. (assuming sorting is ascending)
2. for arr[i][j], increment j until you hit a non-negative number.
this index will be limitRow
3. increment i, until you hit a non-negative number, this index will
be limitColumn,
 for i wrote:
> Given an n X n array with rows sorted and cols sorted, find the number
> of negative elements in most efficient way

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



[algogeeks] Re: Find Max Number of Elephants

2010-06-05 Thread Minotauraus
I think you can do this in O(n) time. Feel free to correct me where
I'm wrong.

Create a 2D array with years on one side and elephant's time alive on
the other. example:
2000 2001 2002 2003 2004 2005 2006 2007 2008 2009  2010  2011 2012
E1 1  1   1 11 1   1  1  1
E2  1 11  1
1   1   1   11
E3  1  1
1   1

Now for every years add vertical indices example 2006 = 3, 2007 = 3,
2008 = 3 and so on. This will give you the
year with max elephant population. The array can be init with 0 or a
static array can be used.

@Anurag: How will you approach this problem by using LCA algorithm
that your link leads to?



On Jun 5, 6:16 am, amit  wrote:
> Maximum number of elephants alive
> Hello guyz,
>
> Every elephant has a birth_time and a death_time. Given N Elephants
> with birth times and death times.. How can we find
> 1) the maximum number of elephants that can be alive at any given
> point of time.
> 2) what is the year in which you can have maximum number of elephants
> alive.
> ex: E1 - 2000-2008 E2-2004-2012 E3-2006-2009
> So in 2006 you have 3 elephants alive (maximum)
> PS: ignore months and all stuff .. if a elephants live in a year
> consider it lives that complete year
>
> I have O(year_max-year_min) solution and O(n^2) solution , where
> n=number of elephants .
> Can we do better ??
>
> thanks

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



[algogeeks] Re: divisible by 3

2010-06-05 Thread Minotauraus
Subtract 3 from the number until either you get 0 or a negative
number. If you get 0, its divisible, else not.
You can probably do this by bit shifting too.

On Jun 5, 11:45 am, divya  wrote:
> Find if a number is divisible my 3, without using %,/ or *. You can
> use atoi().

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



[algogeeks] Re: Largest even length palindrome in a string!!

2010-06-05 Thread Minotauraus
Actually complexity is O(n), BUT it won't work for aa. It'll
return "aa" instead of the whole string.
I think you can use similar approach but add another check under the
first 'if' statement since 'aa'
is a special case. But then again the algo will crap out for a string=
bb. I think the best way would
be to start with from the middle and span outwards. this way you
should find the longest even palindrome of
even length.

On Jun 5, 6:52 am, Bharath  wrote:
> Complexity is O(n3) for both above solutions
>
> Ex: 
>
>
>
>
>
> On Sat, Jun 5, 2010 at 3:27 AM, Minotauraus  wrote:
> > for(int i=0; i > {
> >  if(word[i]==word[i+1]) //for an even palindrome, consecutive letters
> > at the middle of the string have to be the same
> >       {
> >           palindromeFound=true;
>
> >           while(n>0&&m > the palindrome, compare left of and right of, while making sure you
> > don't go out of                         bounds
> >            {
> >                 if(word[n--]==word[m++])
> >                      {
> >                         startIndex = n; //overwrite index of the
> > start and end locations
> >                         endIndex = m;
>
> >                      }
> >                     else break;
> >            }
> >       }
> > }
>
> > print("Even length-ed Palindrome: "+word[startIndex->endIndex], length
> > = endIndex-startIndex);
>
> > Complexity =O(n).
>
> > On Jun 5, 2:34 am, Satya  wrote:
> > > Hi,
>
> > > How to find largest palindrome, which is even in length in a string.
> > > Complexity should be "lessthan" O(n^2).
>
> > > Ex;- abacbbcababac - Given string.
> > > 'abacbbcaba' - is the largest even length palindrome.
>
> > > Thanks,
> > > Satya
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com > .com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> <>

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



Re: [algogeeks] Re: Largest even length palindrome in a string!!

2010-06-05 Thread Rohit Saraf
What makes you think it is O(n^3).
I did not read the code one but divya's solution seems to be O(n^2)
for worst case.

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] divisible by 3

2010-06-05 Thread Rohit Saraf
Still if u want the solution

convert to string and sum up all characters. if sum is greater than 9 repeat
else check if  it is 3 6 or 9


-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] One question on Heap sort

2010-06-05 Thread Rohit Saraf
Did not understand what u said but it is extremely straight forward

Add all the arrays to the heap comparision being only from the first
element. Now remove the root, take the first element of root array and
reinsert the rest of the array. Just keep doin this.

To save space you might want to avoid adding the whole array and just
add some reqd pointers. But the algo remains the same.

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] sorted 2-d array

2010-06-05 Thread Rohit Saraf
See the first row and first column and count the negative entries.
Also let k be the number of negatives in first row and l be in first
column.
now remove the first row and column and recurse on th the top left k x
l matrix that remains
assuming that top left is minimum and increases on going right or down.

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] divisible by 3

2010-06-05 Thread sharad kumar
this problem has been discussed i think..

On Sun, Jun 6, 2010 at 12:15 AM, divya  wrote:

> Find if a number is divisible my 3, without using %,/ or *. You can
> use atoi().
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
yezhu malai vaasa venkataramana Govinda Govinda

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



Re: [algogeeks] Product Array

2010-06-05 Thread sharad kumar
#include
using namespace std;
int main()
{
int arr[5]={1,2,3,4,5};
int res[5]={1,1,1,1,1};
int left=1,right=1,i=0;
for(i=0;i<5;++i)
{res[i]*=left;
  res[4-i]*=right;
  left*=arr[i];
  right*=arr[4-i];

  }for(i=0;i<5;++i)
  cout< wrote:

> Given an array arr[] of n integers, construct a Product Array prod[]
> (of same size) such that prod[i] is equal to the product of all the
> elements of arr[] except arr[i]. Solve it without division operator
> and in O(n).
>
> Can someone explain me the logic.
> Thanks!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
yezhu malai vaasa venkataramana Govinda Govinda

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



Re: [algogeeks] array question

2010-06-05 Thread sharad kumar
@dhivya:keep storing the first occurance element index in hash map and then
start insertin eleement based on index position

On Sun, Jun 6, 2010 at 12:31 AM, divya  wrote:

> Given an array with some repeating numbers. Like 12,6,5,12,6
>
> output: 12,12,6,6,5
> 12 shud come before 6 since it is earlier in list. So cant use a
> dictionary.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
yezhu malai vaasa venkataramana Govinda Govinda

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



[algogeeks] One question on Heap sort

2010-06-05 Thread Anand
Give a O(nlogk) time algorithm to merge k sorted list into one sorted list,
where n is the total number of elements in all the input list.

My approach:

1. take first element from all the k sorted list and build heap for those
elements.
2. call heapify on all k elements to sort it.
3. repeat the above two steps for all n elements.

Complexity:
1. building a heap of k element takes O(klogk).
2. heapifying on each k elements takes O(klogk).
3. repeat the above steps n  times = 0(nlogk).

Is my approach and understanding correct?

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



Re: [algogeeks] Find Max Number of Elephants

2010-06-05 Thread Amir hossein Shahriari
i think this can be done in O(nlogn)
create an array of the years that elephants are born and the years that they die
in this case it would be {2000,2008,2004,2012,2006,2009}
each object in your array should contain both the year and a flag to
know we should increment the number of elephants at this year or
decrement it
sort them by year in O(nlogn)
you can handle the number of elephantst in O(n)
so the overall would be O(nlogn)



On 6/5/10, amit  wrote:
> Maximum number of elephants alive
> Hello guyz,
>
> Every elephant has a birth_time and a death_time. Given N Elephants
> with birth times and death times.. How can we find
> 1) the maximum number of elephants that can be alive at any given
> point of time.
> 2) what is the year in which you can have maximum number of elephants
> alive.
> ex: E1 - 2000-2008 E2-2004-2012 E3-2006-2009
> So in 2006 you have 3 elephants alive (maximum)
> PS: ignore months and all stuff .. if a elephants live in a year
> consider it lives that complete year
>
> I have O(year_max-year_min) solution and O(n^2) solution , where
> n=number of elephants .
> Can we do better ??
>
> thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



[algogeeks] Product Array

2010-06-05 Thread Raj N
Given an array arr[] of n integers, construct a Product Array prod[]
(of same size) such that prod[i] is equal to the product of all the
elements of arr[] except arr[i]. Solve it without division operator
and in O(n).

Can someone explain me the logic.
Thanks!!

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



[algogeeks] sorted 2-d array

2010-06-05 Thread divya
Given an n X n array with rows sorted and cols sorted, find the number
of negative elements in most efficient way

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



Re: [algogeeks] Largest even length palindrome in a string!!

2010-06-05 Thread Antony Vincent Pandian.S.
Apologies.

I thought the question was about just checking for palindrome.

On 6/6/10, Antony Vincent Pandian.S.  wrote:
> Follow hare and tortoise algorithm.
>
> For even length,
> once the traversal through out the string is done, move the fast
> pointer to slow pointer +1 location and start iterating for (length/2)
> times with 2 indices. One indice increasing for fast pointer and the
> other for slow pointer. Keep checking the value at slow pointer index
> and fast pointer index. If they are different, it is not a palindrome.
> eg: for string of length 6 with index starting from 0, by hare and
> tortoise method, slow pointer is placed at 2 while fast pointer is
> placed at 4. Move the fast pointer to (index of slow pointer)+1. In
> this case, move it to 3. Start traversing the slow pointer in
> decreasing manner while increasing the fast pointer.
>
> For odd length,
> follow hare and tortoise method. Move the fast to the slow pointer
> index which is also the middle of the string, start incrementing one
> pointer while decreasing the other and comparing the values of each
> index.
>
> Complexity is O(2n)
>
> On 6/5/10, Bharath  wrote:
>> Complexity is O(n3) for both above solutions
>>
>> Ex: 
>>
>> On Sat, Jun 5, 2010 at 3:27 AM, Minotauraus  wrote:
>>
>>> for(int i=0; i>> {
>>>  if(word[i]==word[i+1]) //for an even palindrome, consecutive letters
>>> at the middle of the string have to be the same
>>>   {
>>>   palindromeFound=true;
>>>
>>>   while(n>0&&m>> the palindrome, compare left of and right of, while making sure you
>>> don't go out of bounds
>>>{
>>> if(word[n--]==word[m++])
>>>  {
>>> startIndex = n; //overwrite index of the
>>> start and end locations
>>> endIndex = m;
>>>
>>>  }
>>> else break;
>>>}
>>>   }
>>> }
>>>
>>> print("Even length-ed Palindrome: "+word[startIndex->endIndex], length
>>> = endIndex-startIndex);
>>>
>>> Complexity =O(n).
>>>
>>> On Jun 5, 2:34 am, Satya  wrote:
>>> > Hi,
>>> >
>>> > How to find largest palindrome, which is even in length in a string.
>>> > Complexity should be "lessthan" O(n^2).
>>> >
>>> > Ex;- abacbbcababac - Given string.
>>> > 'abacbbcaba' - is the largest even length palindrome.
>>> >
>>> > Thanks,
>>> > Satya
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> <>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
> --
> Sent from my mobile device
>
> Luv,
> S.Antony Vincent Pandian
>

-- 
Sent from my mobile device

Luv,
S.Antony Vincent Pandian

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



[algogeeks] array question

2010-06-05 Thread divya
Given an array with some repeating numbers. Like 12,6,5,12,6

output: 12,12,6,6,5
12 shud come before 6 since it is earlier in list. So cant use a
dictionary.

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



Re: [algogeeks] Largest even length palindrome in a string!!

2010-06-05 Thread Antony Vincent Pandian.S.
Follow hare and tortoise algorithm.

For even length,
once the traversal through out the string is done, move the fast
pointer to slow pointer +1 location and start iterating for (length/2)
times with 2 indices. One indice increasing for fast pointer and the
other for slow pointer. Keep checking the value at slow pointer index
and fast pointer index. If they are different, it is not a palindrome.
eg: for string of length 6 with index starting from 0, by hare and
tortoise method, slow pointer is placed at 2 while fast pointer is
placed at 4. Move the fast pointer to (index of slow pointer)+1. In
this case, move it to 3. Start traversing the slow pointer in
decreasing manner while increasing the fast pointer.

For odd length,
follow hare and tortoise method. Move the fast to the slow pointer
index which is also the middle of the string, start incrementing one
pointer while decreasing the other and comparing the values of each
index.

Complexity is O(2n)

On 6/5/10, Bharath  wrote:
> Complexity is O(n3) for both above solutions
>
> Ex: 
>
> On Sat, Jun 5, 2010 at 3:27 AM, Minotauraus  wrote:
>
>> for(int i=0; i> {
>>  if(word[i]==word[i+1]) //for an even palindrome, consecutive letters
>> at the middle of the string have to be the same
>>   {
>>   palindromeFound=true;
>>
>>   while(n>0&&m> the palindrome, compare left of and right of, while making sure you
>> don't go out of bounds
>>{
>> if(word[n--]==word[m++])
>>  {
>> startIndex = n; //overwrite index of the
>> start and end locations
>> endIndex = m;
>>
>>  }
>> else break;
>>}
>>   }
>> }
>>
>> print("Even length-ed Palindrome: "+word[startIndex->endIndex], length
>> = endIndex-startIndex);
>>
>> Complexity =O(n).
>>
>> On Jun 5, 2:34 am, Satya  wrote:
>> > Hi,
>> >
>> > How to find largest palindrome, which is even in length in a string.
>> > Complexity should be "lessthan" O(n^2).
>> >
>> > Ex;- abacbbcababac - Given string.
>> > 'abacbbcaba' - is the largest even length palindrome.
>> >
>> > Thanks,
>> > Satya
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> <>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
Sent from my mobile device

Luv,
S.Antony Vincent Pandian

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



[algogeeks] divisible by 3

2010-06-05 Thread divya
Find if a number is divisible my 3, without using %,/ or *. You can
use atoi().

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



Re: [algogeeks] Find Max Number of Elephants

2010-06-05 Thread Jitendra Kushwaha
@Amit :

Query 1 :  It can be solved in O(n) by checking which elephants life span
contain the given year

Query 2 : Picking up the fact that a elephant die only after its birth we
can find the second query in O(nlogn)
ALGO:
   1. sort in increasing order birth year and death year seperately
   2. increment the birth year till we get a value of year which is
equal to first death year, keep count of current elephant alive in a value
MAX_ELE.
   3. Now as one element died decrement one count and increment till
we get a year value in birth list which is greater or equal to second death
date, keep track of elephents alive and if it is greater than
previous,update MAX_ELE with current elephant count
  4. continue till birth list empty
sorting will require O(nlogn) and finding year in which max elephents  were
alive will take O(n).Total complexity O(nlogn)

Correct me anything wrong

 --
Regards
Jitendra Kushwaha
Undergradute Student
Computer Science & Eng.
MNNIT, Allahabad

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



Re: [algogeeks] Find Max Number of Elephants

2010-06-05 Thread Anurag Sharma
use interval trees.

Anurag Sharma
http://anuragsharma-sun.blogspot.com/


On Sat, Jun 5, 2010 at 6:16 PM, amit  wrote:

> Maximum number of elephants alive
> Hello guyz,
>
> Every elephant has a birth_time and a death_time. Given N Elephants
> with birth times and death times.. How can we find
> 1) the maximum number of elephants that can be alive at any given
> point of time.
> 2) what is the year in which you can have maximum number of elephants
> alive.
> ex: E1 - 2000-2008 E2-2004-2012 E3-2006-2009
> So in 2006 you have 3 elephants alive (maximum)
> PS: ignore months and all stuff .. if a elephants live in a year
> consider it lives that complete year
>
> I have O(year_max-year_min) solution and O(n^2) solution , where
> n=number of elephants .
> Can we do better ??
>
> thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] Re: partion of array

2010-06-05 Thread Anand
I know about Dynamic programming. But could not understand how the sub
optimal structure is applied in this problem. Can you elaborate little.

On Sat, Jun 5, 2010 at 12:38 AM, Rohit Saraf wrote:

> I mean what about the approach did you not understand.
> Do you know about DP?
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
>
>   --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Recursion help!

2010-06-05 Thread Anand
This a good example of dynamic programming.



On Fri, Jun 4, 2010 at 10:15 AM, satwik krishna  wrote:

> i think the best way to trace is to draw a picture of the stack and put the
> values and acc understand the flow
>
>
> On Fri, Jun 4, 2010 at 7:22 AM, Prashant Kulkarni <
> prashant.r.k...@gmail.com> wrote:
>
>>
>> int Max(int a[],int n)
>> {
>>int max;
>>if(n==1) ---( 1
>> )
>>return a[0];
>>else
>>max=Max(a,n-1);
>> ---( 2 )
>>
>>if(max>a[n-1])
>>return max;
>> ---( 3 )
>> }
>>else
>>return a[n-1];
>> ---( 4 )
>> }
>>
>> Statement (1) will executed when there is only single present in the
>> array
>>
>> Statement (2) otherwise else part will executed
>> in this section we calling same function with array index n,n-1,..,0
>> (position of the elements)
>>
>> Statement (3) checking whether this present element is larger than
>> previous one ie here we are comparing ( n )th and
>> (n-1) th element;  if  (n) th is greater then it will return its value
>>
>> Statement (4)
>> here if  (n-1) th is greater so  it will return its value
>>
>>
>> -- Prashant Kulkarni
>>
>>
>>
>>
>>
>> On Fri, Jun 4, 2010 at 7:13 PM, Raj N  wrote:
>>
>>> int Max(int a[],int n)
>>> {
>>>int max;
>>>if(n==1)
>>>return a[0];
>>>else
>>>max=Max(a,n-1);
>>>if(max>a[n-1])
>>>return max;
>>>else
>>>return a[n-1];
>>> }
>>>
>>> Hi, the above is a code to find the max in an array recursively. I
>>> find very difficult in understanding the flow of recursive programs.
>>> Can someone help me out in explaining the flow of the program with
>>> stack sections if possible.
>>> Thanks!!
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>   --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
>  You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Re: o/p

2010-06-05 Thread Rohit Saraf
oh... why did u put %u.
i did not even notice that :P

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



[algogeeks] Re: o/p

2010-06-05 Thread Devendra Pratap Singh

reason for that o/p is ...

coz range of short int is   -32768 to 32767

and value of i start with i=0

and each time it will increment by 1

so corresponding value of i will be

1
2
3
.
.
.
32766
32767
-32768
-32767
.
.
.
.
-2
-1

but

coz in printf u r using %u so it will print...

1
2
3
.
.
.
32766
32767
4294934528
4294934529
.
.
.
.
4294967293
4294967294
4294967295


 if u use %d then u get exact value of i in output also




On Jun 5, 5:28 pm, sharad kumar  wrote:
> @divya,which compiler u r using,i m getting this o/p on gcc compiler
>
> @mohit:loop stops at 4,294,967,295 in gcc

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



Re: [algogeeks] Re: Largest even length palindrome in a string!!

2010-06-05 Thread Bharath
Complexity is O(n3) for both above solutions

Ex: 

On Sat, Jun 5, 2010 at 3:27 AM, Minotauraus  wrote:

> for(int i=0; i {
>  if(word[i]==word[i+1]) //for an even palindrome, consecutive letters
> at the middle of the string have to be the same
>   {
>   palindromeFound=true;
>
>   while(n>0&&m the palindrome, compare left of and right of, while making sure you
> don't go out of bounds
>{
> if(word[n--]==word[m++])
>  {
> startIndex = n; //overwrite index of the
> start and end locations
> endIndex = m;
>
>  }
> else break;
>}
>   }
> }
>
> print("Even length-ed Palindrome: "+word[startIndex->endIndex], length
> = endIndex-startIndex);
>
> Complexity =O(n).
>
> On Jun 5, 2:34 am, Satya  wrote:
> > Hi,
> >
> > How to find largest palindrome, which is even in length in a string.
> > Complexity should be "lessthan" O(n^2).
> >
> > Ex;- abacbbcababac - Given string.
> > 'abacbbcaba' - is the largest even length palindrome.
> >
> > Thanks,
> > Satya
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
<>

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



[algogeeks] Find Max Number of Elephants

2010-06-05 Thread amit
Maximum number of elephants alive
Hello guyz,

Every elephant has a birth_time and a death_time. Given N Elephants
with birth times and death times.. How can we find
1) the maximum number of elephants that can be alive at any given
point of time.
2) what is the year in which you can have maximum number of elephants
alive.
ex: E1 - 2000-2008 E2-2004-2012 E3-2006-2009
So in 2006 you have 3 elephants alive (maximum)
PS: ignore months and all stuff .. if a elephants live in a year
consider it lives that complete year

I have O(year_max-year_min) solution and O(n^2) solution , where
n=number of elephants .
Can we do better ??

thanks

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



Re: [algogeeks] o/p

2010-06-05 Thread divya jain
turbo c++ and my o/p is logical as well

On 5 June 2010 17:58, sharad kumar  wrote:

> @divya,which compiler u r using,i m getting this o/p on gcc compiler
>
> @mohit:loop stops at 4,294,967,295 in gcc
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Print the string in reverse order (not revstr

2010-06-05 Thread Rohit Saraf
Ok. so you have a list.
Iterating over it is linear isn't it?
Ahh... you will need a doubly linked list or an arraylist.does it solve ur
prob?

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sat, Jun 5, 2010 at 5:17 PM, Antony Vincent Pandian.S.  wrote:

> @Rohit I accept that tokenization is linear. But how do you say
> iteration over tokens in the new list and printing in reverse order as
> linear?
>
> On 6/5/10, Rohit Saraf  wrote:
> > Tokenization is done in linear time. Just save the words in an list (And
> > what makes you think of non-linearity in tokenization!)
> > And then iteration over the tokens is trivially linear.
> > --
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombay
> > http://www.cse.iitb.ac.in/~rohitfeb14
> >
> >
> > On Sat, Jun 5, 2010 at 11:01 AM, Antony Vincent Pandian.S. <
> > sant...@gmail.com> wrote:
> >
> >> @Shobhit
> >> @Rohit
> >>
> >> Is it done it linear time?? I dont think so...
> >>
> >> On Sat, Jun 5, 2010 at 9:33 AM, Rohit Saraf
> >> wrote:
> >>
> >>> Tokenize the string and print it reverse!
> >>>
> >>> --
> >>> --
> >>> Rohit Saraf
> >>> Second Year Undergraduate,
> >>> Dept. of Computer Science and Engineering
> >>> IIT Bombay
> >>> http://www.cse.iitb.ac.in/~rohitfeb14<
> http://www.cse.iitb.ac.in/%7Erohitfeb14>
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to algoge...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> algogeeks+unsubscr...@googlegroups.com
> 
> >
> >>> .
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>>
> >>>
> >>
> >>
> >> --
> >> Luv,
> >> S.Antony Vincent Pandian
> >>
> >>  --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algoge...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com
> 
> >
> >> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> Sent from my mobile device
>
> Luv,
> S.Antony Vincent Pandian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] o/p

2010-06-05 Thread Rohit Saraf
If you make it unsigned short int.. then it goes to 65535 on g++/gcc
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] dynamic vs greedy aproach

2010-06-05 Thread Rohit Saraf
Greedy can be used to find one solution which has some special
characteristics.
It should be like - You are able to say that if for any instance of size k
the greedy and the optimal solution match, then for any corresponding
instance of size k+1, the greedy solution is atleast as good as optimal.

Dynamic programming is a more general approach which is generally used when
there is optimal substructure and has mostly found use in doing exponential
looking problems in polynomial time.

i hope u understood

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] o/p

2010-06-05 Thread sharad kumar
@divya,which compiler u r using,i m getting this o/p on gcc compiler

@mohit:loop stops at 4,294,967,295 in gcc

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



Re: [algogeeks] Print the string in reverse order (not revstr

2010-06-05 Thread Antony Vincent Pandian.S.
@Rohit I accept that tokenization is linear. But how do you say
iteration over tokens in the new list and printing in reverse order as
linear?

On 6/5/10, Rohit Saraf  wrote:
> Tokenization is done in linear time. Just save the words in an list (And
> what makes you think of non-linearity in tokenization!)
> And then iteration over the tokens is trivially linear.
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sat, Jun 5, 2010 at 11:01 AM, Antony Vincent Pandian.S. <
> sant...@gmail.com> wrote:
>
>> @Shobhit
>> @Rohit
>>
>> Is it done it linear time?? I dont think so...
>>
>> On Sat, Jun 5, 2010 at 9:33 AM, Rohit Saraf
>> wrote:
>>
>>> Tokenize the string and print it reverse!
>>>
>>> --
>>> --
>>> Rohit Saraf
>>> Second Year Undergraduate,
>>> Dept. of Computer Science and Engineering
>>> IIT Bombay
>>> http://www.cse.iitb.ac.in/~rohitfeb14
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Luv,
>> S.Antony Vincent Pandian
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
Sent from my mobile device

Luv,
S.Antony Vincent Pandian

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



[algogeeks] dynamic vs greedy aproach

2010-06-05 Thread divya jain
how can we make out whether to apply greedy approach or dynamic programming
to a problem??

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



Re: [algogeeks]

2010-06-05 Thread Minotauraus
Can be done in O(n log n) without using aux. memory. Can be done in
O(n) if you use something like a hash table.

On Jun 5, 12:40 am, Rohit Saraf  wrote:
> Inplace in O(n) seems unlikely to me.
> Well you should still try!
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14

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



[algogeeks] Re: Largest even length palindrome in a string!!

2010-06-05 Thread Minotauraus
for(int i=0; i0&&mendIndex], length
= endIndex-startIndex);

Complexity =O(n).

On Jun 5, 2:34 am, Satya  wrote:
> Hi,
>
> How to find largest palindrome, which is even in length in a string.
> Complexity should be "lessthan" O(n^2).
>
> Ex;- abacbbcababac - Given string.
> 'abacbbcaba' - is the largest even length palindrome.
>
> Thanks,
> Satya

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



Re: [algogeeks] Largest even length palindrome in a string!!

2010-06-05 Thread divya jain
1. first find two consecutive letters which are same.
2 point ptr1 to left character and ptr2 to right one
3. now increment ptr2 and decrement ptr1. compare if they are pointing to
same characters. if yes repeat this step
4. if no then store in length ptr2-ptr1-2
5. go to step 1 untill all consecutive same letters have been scanned. if
the new length found is greater then previous one. then discard previous one
and store in length new length.
6. return the substring with largest length


On 5 June 2010 15:04, Satya  wrote:

> Hi,
>
> How to find largest palindrome, which is even in length in a string.
> Complexity should be "lessthan" O(n^2).
>
> Ex;- abacbbcababac - Given string.
> 'abacbbcaba' - is the largest even length palindrome.
>
> Thanks,
> Satya
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] o/p

2010-06-05 Thread mohit ranjan
@Sharad
i am getting ths o/p on gcc

1
2
3
4
...
...

which compiler you are using ?

Mohit Ranjan


On Sat, Jun 5, 2010 at 1:44 PM, sharad  wrote:

> #include
> int main()
> {
> short int i=0;
> for(i<=5&&i>=-1;++i;i>0)
> printf("%u\n",i);
> return 0;
> }
>
> o/p coming is 1...4,294,967,295
> short int is of 2 bytes
> can any one plzz explain the o/p
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] o/p

2010-06-05 Thread divya jain
output on my compiler is 165535
as i=0 initialy ++i is true and so for loop condition is true and printf is
executed. when i becomes 65535 then ++i is equal to 0 and so for loop
condition becomes false.

On 5 June 2010 13:44, sharad  wrote:

> #include
> int main()
> {
> short int i=0;
> for(i<=5&&i>=-1;++i;i>0)
> printf("%u\n",i);
> return 0;
> }
>
> o/p coming is 1...4,294,967,295
> short int is of 2 bytes
> can any one plzz explain the o/p
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] Quick short stack space reduction

2010-06-05 Thread Rohit Saraf
Actually he means the case when you implement quicksort using stacks.

-- 
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



[algogeeks] Largest even length palindrome in a string!!

2010-06-05 Thread Satya
Hi,

How to find largest palindrome, which is even in length in a string.
Complexity should be "lessthan" O(n^2).

Ex;- abacbbcababac - Given string.
'abacbbcaba' - is the largest even length palindrome.

Thanks,
Satya

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



Re: [algogeeks] Quick short stack space reduction

2010-06-05 Thread Senthilnathan Maadasamy
Hi all,
   Please correct me if I am wrong.  Since quick sort is in-place
sort, there is no difference in stack space whichever order you do it.  In
the worst case the stack depth can be O(n) unless you convert the quick sort
of longer sub-array to iteration instead of recursion in which case the
recursion depth is always O(logn).

On Sat, Jun 5, 2010 at 7:13 AM, sharad kumar wrote:

> @divya,in second case longer one will be in stack for shorter time(not
> longer)bcoz it will take less time to sort small sequence so stack space for
> shorter one will be freed earlier,otherwise that space has to wait for the
> longer time
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



[algogeeks] o/p

2010-06-05 Thread sharad
#include
int main()
{
short int i=0;
for(i<=5&&i>=-1;++i;i>0)
printf("%u\n",i);
return 0;
}

o/p coming is 1...4,294,967,295
short int is of 2 bytes
can any one plzz explain the o/p

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



Re: [algogeeks] Print the string in reverse order (not revstr

2010-06-05 Thread Rohit Saraf
Tokenization is done in linear time. Just save the words in an list (And
what makes you think of non-linearity in tokenization!)
And then iteration over the tokens is trivially linear.
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sat, Jun 5, 2010 at 11:01 AM, Antony Vincent Pandian.S. <
sant...@gmail.com> wrote:

> @Shobhit
> @Rohit
>
> Is it done it linear time?? I dont think so...
>
> On Sat, Jun 5, 2010 at 9:33 AM, Rohit Saraf 
> wrote:
>
>> Tokenize the string and print it reverse!
>>
>> --
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Luv,
> S.Antony Vincent Pandian
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks]

2010-06-05 Thread Rohit Saraf
Inplace in O(n) seems unlikely to me.
Well you should still try!
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] Re: partion of array

2010-06-05 Thread Rohit Saraf
I mean what about the approach did you not understand.
Do you know about DP?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] Longest Increasing Subsequence in O(nlogn)

2010-06-05 Thread Anand
http://codepad.org/NDAeIpxR

Here is code for it
On Sat, May 29, 2010 at 7:45 PM, Anurag Sharma wrote:

> @pawan
> Will it not take O(n^2) time then.
> What he is talking about is solving it in O(nlogn) time
>
> Anurag Sharma
> http://anuragsharma-sun.blogspot.com/
>
>
>
> On Sat, May 29, 2010 at 7:04 PM, pawan sharma 
> wrote:
>
>> @amit
>> for longest increasing  subsequence , just sort the given array and find
>> longest  subsequence of sorted array  and unsorted array . It will give you
>> longest increasing  subsequence (because of sorted array) .
>>
>>
>> On Sat, May 29, 2010 at 12:41 PM, Nikhil Agarwal <
>> nikhil.bhoja...@gmail.com> wrote:
>>
>>> Check:
>>>
>>> http://www.algorithmist.com/index.php/Longest_Increasing_Subsequence
>>>
>>>
>>>
>>>
>>>
>>> On Sat, May 29, 2010 at 4:15 AM, Amir hossein Shahriari <
>>> amir.hossein.shahri...@gmail.com> wrote:
>>>
 A hint from "Introduction to algorithms" on this problem:
 Observe that the last element of a candidate subsequence of length *i*  is
 at least as large as the last element of a candidate subsequence of length
 *i-1. *Maintain candidate subsequences by linking them through the
 input sequence

 The attached file is a tutorial from train.usaco.org which includes 3
 approaches to the problem and explains them with some examples.
 I hope it would help!


 On Fri, May 28, 2010 at 7:44 PM, amit  wrote:

> Hi , Can anyone plz explain this algorithm taking some example.
> I read this on wiki but could'nt get how binary search was working.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
   --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>>
>>> --
>>> Thanks & Regards
>>> Nikhil Agarwal
>>> Senior Undergraduate
>>> Computer Science & Engineering,
>>> National Institute Of Technology, Durgapur,India
>>> http://tech-nikk.blogspot.com
>>> http://beta.freshersworld.com/communities/nitd
>>>
>>>
>>> --
>>>  You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>> --
>>  You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
>  You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Number of sequences of n binary digits that don't contain two 1's in a row

2010-06-05 Thread Raj N
@sharad: What about 101 even it doesn't have two 1's in a row

On Sat, Jun 5, 2010 at 8:59 AM, sharad kumar wrote:

> @rajn.can it be subsequence doesnt have one's too.hence 000,001,010,100 is
> required answer.
>
>
> On Sat, Jun 5, 2010 at 12:13 AM, Raj N  wrote:
>
>> Hi,
>> I came across this question to find the number of sequences of n
>> binary digits that don't contain 2 1's in a row. I wanted to know what
>> exactly this means. Is it like if n=3 then compute all binary numbers
>> having 3 digits which don't have consecutive 1's 110, 011, 111 ??
>> If not help me understanding it.
>> Thanks!!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> yezhu malai vaasa venkataramana Govinda Govinda
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Re: partion of array

2010-06-05 Thread Anand
DP approach for solving this problem.

Anand

On Fri, Jun 4, 2010 at 9:06 PM, Rohit Saraf wrote:

> What precisely did you not understand??
>
> --
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] Print the string in reverse order (not revstr)

2010-06-05 Thread Antony Vincent Pandian.S.
Rohit, you are very well awake

On Sat, Jun 5, 2010 at 9:49 AM, Rohit Saraf wrote:

> Have you posted the same question twice or i am feeling sleepy?
>
> --
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Luv,
S.Antony Vincent Pandian

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



Re: [algogeeks] Print the string in reverse order (not revstr

2010-06-05 Thread Antony Vincent Pandian.S.
@Shobhit
@Rohit

Is it done it linear time?? I dont think so...

On Sat, Jun 5, 2010 at 9:33 AM, Rohit Saraf wrote:

> Tokenize the string and print it reverse!
>
> --
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Luv,
S.Antony Vincent Pandian

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



Re: [algogeeks] Print the string in reverse order (not revstr)

2010-06-05 Thread Lalit Rajora
Its simple...
Reverse the whole string than reverse each word. an dthe work is done
complexity O(n)
This is a standard question of interview


On Sat, Jun 5, 2010 at 9:49 AM, Rohit Saraf wrote:

> Have you posted the same question twice or i am feeling sleepy?
>
> --
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks]

2010-06-05 Thread harit agarwal
if the array contains only numbers 1 to n then it can be done in O(n)
inplace otherwise only way is hashing or sorting.which is trivial
solution...

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



Re: [algogeeks]

2010-06-05 Thread sharad kumar
@sharad,ya inplace soln is desired...

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