Re: [algogeeks] Next higher element

2010-06-24 Thread chitta koushik
It works for the input given by you. Check the below code:

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class NextHigherElement {

public static void main(String args[]){
 List  input = new ArrayList();
Stack s = new Stack();
 input.add(4);
input.add(1);
input.add(3);
input.add(5);
input.add(6);
input.add(3);
input.add(2);
 s.push(input.get(0));
 for(int i=1;i s.peek()) )
{
System.out.println(s.pop()+"**"+input.get(i));
}
s.push(input.get(i));
}
 while(!s.isEmpty()){
System.out.println(s.pop()+"**"+"nothing");
}
 }
}



--Koushik C


On Thu, Jun 24, 2010 at 10:46 PM, Raj N  wrote:

> @Chitta: Hey this doesn't work in all cases. For eg: 4 1 3 5 6
> Output:
> 4-5
> 1-3
> 3-5
> 5-6
> 6-null
>
> But according to ur logic u push 4 then, u push 1 as it is < 4, do u
> conclude that 4 doesn't have next higher element ?
>
>
> On Thu, Jun 24, 2010 at 4:04 PM, chitta koushik <
> koushik.infin...@gmail.com> wrote:
>
>> push the elements into stack , when the element to be pushed is greater
>> than the 'top' element.. pop the elements and write then
>>
>> eg : if array is 1 2 3 4 5 8 6
>>
>> insert 1
>> -
>> stack : 1
>>
>> insert 2 ( as 2 > top i.e 1)
>> -
>>  output  1 - 2
>> stack : 2
>>
>> insert 3 ( as 3 > top i.e 2)
>> -
>> output  1-2, 2-3
>> stack 3
>>
>> .
>> .
>> .
>> insert 8 ( as 8 > top i.e 5)
>> --
>> output  1-2, 2-3,3-4,4-5
>> stack 8
>>
>> insert 6
>> ---
>> output 1-2, 2-3,3-4,4-5,5-8
>> stack 8,6
>>
>>
>> final output : 1-2, 2-3,3-4,4-5,5-8,8- -1 , 6 - -1
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wed, Jun 23, 2010 at 10:48 PM, Raj N  wrote:
>>
>>> @Kumar: The next higher of 5 will be 7 as it comes first in the array.
>>>
>>>
>>> On Wed, Jun 23, 2010 at 5:28 PM, Kumar Vishal wrote:
>>>
>>>> hi the number should be just next higher element or any higher element
>>>>
>>>> like
>>>> if my arr is like
>>>>
>>>> arr= 2 5 1 3 7 6
>>>>  the next higher element for 5
>>>>  should be what (7 or 6 )  because 6 is more closer to 7 but 7 comes
>>>> first in arr
>>>>
>>>>
>>>> On Wed, Jun 23, 2010 at 11:18 AM, Raj N  wrote:
>>>>
>>>>> Design a data structure to find the next higher element for each
>>>>> element in an array.
>>>>> For e.g. if array is 1 2 3 4 5 8 6
>>>>> o/p should be
>>>>> (element) (next higher element)
>>>>> 1 2
>>>>> 2 3
>>>>> 3 4
>>>>> 4 5
>>>>> 5 8
>>>>> 8 nothing
>>>>> 6 nothing
>>>>>
>>>>> The array need not be sorted.
>>>>> Constraints-O(n) time complexity
>>>>>
>>>>> --
>>>>> 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.
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Kumar Vishal
>>>> 
>>>> StAy HunGrY , StAy fOOlisH
>>>> 
>>>> Contact No:- 09560193839
>>>>
>>>> --
>>>> 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.
>

-- 
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] Next higher element

2010-06-24 Thread chitta koushik
push the elements into stack , when the element to be pushed is greater than
the 'top' element.. pop the elements and write then

eg : if array is 1 2 3 4 5 8 6

insert 1
-
stack : 1

insert 2 ( as 2 > top i.e 1)
-
 output  1 - 2
stack : 2

insert 3 ( as 3 > top i.e 2)
-
output  1-2, 2-3
stack 3

.
.
.
insert 8 ( as 8 > top i.e 5)
--
output  1-2, 2-3,3-4,4-5
stack 8

