Re: [algogeeks] Re: Reverse Queue

2012-06-20 Thread Sreeprasad Govindankutty
Just a query :

If the queue is implemented as an array, then is it not possible to swap
the elements from the last and first position onwards until you reach
middle point.  Wont this use O(1) space and O(n/2) time.



On Wed, Jun 20, 2012 at 1:56 PM, Hassan Monfared wrote:

> void Reverse(std::queue &pQ)
> {
> if(pQ.empty())
> return;
>  int item=pQ.front();
> pQ.pop();
> Reverse(pQ);
>  pQ.push(item);
> }
> Regards
>
> On Wed, Jun 20, 2012 at 9:41 PM, enchantress wrote:
>
>> Queues are basically linked lists with head and tail pointers. It is
>> possible to reverse the list by change of pointers in O(n) time n O(1)
>> space.
>> PS: Not considering queue ADT with enqueue dequeue operations.
>>
>>
>> On Wednesday, 20 June 2012 18:34:46 UTC+5:30, Navin Kumar wrote:
>>>
>>> How to reverse a Queue .
>>>
>>> Constraints: Time complexity O(n). space complexity: O(1)
>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/syRXPuMjBpkJ.
>>
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Amazon Question

2011-04-16 Thread Sreeprasad Govindankutty
Yes this is the solution when the binary tree is complete binary tree

Thanks and many regards,
Sreeprasad Govindankutty



On Sat, Apr 16, 2011 at 3:57 PM, Pratik Kathalkar  wrote:

> I think this solution is applicable if the binary tree is complete binary
> tree, isn't it?
>
> On Thu, Apr 14, 2011 at 12:52 AM, Harshit Gangal  > wrote:
>
>> it 2*node and 2*node+1, if binary tree is stored in an array
>>
>>
>> On Thu, Apr 14, 2011 at 12:36 AM, Vishakha Parvatikar <
>> vishakha.parvati...@gmail.com> wrote:
>>
>>> Given a binary tree, write a program to find the cousin nodes of the
>>> given node.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Harshit Gangal
>> Fourth Year Undergraduate Student
>> Dept. of Computer Science
>> JIIT, Noida , India
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Pratik Kathalkar
> CoEP
> BTech IT
> 8149198343
>
>   --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] one more from amazon

2011-02-06 Thread Sreeprasad Govindankutty
If duplicate values are allowed  ::

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class PartionNumber {

public static void main(String[] args) {
System.out.println("Enter the number");
InputStreamReader ifn = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(ifn);
try{
String n =buf.readLine();
int number = Integer.parseInt(n);
int i=-1;
functionPartion(number,i);
System.out.println("0 "+number);
}catch(Exception e){
 e.printStackTrace();
}

}

private static void  functionPartion(int number,int a) {
  a=a+1;
 if(number!=0){
 System.out.println(number+ " " +a);
 functionPartion(number-1, a);

 }
}

}




Thanks and many regards,
Sreeprasad



On Sun, Feb 6, 2011 at 7:29 PM, Wei.QI  wrote:

>  public static ArrayList> Partition(int val, int start,
> int size) {
>
>   ArrayList> r = new ArrayList>();
>
>   if (start * size > val) {
>return null;
>   }
>
>   if(size == 1)
>   {
>r.add(new ArrayList());
>r.get(0).add(val);
>return r;
>   }
>
>   for (int i = start; i <= val/size; i++) {
>ArrayList> tr = Partition(val - i, i, size - 1);
>if (tr != null) {
> for (int j = 0; j < tr.size(); j++) {
>  ArrayList subr = tr.get(j);
>  subr.add(i);
> }
> r.addAll(tr);
>}
>   }
>   return r;
>
>  }
>
> On Sun, Feb 6, 2011 at 7:51 AM, Gajendra Dadheech wrote:
>
>> Write a function to print all unique partitions on n tht are of size m.
>> eg: n=10, m=4. it should print 7 1 1 1, 6 2 1 1, 5 3 1 1, 3 3 2 2,, so on
>>
>>
>>
>> Thanks and regards,
>> Gajendra Dadheech
>> hi
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-02 Thread Sreeprasad Govindankutty
 in java :  BigDecimal_MAX  ?

On Wed, Feb 2, 2011 at 10:58 PM, Bhavesh agrawal wrote:

> sry i does not help me
>
>
> On Wed, Feb 2, 2011 at 10:59 PM, nishaanth  wrote:
>
>> how about put INT_MAX ..if we add 1 there will be a overflow right ?
>>
>>
>> On Wed, Feb 2, 2011 at 10:50 PM, Logic King 
>> wrote:
>>
>>> I have submitted the code of the same problem on spoj in C
>>>  as
>>>
>>> #include
>>> int main()
>>> {
>>> printf("&infin\n");
>>> return 0;
>>> }
>>>
>>>
>>> this code represents the infinity i suppose then why i am getting WA !!
>>>
>>> On Wed, Feb 2, 2011 at 10:30 PM, juver++  wrote:
>>>
>>>> Output infinity sign :)
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from 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.
>>>
>>
>>
>>
>> --
>> S.Nishaanth,
>> Computer Science and engineering,
>> IIT Madras.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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.
>



-- 
Thanks and many regards,
Sreeprasad Govindankutty

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



Re: [algogeeks] OS galvin sol..

2011-01-21 Thread Sreeprasad Govindankutty
Thanks so much

On Wed, Jan 19, 2011 at 4:20 AM, jayapriya surendran wrote:

> wow..thank you so much
>
>
> On Wed, Jan 19, 2011 at 2:08 PM, LALIT SHARMA  wrote:
>
>>
>>
>> --
>> Lalit Kishore Sharma,
>>
>> IIIT Allahabad (Amethi Capmus),
>> 6th Sem.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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.
>



-- 
Thanks and many regards,
Sreeprasad Govindankutty

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