cant we use knuth morris algorithm..to find pattern..in a row?
On Thu, Oct 27, 2011 at 10:28 PM, Anup Ghatage ghat...@gmail.com wrote:
I guess this is just like finding a word in a matrix
On Thu, Oct 27, 2011 at 7:32 PM, SAMMM somnath.nit...@gmail.com wrote:
Forgot to mention this was
The hashing solution is similar to the 1st answer
herehttp://stackoverflow.com/questions/2932979/find-a-common-element-within-n-arrays
A sorting solution will take O(k.n.logn) time
On Fri, Oct 28, 2011 at 9:51 AM, Anup Ghatage ghat...@gmail.com wrote:
Don,
As you said, the intersection
How do u plan to implement it ???
--
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
How is it possible to create a hash map using elements as keys and their
counts as values .If we give some key the value is automatically computed by
hash function .If u are given an element/key its index/value is calculated
by hash function.am i corrct??
On 27 October 2011 22:36, Nitin Garg
ohh , the number can repeat itself. I dint notice that.
On Fri, Oct 28, 2011 at 4:02 PM, mohit verma mohit89m...@gmail.com wrote:
something like this :
for(int i=0;temp=sum , isum/2;i++)
{ temp=temp-i;
for(int j=i+1;jtemp;j++)
couti j temp-j\n;
}
But there is a problem with code :
something like this :
for(int i=0;temp=sum , isum/2;i++)
{ temp=temp-i;
for(int j=i+1;jtemp;j++)
couti j temp-j\n;
}
But there is a problem with code :
like for sum 7 , repeated cases are 0 3 4 and 0 4 3.
On Thu, Oct 27, 2011 at 7:46 PM, rj7 r4ra...@gmail.com wrote:
@Nitin Garg well if
+1 Gene
With regards,
Praveen Raj
DCE-IT 3rd yr
735993
praveen0...@gmail.com
On Wed, Sep 28, 2011 at 1:36 AM, Gene gene.ress...@gmail.com wrote:
Indeed you must be given that all the array elements are unique or at
least that there are no more than floor(n/2) repeats). Otherwise this
you didnt mention if duplicate elements should appear in the
intersection or not. If no duplicates necessary, then your language
may already have intersection between arrays built in. Or you should
write an intersection operator/method between arrays (in ruby it is
just the operator). My
sorry, i made a slight coding mistake in my last post (invisible 7th
array) , but the logic remains the same...corrected sample output:
arrays: 6
elements in each array: 20
range: 1 to 5
array #1: [3, 4, 3, 4, 5, 3, 2, 2, 1, 4, 2, 3, 4, 4, 3, 1, 3, 2, 4, 4]
array #2: [1, 4, 5, 2, 1, 5, 1, 4, 3,
@ankur - Ans-9 how can it be log n. The heap given is Max heap. I think it
should be O(n) using array or tree traversal (as heap is implemented)
keeping current min at hand. Correct me if m wrong.
On Sat, Oct 15, 2011 at 12:14 PM, shady sinv...@gmail.com wrote:
already been answered... :-/
If a natural number N is given such that N = a × b where a and b are
the factors of N. How many such sets of (a, b) can be formed in which
the selection of the two numbers a and b is distinctly different if N
= 8 × 33 and the distinct factors should be Prime to each other ?
--
You received this
@Mohit
Agreed. The answer is O(n).
On Fri, Oct 28, 2011 at 6:48 PM, mohit verma mohit89m...@gmail.com wrote:
@ankur - Ans-9 how can it be log n. The heap given is Max heap. I think
it should be O(n) using array or tree traversal (as heap is implemented)
keeping current min at hand. Correct
I think Dan's solution is the best one here. TC O(n log n) and SC O(1)
where n is the maximum no. of elements in any array
Instead of starting with K given arrays, just take the first 2.
Sort both of them - time is nlogn
Now run two pointers on each array to save the common elements as they
are
can u plz tell me what exactly %*d means?
--
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.
How are we going to write a program which if fed the data gives the
answer?
Any ideas for the algorithm?
My approach:
We have a graph here.
We have vertices with indegree 0 and outdegree 1. - call it set A
(start points) (m vertices)
We have vertices with indegree 1 and outdegree 0. - call it
Can any one give the pseudo code for creating suffix and tournament tree
??? Not able to find the proper algo in the net ,. tht's y asking for help
. plzz
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web
let this statement int x=100,y=5;printf(%*d,x,y);
in this line first x is assign to '*' and it become %100d
and it will padd 100 spaces before print. and if we use( %*d,x)
then x is assign to '*' and garbage value wud be printed.
On Fri, Oct 28, 2011 at 8:53 PM, annarao kataru
Here is another idea if space is available
Step 1: Go through the whole array, find the maximum. Create a hash table of
the maximum value.
Step 2: Hash the arrays, one by one and re-create them with only unique
elements. (discard on collision)
Step 3: Once you get the unique arrays, create
Any natural no can be written as a product of powers of primes
N = a^m × b^n × c^l where a, b , c are prime no.s
for given N= 8 × 33
N= 2^3 × 3^1 × 11^1
now we can use combinatorics to find 2 distinct factors a × b such that
(a,m)=1 i.e. they are co-primes
On 28 October 2011 20:21, SAMMM
@Sammm: Suppose that N has prime factorization
N = p1^e1 * p2^e2 * ... * pn^en
where ^ indicates exponentiation. Then for a and b to be coprime, a
must contain all or none of the factors of each prime, and similarly
for b. Thus, a is the product of some subset of the pi^ei and b is the
product
I think 5,4
On Fri, Oct 28, 2011 at 9:08 PM, Dumanshu duman...@gmail.com wrote:
How are we going to write a program which if fed the data gives the
answer?
Any ideas for the algorithm?
My approach:
We have a graph here.
We have vertices with indegree 0 and outdegree 1. - call it set A
21 matches
Mail list logo