insert 6
---
output 1-2, 2-3,3-4,4-5,5-8
stack 8,6


final output : 1-2, 2-3,3-4,4-5,5-8,8- -1 , 6 - -1








On Wed, Jun 23, 2010 at 10:48 PM, Raj N  wrote:

> @Kumar: The next higher of 5 will be 7 as it comes first in the array.
>
>
> On Wed, Jun 23, 2010 at 5:28 PM, Kumar Vishal  wrote:
>
>> hi the number should be just next higher element or any higher element
>>
>> like
>> if my arr is like
>>
>> arr= 2 5 1 3 7 6
>>  the next higher element for 5
>>  should be what (7 or 6 )  because 6 is more closer to 7 but 7 comes first
>> in arr
>>
>>
>> On Wed, Jun 23, 2010 at 11:18 AM, Raj N  wrote:
>>
>>> Design a data structure to find the next higher element for each
>>> element in an array.
>>> For e.g. if array is 1 2 3 4 5 8 6
>>> o/p should be
>>> (element) (next higher element)
>>> 1 2
>>> 2 3
>>> 3 4
>>> 4 5
>>> 5 8
>>> 8 nothing
>>> 6 nothing
>>>
>>> The array need not be sorted.
>>> Constraints-O(n) time complexity
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> Kumar Vishal
>> 
>> StAy HunGrY , StAy fOOlisH
>> 
>> Contact No:- 09560193839
>>
>> --
>> 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: no of bits

2010-06-22 Thread chitta koushik
For more such problems and solns

http://graphics.stanford.edu/~seander/bithacks.html


for (c = 0; v; c++)
{
  v &= v - 1; // clear the least significant bit set
}

O(k)   -- no. of bits set in the number



--Koushik C


On Tue, Jun 22, 2010 at 7:16 PM, Dave  wrote:

> Assuming 32 bit integers:
> n = ((x >> 1) & 0x) + (x & 0x)
> n = ((n >> 2) & 0x) + (n % 0x)
> n = ((n >> 4) & 0x0F0F0F0F) + (n & 0x0F0F0F0F)
> n = ((n >> 8) & 0x00FF00FF) + (n & 0x00FF00FF)
> n = ((n >>16) & 0x) + (n & 0x)
>
> n now is the number of bits set in x. Time is O(1).
>
> Dave
>
> On Jun 22, 6:26 am, divya  wrote:
> > find the no. of bits set in a no. in logn 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.



Re: [algogeeks] Re: Implement a queue using a stack

2010-03-23 Thread chitta koushik
yeah i understand that . still wanted to attempt writing a recursive
reverse() stack operation.

On Wed, Mar 24, 2010 at 9:21 AM, Rohit Saraf wrote:

