wap a program in efficient manner to remove all occurrence of
duplicate character in the word and all occurrence of duplicate word
in the file.
i break the problem in two section( this is my approach it may be
better one )
wap to remove all duplicate character in the word. (order is important)
[
Use the rejection technique, something like this:
do
{
do
U1 = random_1_to_5();
while( U1 == 5 );
// At this point, U1 is a uniform integer in the range 1 to 4.
U2 = random_1_to_5();
if( U1 > 2 )
U2 += 5;
}
while( U2 > 7 );
// At this point, U2 is a uniform random
@ankur: u r right.
On Mon, Sep 7, 2009 at 9:36 PM, ankur aggarwal wrote:
> I KNow a sol for given a rand_5() function which generates 0 to 5
> and we have to find rand_7() for 0 to 7
>
> could not think about it...
>
>
>
> On Mon, Sep 7, 2009 at 9:26 PM, ankur aggarwal
> wrote:
>>
>> Given a ran
Cud u plz explain the logic behind this?
On Mon, Sep 7, 2009 at 9:44 PM, Gokul wrote:
>
> you can try this..
> int add(int x, int y)
> {
>if (!x) return y;
>else
> return add((x & y) << 1, x ^ y);
> }
>
>
>
> On Sep 7, 4:01 pm, ritter
you can try this..
int add(int x, int y)
{
if (!x) return y;
else
return add((x & y) << 1, x ^ y);
}
On Sep 7, 4:01 pm, ritter wrote:
> how to add two integers without using arithmetic operators?
> can anyone help me.
--~--~--
Given a random number generator that generates numbers in the range 1 to
5, how can u create a random number generator to generate numbers in the
range 1 to 7. (remember that the generated random numbers should follow a
uniform distribution in the corresponding range)
--~--~-~--~~---
I KNow a sol for given a rand_5() function which generates *0* to 5
and we have to find rand_7() for *0* to 7
could not think about it...
On Mon, Sep 7, 2009 at 9:26 PM, ankur aggarwal wrote:
> Given a random number generator that generates numbers in the range 1 to
> 5, how can u create a ra
is it not finding a cycle in a graph of length 3.
On Sun, Sep 6, 2009 at 9:02 PM, Dufus wrote:
>
> The following approach might work.
> Let K be the maximum degree of a vertex in the graph
> Enumerate each of the n vertex as 1...n
> Enumerate undirected edge between vertex i and j (i.e. i--j
How about using a hash. Hash element to its position in the array.
This way we can preserve the order.
On Sep 7, 4:33 pm, gaurav gupta <1989.gau...@googlemail.com> wrote:
> Counting Sort is a good solution. This problem is same like :
>
> you have an array 1,3,1,3,2,6,5,7,8,5,6,4,5,2 You have to
To Add two integer you can use full adder at bit level.
if bit1 and bit2 are kth bits and car is previous carry then
sum = bit1 ^ bit2 ^ carry;
carry = bit1.carry + bit2.carry + bit1.bit2;
here ^ = bitwise zor
. = bitwise and
+ = bitwise or
repeat it for all bits of two integer,
Counting Sort is a good solution. This problem is same like :
you have an array 1,3,1,3,2,6,5,7,8,5,6,4,5,2 You have to arrange them such
that all number having same value should occur together and order of
occurrence in series should conserve. So result will be :
1,1 ,3,3,2,2,6,6,5,5,5,7,8 ,4
O
I think this can be done by using XOR operations...or can be done by using a
loop and using increment operators (if they are allowed).
On Mon, Sep 7, 2009 at 4:31 PM, ritter wrote:
>
> how to add two integers without using arithmetic operators?
> can anyone help me.
>
> >
>
--
Thanks and Rega
nagendra..
plz show the working using an example ..
take input
babbaabbc
On Sun, Sep 6, 2009 at 2:07 PM, Nagendra Kumar wrote:
>
> @all:
>
> T(i,j) : denotes the length of longest palindrome with start index
> i and end index j index.
> T(i,j )=
> max {
>
*"
*
>
> *
> @kunzmilan *
>
* *
> *" What do you mean by polynomial of the graph ? "
> *
>
*
*
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@g
@ Ankur,
IMHO suffix tree is ONE of the solution.
_dufus
On Sep 3, 7:37 am, ankur aggarwal wrote:
> only suffix tree is the soln i think..
>
> On Wed, Sep 2, 2009 at 11:20 AM, nitin mathur
> wrote:
>
>
>
>
>
> > Hi everybody..
>
> > I am sorry as the algorithm I proposed takes O(n^2) and not
1.Write a function to smooth out stock fluctuations.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this gr
How about counting sort in O(N+K) time and O(K) space.
_dufus
On Sep 6, 1:06 pm, ankur aggarwal wrote:
> You have N balls having one of K colors. Arrange them into groups of same
> colors. e.g.
>
> RRGRG
> can be arranged as
> RRRGG (Answer)
> GGRRR
--~--~-~--~~---
The following approach might work.
Let K be the maximum degree of a vertex in the graph
Enumerate each of the n vertex as 1...n
Enumerate undirected edge between vertex i and j (i.e. i--j) as
(i,j)
Sort all the |E| edges in O(|V| + |E|) time // radix sort.
Now (i1,i2,i3) form a triangle iff
3.You have 50,000 html files, some of which contain phone numbers. How would
you create a list of all the files which contain phone numbers?
Solutions should be optimal
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
how to add two integers without using arithmetic operators?
can anyone help me.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
If Z[] is allowed to modify then i think we can do in O(1) space //
quite clear from the link I have posted above
else we need O(k) space to restore Z[].
_dufus
On Sep 6, 2:32 pm, ankur aggarwal wrote:
> @dufus
> wat is your complexity ??
>
> On Sat, Sep 5, 2009 at 8:17 PM, Dufus wrote:
>
> >
21 matches
Mail list logo