> Even when you are writing a recursive function.. you are not using one
> stack.
> One stack is yours. Other used for recursion.
>
> Making queue from a single stack <=>  Making turing machine from CFG.
>
> -Rohit
>
>
> On Wed, Mar 24, 2010 at 9:18 AM, chitta koushik <
> koushik.infin...@gmail.com> wrote:
>
>> Can we implement it using a single stack by writing  a recursive reverse
>> stack operation ?
>>
>>
>>
>> On Tue, Mar 23, 2010 at 10:18 AM, Sundeep Singh 
>> wrote:
>>
>>> Thanks Dave, I didn't think about this... definitely better!
>>>
>>> Sundeep.
>>>
>>>
>>> On Mon, Mar 22, 2010 at 9:08 PM, Dave  wrote:
>>>
>>>> Better still.
>>>> To enqueue: push onto stack A.
>>>> For dequeuing: If stack B is empty, pop all items from stack A and
>>>> push onto stack B. Then pop stack B.
>>>> There is no need to push remaining items back to stack A.
>>>>
>>>> As every item passes through the queue, it is pushed onto stack A,
>>>> then popped from stack A and pushed onto stack B, and finally popped
>>>> from stack B. The time is roughly twice the time required for a direct
>>>> implementation of a queue.
>>>>
>>>> There is room for a little optimization if both stacks are empty when
>>>> enquing, as you can push the item directly onto stack B. Furthermore,
>>>> when popping from stack A and pushing onto stack B, you don't need to
>>>> push the last item popped, as it is the return value.
>>>>
>>>> Dave
>>>>
>>>> On Mar 22, 9:29 am, Sundeep Singh  wrote:
>>>> > Hey Brian,
>>>> >
>>>> > Better still, for inserting in queue, just keep pushing onto the stack
>>>> A.
>>>> > You need stack B only for dequeuing: for dequeuing, push all items
>>>> into
>>>> > stack B, pop as many as you want from stack B and then push back all
>>>> > remaining items in stack A.
>>>> >
>>>> > Regards,
>>>> > Sundeep.
>>>> >
>>>> >
>>>> >
>>>> > On Mon, Mar 22, 2010 at 6:56 PM, Brian  wrote:
>>>> > >  > How is it possible to implement a queue using a stack only?
>>>> >
>>>> > > Interesting, but tricky... You need two stacks as Prakhar stated...
>>>> > > In general, if you have Stack A and Stack B, you should keep all the
>>>> items
>>>> > > in stack A and then use stack B for processing.
>>>> >
>>>> > > For example to insert an item:
>>>> > > 1. Pop all the items from A  and then push them into B (this should
>>>> push
>>>> > > the items into Stack B in reverse order)
>>>> > > 2. Insert the new item into A
>>>> > > 3. Pop all the items in B and push them back into A (again this will
>>>> push
>>>> > > them back into Stack B in reverse order)
>>>> >
>>>> > > Running time should be O(1)+O(2n), which is O(n) for larger values
>>>> of n -
>>>> > > which is not good...
>>>> >
>>>> > > To retrieve an item, pop the first item in stack A
>>>> >
>>>> > > Hope  this helps -
>>>> > > Regards
>>>> > > B
>>>> >
>>>> > > On 3/22/2010 4:55 AM, Prakhar Jain wrote:
>>>> >
>>>> > > By a do u mean a single stack ?
>>>> > > Otherwise if you use 2 its v simple
>>>> >
>>>> > > Best,
>>>> > > Prakhar Jain
>>>> > >http://web.iiit.ac.in/~prakharjain/<http://web.iiit.ac.in/%7Eprakharjain/>
>>>> <http://web.iiit.ac.in/%7Eprakharjain/>
>>>> >
>>>> > > On Mon, Mar 22, 2010 at 12:56 AM, Pushpesh Gupta <
>>>> pushpes...@gmail.com>wrote:
>>>> >
>>>> > >> How is it possible to implement a queue using a stack only?
>>>> >
>>>> > >> --
>>>> > >> You received this message because you are subscribed to the Google
>>>> Groups
>>>> > >> "Algorithm Geeks" g

Re: [algogeeks] Re: Implement a queue using a stack

2010-03-23 Thread chitta koushik
Can we implement it using a single stack by writing  a recursive reverse
stack operation ?


On Tue, Mar 23, 2010 at 10:18 AM, Sundeep Singh wrote:

> Thanks Dave, I didn't think about this... definitely better!
>
> Sundeep.
>
>
> On Mon, Mar 22, 2010 at 9:08 PM, Dave  wrote:
>
>> Better still.
>> To enqueue: push onto stack A.
>> For dequeuing: If stack B is empty, pop all items from stack A and
>> push onto stack B. Then pop stack B.
>> There is no need to push remaining items back to stack A.
>>
>> As every item passes through the queue, it is pushed onto stack A,
>> then popped from stack A and pushed onto stack B, and finally popped
>> from stack B. The time is roughly twice the time required for a direct
>> implementation of a queue.
>>
>> There is room for a little optimization if both stacks are empty when
>> enquing, as you can push the item directly onto stack B. Furthermore,
>> when popping from stack A and pushing onto stack B, you don't need to
>> push the last item popped, as it is the return value.
>>
>> Dave
>>
>> On Mar 22, 9:29 am, Sundeep Singh  wrote:
>> > Hey Brian,
>> >
>> > Better still, for inserting in queue, just keep pushing onto the stack
>> A.
>> > You need stack B only for dequeuing: for dequeuing, push all items into
>> > stack B, pop as many as you want from stack B and then push back all
>> > remaining items in stack A.
>> >
>> > Regards,
>> > Sundeep.
>> >
>> >
>> >
>> > On Mon, Mar 22, 2010 at 6:56 PM, Brian  wrote:
>> > >  > How is it possible to implement a queue using a stack only?
>> >
>> > > Interesting, but tricky... You need two stacks as Prakhar stated...
>> > > In general, if you have Stack A and Stack B, you should keep all the
>> items
>> > > in stack A and then use stack B for processing.
>> >
>> > > For example to insert an item:
>> > > 1. Pop all the items from A  and then push them into B (this should
>> push
>> > > the items into Stack B in reverse order)
>> > > 2. Insert the new item into A
>> > > 3. Pop all the items in B and push them back into A (again this will
>> push
>> > > them back into Stack B in reverse order)
>> >
>> > > Running time should be O(1)+O(2n), which is O(n) for larger values of
>> n -
>> > > which is not good...
>> >
>> > > To retrieve an item, pop the first item in stack A
>> >
>> > > Hope  this helps -
>> > > Regards
>> > > B
>> >
>> > > On 3/22/2010 4:55 AM, Prakhar Jain wrote:
>> >
>> > > By a do u mean a single stack ?
>> > > Otherwise if you use 2 its v simple
>> >
>> > > Best,
>> > > Prakhar Jain
>> > >http://web.iiit.ac.in/~prakharjain/
>> 
>> >
>> > > On Mon, Mar 22, 2010 at 12:56 AM, Pushpesh Gupta <
>> pushpes...@gmail.com>wrote:
>> >
>> > >> How is it possible to implement a queue using a stack only?
>> >
>> > >> --
>> > >> 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.- 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 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...@go

Re: [algogeeks] basic problem

2010-03-23 Thread chitta koushik
malloc returns a void pointer to the allocated chunk of memory.

On Wed, Mar 24, 2010 at 2:42 AM, aman goyal  wrote:

> why do we use malloc funtcn to allocate memory for a stuct node variable
> pointer..
> why dont we simply write struct node p;
> instead we do
> struct node *p
> p=malloc();
>
> any valid reasons for this??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.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] Dijkstra For Longest Path?

2010-01-14 Thread chitta koushik
How abt negating values and using same single source shortest path algo ?

2010/1/15 saltycookie 

> longest path is NP-hard
>
> 2010/1/11 Johan 
>
>> Ok, so I know that Dijkstra can be used to solve the single-source
>> shortest path problem quite efficiently. I however need to find the
>> single source longest path through a graph. Can Dijkstra be used for
>> this if I transform the edge lengths so that the longest edge is now
>> the shortest etc etc. Does anybody have any references to work done
>> which is similar to the this longest path 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.
>>
>>
>>
>>
>
>
> --
>  此致
> 敬礼!
>
> 林夏祥
>
> --
> 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] Kth element in BST without static/global variable or function argument

2009-12-09 Thread chitta koushik
even if u maintain the size , u never know whats the size of child
left-subtree and right subtree to evaluate.

can you explain the first appraoch ?


On Wed, Dec 9, 2009 at 9:24 PM, Rohit Saraf wrote:

> u can maintain the size..
> and if you don't want that , at least memoize it.. it won't be O(n^2) then.
>
> Rohit Saraf
> Sophomore
> Computer Science and Engineering
> IIT Bombay
>
>
>
> On Wed, Dec 9, 2009 at 9:12 PM, chitta koushik  > wrote:
>
>> Though i couldn't get both ur approaches clearly , guess 2nd approach shud
>> take O(n^2)  since you go to each node and find the size of left subtree .
>>
>> Or i shud be missing something. my bad can you explain your approaches
>> clearly.
>>
>> On Wed, Dec 9, 2009 at 8:20 PM, Rohit Saraf 
>> wrote:
>>
>>> do it iteratively either by:
>>>
>>> 1) If size of left tree is less than k, rotate the tree left. and so on
>>> till .single while loop required for this.
>>> or
>>> 2) Start from head, if k is more than size of left-tree, go to left and
>>> continue searching.. other wise go right and search for k-size(left)-1 in
>>> right tree. All this can be implemented in a single while loop.
>>>
>>>  --
>>> 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] Kth element in BST without static/global variable or function argument

2009-12-09 Thread chitta koushik
Though i couldn't get both ur approaches clearly , guess 2nd approach shud
take O(n^2)  since you go to each node and find the size of left subtree .

Or i shud be missing something. my bad can you explain your approaches
clearly.

On Wed, Dec 9, 2009 at 8:20 PM, Rohit Saraf wrote:

> do it iteratively either by:
>
> 1) If size of left tree is less than k, rotate the tree left. and so on
> till .single while loop required for this.
> or
> 2) Start from head, if k is more than size of left-tree, go to left and
> continue searching.. other wise go right and search for k-size(left)-1 in
> right tree. All this can be implemented in a single while loop.
>
>  --
> 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] Search in a sorted NxN matrix

2009-11-25 Thread chitta koushik
@Bharath

I dont think BinSrch on diagnol and then on row works.
Can u explain your algo?  chk for this matrix

1  2  3  4  5
2  9 12 19 24
3  10 14 18 20
8  13 15 20 23
11 14 16 21 24

Find(8) doesn't give o/p


--Koushik C
On Wed, Nov 25, 2009 at 5:18 PM, Arun  wrote:

> how about splitting the matrix into 4 squares and considering the rightmost
> bottom and comparing it to topmost left corner of each square. in every
> iteration you will eliminate atleast one square. so worst case, you have to
> repeat this divide and conquer on the three other squares.
> not good as as binary search though(in the sense of eliminating 2 squares).
>
>
> On Wed, Nov 25, 2009 at 3:12 AM, Aditya Shankar <
> iitm.adityashan...@gmail.com> wrote:
>
>>
>>
>> On Wed, Nov 25, 2009 at 2:16 PM, Bharath  wrote:
>>
>>> You can actually do it in O(logn) complexity. Binary Search on diagonal
>>> and then on a row.
>>
>> Will that always work?
>> 1 2 3
>> 3 5 6
>> 4 7 8
>>
>> Find(6) fails with the usual binary search algorithm.
>>
>>
>>>
>>>
>>> On Tue, Nov 24, 2009 at 10:33 PM, chitta koushik <
>>> koushik.infin...@gmail.com> wrote:
>>>
>>>> Start from top right or bottom left corner and move according if the
>>>> element to be searched is lesser or greater than current.
>>>>
>>>>
>>>> --Koushik C
>>>> Pablo 
>>>> Picasso<http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html> - 
>>>> "Computers are useless. They can only give you answers."
>>>>
>>>>
>>>> On Tue, Nov 24, 2009 at 7:27 PM, Rohit Saraf <
>>>> rohit.kumar.sa...@gmail.com> wrote:
>>>>
>>>>> A nice problem that i encountered :
>>>>> In O(n) search for a value x in a sorted NxN matrix.
>>>>> Definition of sorted matrix:  All rows and all columns are sorted in
>>>>> ascending order.
>>>>>
>>>>>  So thought of sharing ..
>>>>>
>>>>>
>>>>> Rohit Saraf
>>>>> Sophomore
>>>>> Computer Science and Engineering
>>>>> IIT Bombay
>>>>>
>>>>> --
>>>>> 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.
>>
>
>  --
> 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] Search in a sorted NxN matrix

2009-11-24 Thread chitta koushik
Start from top right or bottom left corner and move according if the element
to be searched is lesser or greater than current.


--Koushik C
Pablo Picasso
- "Computers are useless. They can only give you answers."


On Tue, Nov 24, 2009 at 7:27 PM, Rohit Saraf wrote:

> A nice problem that i encountered :
> In O(n) search for a value x in a sorted NxN matrix.
> Definition of sorted matrix:  All rows and all columns are sorted in
> ascending order.
>
> So thought of sharing ..
>
>
> Rohit Saraf
> Sophomore
> Computer Science and Engineering
> IIT Bombay
>
> --
> 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] Binairy Search Algoritm

2009-11-12 Thread chitta koushik
while(a.[mid].equals('city1') && a[mid+1].equals('city2') ){
 mid = low+high/2;
 if(a[mid]=='city1' && a[mid+1]=='city1')
  low=mid;
 else if (a[mid]=='city2' && a[mid+1]=='city2')
  high=mid;
}

On Thu, Nov 12, 2009 at 3:39 PM, Dennis  wrote:

> Hello, here's the deal...
>
> I have an ordered array containing 'Person' objects. The array is
> ordered by the city the person lives in.
>
> My array contains people from 2 different cities.
>
> Now i need to find the highest index of the first city in the array
> using a binairy search algoritm, i have had several tries but i can't
> seem to figure it out, so i was hoping some of you could help me
> out...
>
> The programming language is Java, but i guess that doesn't realy
> matter much.
>
> Thanks in advance,
> Dennis
>
> --
>
> 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=.
>
>
>

--

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




[algogeeks] Re: find the output

2009-01-06 Thread chitta koushik
nothing is printed as buffer is local to modify function, it cannot be
returned.



"He who speaks,Does not Know...He who knows, Does not speak..."

http://students.iiit.ac.in/~koushik_c/


On Tue, Jan 6, 2009 at 2:48 AM, tania hamid  wrote:

>
>
> Plz indicate the output of the following code and explain why is it so..
>
>
> *char *modify (char *s)
> {
> #define MAX 15
>   char buffer[MAX];
>   strcpy (buffer, s);
>
>   buffer[0] = 'H';
>   return buffer;
> }
>
> int
> main ()
> {
>   printf ("hello!!!");
>   printf ("%s ", modify ("hello!!!"));
> }*
>
>
>
> >
>

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



[algogeeks] Re: I'm stuck with this problem

2007-10-14 Thread chitta koushik
Algo:

1. Maintain a separate array class[] to indicate which element(a,b) belong
to which class
2. assign first(a,b) to class 1.  in eg: 12,30 to class 1
3. for each other element from then compare with members of existing class
if yes assign this element with same class, else assign different class
number.

hope this helps...  it has worst case of complexity of O(n^2)... any better
soln is appreciated.


On 10/14/07, Vijay Chidambaram <[EMAIL PROTECTED]> wrote:
>
>
>
> Legend wrote:
> > Suppose that I have some data:
> >
> > 12,30
> > 12,45
> > 2,3
> > 7,8
> > 3,9
> > 30, 8
> > 45,54
> > 56,65
> >
> > Where (a,b) indicates that a is connected to b. I want to get all
> > connected nodes to one point. For instance, the output of the above
> > example should be something like:
> >
> > Group 1
> > 2,3
> > 3,9
> > Group 2
> > 12,30
> > 12,45
> > 30,8
> > 7,8
> > Group 3
> > 45,54
> > Group 4
> > 56,65
> >
> > The order is not important as long as the whole group stays together.
> > Reason why they are grouped like that:
> >
> > 1. 2 is connected to 3 and 3 is connected to 9 and so we put all the
> > three, i.e. 2,3,9 into one group.
> > 2. 12 is connected to 45 and 12 is also connected to 30 so we put
> > these in the same group but 30 is connected to 8 and 8 is connected to
> > 7 so ultimately we put all these into the same group.
> > 3. 45 and 54 are connected but not related to any other numbers so we
> > put them into another group
> > 4. 56 and 65 are connected but not related to any other numbers so we
> > put them into another group
> >
> > I am unable to figure out an algorithm for this. Can someone guide me?
>
> You can use disjoint data structures for this. A good tutorial can be
> found at
> http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=disjointDataStructure
> .
>
>
> >
>


-- 
---
Great people lived on one basic IDEA! "Thinking on their own lines."

http://students.iiit.ac.in/~koushik_c/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: need an algorithm for inserting tags....

2007-09-16 Thread chitta koushik

please explain ur problem more clearlyi cud be of some help


On 9/16/07, gomsi <[EMAIL PROTECTED]> wrote:
>
> hi,
>
> i have a paragraph where i have to insert  and  tags to
> highlight the required words.i am implementing it in c++  i am
> currently doing it as follows..
>
> i take the corresponding position at which the word occurs within the
> paragraph and the word length and store it in a map(STL)..and start
> inserting the tags after i scan the paragraph for the words
> although it works fine for larger words problem occurs when the word
> to be marked are like "bidder dd d"..the tags start overlapping and
> become mixed up within the paragraph.. can someone provide a good
> algorithm and help please... asap..
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded
jean you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU
HAVE USED IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: What is the most efficient algorithm to find the first non repeating char in a string

2007-08-08 Thread chitta koushik

Hi,

If the string contains only alphabets then we can maintain an array of
26 characters which tells that the alphabets has occured once or
notif it is already occured .we can output it directly...

more efficient algos are welcome


On 8/8/07, JOE11790 <[EMAIL PROTECTED]> wrote:
>
> Hi,
>  I got a question in the interview about how to find the first non
> repeating char in a string. For example for string ABCA, B is the
> first non repeating char. It is easy to come up with a brute
> force algorithm by scanning the string. But is there an efficient way
> to do it?
>
> thanks
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded
jean you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU
HAVE USED IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Reading a PS or PDF..

2007-06-03 Thread chitta koushik
Hi,

I was asking about how to read PDF from a C or C++ (for that matter any
programming language) and not using Acrobat Reader or Evince 

Thanks,
koushik

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Reading a PS or PDF..

2007-06-02 Thread chitta koushik
Hi,

Can anyone explain me how we can read a PDF or PS file and print its
contents...

thanks in anticipation
koushik chitta

-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: a chessboard type problem

2007-05-04 Thread chitta koushik
It's just like Dyanamic programming graph problem ...u can apply dijkstra's
shortest path..only thing u have more constraints to look out..


On 5/4/07, max <[EMAIL PROTECTED]> wrote:
>
>
> Say you have an n*n "chessboard" where each square is associated with
> a real number (pos or neg). You want to navigate from one side to the
> other by either moving one space ahead or one space ahead and one
> space to the side (either side). I need an relatively efficient
> algorithm that will optimize the path so that the sum of the values of
> the squares that are touched is maximized. An easy to implement
> algorithm would be great.
>
> Thanks in advance.
> Max
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Maximum Product contiguous subarray

2007-04-25 Thread chitta koushik
Hi,

I think the problem is same as maximum sum..since product is max. if sum is
max. only thing we have to verify is that we should get even number of
negative numbers in our product..

On 4/25/07, Bootlegger <[EMAIL PROTECTED]> wrote:
>
>
> We've all seen the maximum sum contiguous subarray problem, but heres
> a new take on it: maximum PRODUCT contiguous subarray:
>
> Suppowe we have an array A[1 to n] of n integers (positive and
> negative), Find the maximum product found in any contiguous subarray
> and produce the pseudo-code for in.
>
> I've had a crack and im struggling with this, apparently it can be
> done in O(n) time.
>
> Anyone any idea's?
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Reading a PDF file

2007-04-19 Thread chitta koushik
Hi,

I want to read a PDF file contents and want to print that in a text
file...i.e if a PDF file contains "abcd" i want to read that and store in
text file..

i think we can face problem in knowing how much bytes the PDF header has and
etcdoes any know that please help

thanks in anticipation...

cheers,
koushik chitta
-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Heaps vs. B-Tree

2007-04-18 Thread chitta koushik
Hi,
In reality there is no perfect hash function since database tend to store
large data...hash may get destructive many time if hash function is not
correctly..BTrees gives us bushy nature so...its fast as compared..

Now-a-days BTrees usage has also got down...databases are now using R-trees
and R+ trees which are more effective..

cheers,
koushik


On 4/19/07, C++4LifePuta <[EMAIL PROTECTED]> wrote:
>
>
> A programmer friend of mine told me that research was done and for
> database applications, B-Trees were faster on average as opposed to
> hashes.
>
> I thought about this for a minute and could only come up with maybe
> the amount of data they are storing is so large that a resonably
> unique hash function could not always be derived resulting in frequent
> collisions.
>
> Any thoughts on this?
> 
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Path finding in map

2007-04-18 Thread chitta koushik
Hi,

please explain your problem clearly..u have just given the mapthere are
many popular alogs...like Travelling salesperson algo,Dijkstra shortest
path,Bellmond ford shortest path,All pairs shortest path depending on the
problem..

cheers,
koushiki chitta
On 4/18/07, Lukas Šalkauskas <[EMAIL PROTECTED]> wrote:
>
> Hello,
>   What suggestions you have for path finding like this? algos, etc.
>
>
> --
> You can contact me by :
>msn messanger: [EMAIL PROTECTED]
>yahoo messanger: [EMAIL PROTECTED]
>ICQ: 443443043
>Google Talk: [EMAIL PROTECTED]
>Skype: halfas.online.now
>IRC: HalFas`  (irc2.omnitel.net)
>Home page: http://www.revidev.com/halfas/
>One's leisure project: http://rvision.gamedev.lt/RVengine
> >
>
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: calculating distance

2007-04-15 Thread chitta koushik

Hi,

I think this can be done like.
1)Consider a point and check all the points around it which are
different from it.
2)this can be done recursively...
3)if we get a pixel whose id is same as already visited one...don't
consider that.


On 4/15/07, elesser <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> In a program I am currently writing, I have a matrix (around 6 x
> 3) containing information about the pixels in an image: every row of
> the matrix has information about 1 pixel. The first column contains
> the pixel id and the following two columns contain the x and y
> coordinates. If two rows have the same pixel id, this indicates that
> these two pixels have exactly the same RGB values.
>
> What I'm now trying to do is finding the smallest box in the image
> that contains ALL the colors in the image, that is, that contains
> every pixel with different RGB values at least one time. As far as I
> know, this is done by comparing all x and y coordinates of all the
> pixels with one another, looking for the smallest difference when
> substracting the xy values from each other. The problem is that from
> all identical pixel id's, one pixel has to be chosen that, overall, is
> the closest to all other pixels.
>
> Does anyone have any idea how to do this? I'm programming in MATLAB,
> but code in C or C++ is fine.
>
> Thanks.
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded
jean you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU
HAVE USED IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: RR*=R* ?

2007-03-27 Thread chitta koushik
RR*=R+   and not R* .follow some standard textbooksothers may have
many typo errors

On 3/27/07, Ravi <[EMAIL PROTECTED]> wrote:
>
>
> The text books on regular expressions show that:
> RR*=R*
>
> What I feel is that
> RR*=R(є + R + R^2 + R^3 ... )
>=R + R^2 + R^3 + R^4 ...
>=R+
>=R* - {є}
>
> How come RR*=R* is true?
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: BST represented in array

2007-03-24 Thread chitta koushik
hi,

U get sorted numbers if u traverse the BST in inorder..so if u traverse the
array following inorder u get sorted list and also u visit each index
onceso its O(n)...

with regards,
koushik chitta

On 3/24/07, vim <[EMAIL PROTECTED]> wrote:
>
>
> hi guys
> plz explain how to sort elements of BST represented using array in
> o(n) time
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: C++

2007-03-15 Thread chitta koushik
for Begginers ---Profession C++ WROX publications is good...-if u
already know C++use Effective C++ by Scott meyers(too good book)

On 3/16/07, LiveShell <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>  Sorry for cross postingCan ny body tell me which is the best
> book for C++ ???
>
> LiveShell
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Sorting o(n) time

2007-03-14 Thread chitta koushik
you can sort the students list according to marks in o(n) time by using
RADIX SORT.

On 3/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Dean of Computer Science department wants to keep the motivation
> levels of students of data structure course high by giving incentives.
> He has suggested that after the second minor the top  lon students be
> distributed samosas and the next  sqrt(n) students be given gulab
> jamuns. However, he has stipulated that we cannot sort the student
> roll list according to marks (which would také time) but should use
> data structures skills to determine who gets what in O(n) time???
>
>
> >
>


-- 
***
30 years from now it doesn't matter which shoe you wore,which branded jean
you wore..what all matters is WHAT YOU HAVE LEARNED AND HOW YOU HAVE USED
IT.

http://students.iiit.ac.in/~koushik_c

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---