it would be size of int.
On Jul 7, 10:34 am, oppilas . jatka.oppimi...@gmail.com wrote:
Ok. So for differentiating objects, we have size 1. What will be size of
following class:-
class A{
int z;};
How does different objects gets differentiated in above case?
On Wed, Jul 6, 2011
Hi,
You may look out for plagirism detectors.
My approach would be :
1. Hash all the keywords in one file and keep the count.
2. For each keyword in the other file , check if it exists in the hash table
, decrement its count. Also increment a counter which represents the
similarity between the
93747
x^2+2x-15=0 roots are x=3 and x=-5
equations being 5digits (x^2) (x) (y) (x+1) (y1)
y+y1=14
x+y=10
x=3
Solving these we get 93747
Regards
Rajeev
On Wed, Jul 6, 2011 at 7:35 PM, Anika Jain anika.jai...@gmail.com wrote:
93747
On Wed, Jul 6, 2011 at 5:05 AM, anurag aggarwal
Another question reg. quicksort.
If we always find the median in o(n) and use it as the pivot ,will the
quicksort by o(nlogn) ( i mean worst case also o(nlogn) )?
Since partition is anyway o(n) , im making it o(n) + o(n){for finding
median}.
On Wed, Jul 6, 2011 at 2:50 AM, Ritesh Srivastava
I gave this method as you are also expecting random(0,1) to give values
either 0 or 1 only, not between these two.
Thanks and Regards
Devansh Gupta
MNNIT, Allahabad
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
@Navneettake a look at the solution below and tell if there is any bug
in it...
*#include string.h
typedef struct revll
{
char s[100];
struct revll *next;
}revll;
revll *rev_str(char *a)
{
char temp[100];
int i,len=strlen(a),j=0;
revll *head,*p;
Yes, Random(0, 1) gives values 0 or 1 only with equal probabilities. But
your solution won't work.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
a clock gains uniformly and is 5 minute at 8.00 am on sunday.And on
next sunday it is 5 minute 48 second fast at 8.00 pm.Tell the time
when clock was showing correct time
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
There is a straight roads with 'n' number of milestones. You are given an
array with the distance between all the pairs of milestones in some random
order. Find the position of milestones.
Example:
Consider a road with 4 milestones(a,b,c,d) :
a --- 3Km ---b--- 5Km ---c--- 2Km ---d
Distance between
I think for initial start it should be the minimum n values for n
milestones
On Thu, Jul 7, 2011 at 1:53 PM, Akshata Sharma akshatasharm...@gmail.comwrote:
There is a straight roads with 'n' number of milestones. You are given an
array with the distance between all the pairs of milestones
But the problem arises in setting the order
On Thu, Jul 7, 2011 at 2:06 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
I think for initial start it should be the minimum n values for n
milestones
On Thu, Jul 7, 2011 at 1:53 PM, Akshata Sharma
Off Topic:
Sorry for the diversion, but I was just wondering how easy it has
become to code in languages other than c. Here is the code i wrote for
the above mentioned problem in Python. It takes command line arg as
string. something like
vishal@ubuntu:~/progs/python\ 02:45:07 PM $ cat rev.py
@Vishal, can you see if your program works well for more than single
space between words? Not sure how split functions helps.
BTW, Perl also is very strong language for string manipulations.
(Specially designed for efficient string operations)
On Thu, Jul 7, 2011 at 2:48 PM, Vishal Thanki
Can we do this?
Start with a node, take an edge say between x1 and x2 of length k1.
Take another node x3 and check distance between x1 and x3 (k13) and x2
and x3 (k23)
Depending on whether k13 or k23 is bigger, the node x3 between x1 and
x2 or away from x1 and after x2.
Proceeding in this way
@Navneet, it works with multiple spaces between words.. And here is
the two line solution :)
import sys
print .join((sys.argv[1].split())[::-1])
On Thu, Jul 7, 2011 at 3:12 PM, Navneet Gupta navneetn...@gmail.com wrote:
@Vishal, can you see if your program works well for more than single
@Vishal,
Don't confuse printing in reverse with actually modifying the actual
string to reverse word order in it :)
On Thu, Jul 7, 2011 at 3:34 PM, Vishal Thanki vishaltha...@gmail.com wrote:
@Navneet, it works with multiple spaces between words.. And here is
the two line solution :)
import
if b-a is exactly 2^k-1 , k0
then a + k bits (each bit is set using rand(0 1) ) with equal probability
surender
On Thu, Jul 7, 2011 at 1:20 PM, Nitish Garg nitishgarg1...@gmail.comwrote:
Yes, Random(0, 1) gives values 0 or 1 only with equal probabilities. But
your solution won't work.
--
You
yea, expression .join((sys.argv[1].split())[::-1]) will return the string!!
On Thu, Jul 7, 2011 at 3:36 PM, Navneet Gupta navneetn...@gmail.com wrote:
@Vishal,
Don't confuse printing in reverse with actually modifying the actual
string to reverse word order in it :)
On Thu, Jul 7, 2011 at
#!/usr/bin/python
import sys
string=sys.argv[1]
string= .join((string.split())[::-1])
print string
How does this sound? :P
On Thu, Jul 7, 2011 at 3:43 PM, Vishal Thanki vishaltha...@gmail.com wrote:
yea, expression .join((sys.argv[1].split())[::-1]) will return the
string!!
On Thu, Jul 7,
I meant, having the result in same string which was used as param. Is
that the case? I think the below will use a separate string.
On Thu, Jul 7, 2011 at 3:43 PM, Vishal Thanki vishaltha...@gmail.com wrote:
yea, expression .join((sys.argv[1].split())[::-1]) will return the
string!!
On
Okay, I think NO EXTRA SPACE is what i should have mentioned clearly.
Anyways dude, i appreciate the point of simplicity which you are
trying to show.
On Thu, Jul 7, 2011 at 3:45 PM, Navneet Gupta navneetn...@gmail.com wrote:
I meant, having the result in same string which was used as param. Is
How about this??
Since we have the distances between all pairs of nodes, so first we find the
largest distance.
They nodes which are the maximum distance are terminal nodes.
So in the given e.g. we get a-d at a distance of 10 units.
Now with this we know that the remaining nodes will lie between
How about this ?
1. We construct a graph with these nodes.
2. We make an incoming edge on a node if it is created using some
other node. Ex: 7=5+2. So 7 will have 1 incoming and 5 2 will have
outgoing.
3. Select all the nodes which only have outgoing edges. These would be
the actual distances
Thanks Dave, nice solution. By setting the bits we can get equal
probabilities.
--
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/-/Y02NVHYBhdkJ.
To post to
@nishit whats the problem with Bipartite Matching ist perfect example
of Bipartite Graph isn't it ?? as have to just divide the set of
vertex in to two disjoint set such that no two people who are friends
will be in same team that what Bipartite Matching says ??
although graph coloring will also
the clock has become faster by 48 seconds in 10800 minutes
i.e., 1 sec in 225 minutes
from 8am on sunday we have to go 225*5*60 minutes behind to get time when
clock showed the correct time.
i.e., 67500 minutes or 44 days 1260 minutes
44 days 21 hours
which means clock showed correct timing at
What about this:
First you have the list of distances between two milestones. Let’s form a
table
Start milestone
End Milestone
Distances
A1
A0
7
A0
A3
10
A1
A2
5
A2
A3
2
A0
A2
8
A0
A1
3
I have taken above variable A0, A1, A2, A3 for a, b, c, d respectively. Now
we sort the
struct t{};
int main(){
struct t a,b,c;
int l;
printf(%u %u %u %u\n,a,b,c,l);
}
o/p
3213845680 3213845680 3213845680 3213845676
a,b,c all are pointing to same location, so no space is allocated to them.
As i already mentioned, *may be* . I dont know what standard says about it
or rather i
how about this?
given n milestones
1.find max number from the array and delete it.
2.now find any (x,y) both from the array such that x+y == max.
3. put min(x,y) in the front of output array, delete y from array and
if(sizeof(output array)==(n-2))
put x also in front of output array and
Initially we can sort the array in O(nlogn) and then given a max
value, find a pair (x,y) in O(n). here n is also of quadratic order if
taken in terms of no. of milestones.
On Jul 7, 5:52 pm, Dumanshu duman...@gmail.com wrote:
how about this?
given n milestones
1.find max number from the
Heres a problem that I've been trying to solve using Dynamic Programming but
I've got no where with it. Any hints would be appreciated.
A program's library offers a simple function to split a string into two
parts. As this operation requires copying the entire string, it takes time
n, where n is
My solution,
a) First sort the distances.
b) We will consider the first 2 minimum numbers.. They are definitely the
distances between the 3 nodes...
c) Find the sum of the first 2 minimum numbers.. If this sum is outside n
then we simply return all the nodes less than n else remove that sum and
My solution,
a) First sort the distances.
b) We will consider the first 2 minimum numbers.. They are definitely the
distances between the 3 nodes...
c) Find the sum of the first 2 minimum numbers.. If this sum is outside n
then we simply return all the nodes less than n else remove that sum and
Hi,
a --- 3Km ---b--- 5Km ---c--- 2Km ---d--- 6Km --e
lets arry be 3,5,2,6,8,10,16,7,13,8it can be any order...
higest value is 16 ie total distance.
now chose pairs whose sum equals to 16
3,13
6,10
8,8
now we come to know the distance of point for either from a or e
If we are able to
This will take more time than mine... Mine will be very fast as we are
exiting if the least sum is outside n
On Thu, Jul 7, 2011 at 6:56 PM, yv paramesh yv.param...@gmail.com wrote:
Hi,
a --- 3Km ---b--- 5Km ---c--- 2Km ---d--- 6Km --e
lets arry be 3,5,2,6,8,10,16,7,13,8it can be any
Got it...Thanks..
On Wed, Jul 6, 2011 at 11:31 PM, shiv narayan narayan.shiv...@gmail.comwrote:
speed of river=(distance traveled by object in it) / total time it
took to travel
here hat has traveled a distance of 1 KM
and it has taken =5mn+5 min=10 min=10min/60=1/6 hrs;
so speed =
At a movie theater, the manager announces that they will give a free ticket
to the first person in line whose birthday is the same as someone who has
already bought a ticket. You have the option of getting in line at any time.
Assuming that you don't know anyone else's birthday, that birthdays are
The greatest chance i.e. 100% chance would be at position number 366.
(By Pigeonhole principle).
On Jul 7, 2:34 pm, swetha rahul swetharahu...@gmail.com wrote:
At a movie theater, the manager announces that they will give a free ticket
to the first person in line whose birthday is the same as
I have one more approach in mind where it requires T(n) = O(n) and
O(1) space complexity. here it goes:
1) Start traversing the array.
2)Store the location when 0 and 1 both appears for the first time in
some variable.
3)Similarly store the location of 0 and 1 when both appears for the
last time
Q10.
array a[]={19 16 18 3 50 70 12 11 14}
array b[];
sum required=30
3 11 12 14 16 18 19 50 70 //sort
0 1 2 3 4 5 6 7 8 //index
lr
count=0,i=0;
while(lr)
{
if(a[l]+a[r])sum
r--;
elseif(a[l]+a[r])sum
l++;
else
{
thanks yogi.
it is amzing tric and solution
--
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
Q3.
start with 7000 //8 digit number
7000
7001 //as 7 is 1 time so 8th place is 1
6001 //as due to 1 on 8th place no. of zeros =6
6010 //as 6 is present so 7th place is 1 and 7 is not present so 8th
place is again changed to 0
6110 //as 1 is present on 7th place so at 2nd
probability that i win standing at second position: 1/365
third position : 364/365*2/365 = 1/365)*(628/365)
fourth position : 364/365*363/365*3/365
4th : 364/365*363/365*362/365*4/365
nth position:
(365-1)*(365-2)*(365-3)*(365-4)*(365-5).*(365-(n-2))*(365-(n-1))*(n)*(1/365)^n
--
You
Akash johari : can you tell me the way to create suffix tree in o(n)
time ? i know only nlogn (also n*logn^2) method . If not , how can
you do it in o(n) ?
@ hemeesh : Also how can KMP be useful to solve it ?
On Jul 6, 8:25 pm, Hemesh Singh hemesh.mn...@gmail.com wrote:
I think this problem
Sorry for the previous post
the last line was incorrect
it should have been (n+1)th position
I was just writing roughly and pressed send instead of save.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
probability that i win standing at second position: 1/365
probability that i win standing at third position : 364/365*2/365 =
1/365)*(628/365)
probability that i win standing at fourth position : 364/365*363/365*3/365
probability that i win standing at 4th position :
364/365*363/365*362/365*4/365
@Sachin: What if the milestones were, A1-A3-A2-A0 in this order?
Regards,
Sandeep Jain
On Thu, Jul 7, 2011 at 6:00 PM, sachin sharma sachin.bles...@gmail.comwrote:
What about this:
First you have the list of distances between two milestones. Let’s form a
table
Start milestone
End
@Sachin: What if the milestones were, A1-A3-A2-A0 in this order?
Regards,
Sandeep Jain
On Thu, Jul 7, 2011 at 6:00 PM, sachin sharma sachin.bles...@gmail.comwrote:
What about this:
First you have the list of distances between two milestones. Let’s form a
table
Start milestone
End
Can u elaborate something on implementation.??
--
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
char a[20];
int l;
int main()
{
char str[100];
scanf(%s,str);
l=strlen(str);
}
--
*Regards,*
*Piyush Kapoor,*
*CSE-IT-BHU*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Pls Ignore my above post..
On Thu, Jul 7, 2011 at 10:36 PM, Piyush Kapoor pkjee2...@gmail.com wrote:
char a[20];
int l;
int main()
{
char str[100];
scanf(%s,str);
l=strlen(str);
}
--
*Regards,*
*Piyush Kapoor,*
*CSE-IT-BHU*
--
*Regards,*
*Piyush Kapoor,*
step:-
1) sort the array
2) remove the smallest and largest element from arary. keep the smallest
elemnt in seperate queue(result)
3) repeat the above untill the array is empty or it contains only it
contains only one element
4) put the last element also in the queue (result)
eg:-for ur example
No need.. check my solution...
On Thu, Jul 7, 2011 at 10:39 PM, durgesh kumar durgesh1...@gmail.comwrote:
step:-
1) sort the array
2) remove the smallest and largest element from arary. keep the smallest
elemnt in seperate queue(result)
3) repeat the above untill the array is empty or it
On Thu, Jul 7, 2011 at 6:41 PM, Swathi chukka.swa...@gmail.com wrote:
My solution,
a) First sort the distances.
b) We will consider the first 2 minimum numbers.. They are definitely the
distances between the 3 nodes...
c) Find the sum of the first 2 minimum numbers.. If this sum is outside
On Thu, Jul 7, 2011 at 4:15 PM, Gaurav Tyagi cho...@gmail.com wrote:
How about this ?
1. We construct a graph with these nodes.
2. We make an incoming edge on a node if it is created using some
other node. Ex: 7=5+2. So 7 will have 1 incoming and 5 2 will have
outgoing.
3. Select all the
Why it will fail.. let the given sequence be :
A-1--B---5---C--3-D-2-E
A-B : 1
A -C : 6
A -D: 9
A-E : 12
B-C: 5
B-D: 8
B-E: 10
C-D: 3
C-E: 5
D-E: 2
When we sort we will get 1,2,3,5,5,6,8,9,10,12.
The first 2 small number are 1 and 2... so out of 4 distances we
char a[20];
int l,i,j,k;
int main()
{
char str[100];
gets(str);
l=strlen(str);
for(i=l-1;i=0;){
k=19;
a[k]='\0';
while(i=0 str[i]!=' '){
a[--k]=str[i--];
}
printf(%s,a+k);
while(i=0 str[i]==' ') i--;
printf( );
}
}
On Thu, Jul 7, 2011 at
dear swathi,
i m not geetint solution for this pexample according to your algo.cold u
explain me wth this example ...
A--1---B--5--C-3-D2E
thanks in advance
durgesh
--
You
step:-
1) sort the array
2) remove the smallest and largest element from arary. keep the smallest
elemnt in seperate queue(result)
3) repeat the above untill the array is empty or it contains only it
contains only one element
4) put the last element also in the queue (result)
eg:-for ur
@swathi
i think your algo won't work
try out for the following cases
1. 2,3,5,7,8,10
2. 2,3,5,6,9,11
On Thu, Jul 7, 2011 at 10:59 PM, oppilas . jatka.oppimi...@gmail.comwrote:
step:-
1) sort the array
2) remove the smallest and largest element from arary. keep the smallest
elemnt
sry it was mistyped
--
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
@swathi:- nice try bt could u explain for
A1---B--6--C-3D--2E
thanks
Durgesh
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
@oppilas:- yes U r right... i simply mistyped it...I think evrythng else
is ok.
thanks Durgesh
--
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
Hi everyone... umm i am a bit new to algo applications in programming..
can anyone pls tell me what all is important in algorithms? ,From
companies point of view...
I have studied upto ch-13 of the book Cormen.
Thanks..
--
You received this message because you are subscribed to the Google
The ans is 16 because :-
if we drop from 16th floor and if egg1 breaks floor to be tested is b/w 1-16
. Then start from floor 1 with egg2 and floor from which it breaks first is
obtained and will lie b/w 1-16. the attempts are no more than 16.
however If egg1 doesn't break on 16 floor then try on
The answer is 14 .
On Thu, Jul 7, 2011 at 11:25 PM, Sumit chauhan sumitchauhan...@gmail.comwrote:
The ans is 16 because :-
if we drop from 16th floor and if egg1 breaks floor to be tested is b/w
1-16 . Then start from floor 1 with egg2 and floor from which it breaks
first is obtained and
@durgesh,
step:-
1) sort the array
2) remove the smallest and largest element from arary. keep the smallest
elemnt in seperate queue(result)
3) repeat the above untill the array is empty or it contains only it
contains only one element
4) put the last element also in the queue (result)
for
Sumit,
the answer is 14
I think the example of 16 that they take on careerplus is probably confusing
you.
--
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
Given an array of integers A, give an algorithm to find the longest
Arithmetic progression in it, i.e find a sequence i1 i2 … ik,
such that
A[i1], A[i2], …, A[ik] forms an arithmetic progression, and k is the
largest possible.
The sequence S1, S2, …, Sk is called an arithmetic progression if
Design a data structure that can be used instead of an array and
avoids the high-cost (i.e. O(n)) of initializing the array. the data
structure ought to holds n items and supports the following operations
in O(1) time:
* Init – Initializes the data structure to empty.
* Set(i, x) – Sets item x at
Sory once again for that incomplete answer.
The complete one is here.
probability that i win standing at second position: 1/365
probability that i win standing at third position : 364/365*2/365 =
1/365)*(628/365)
probability that i win standing at fourth position : 364/365*363/365*3/365
:Given two sorted arrays a[]={1,3,77,78,90} and b[]={2,5,79,81}. Merge
these two arrays, no extra spaces are allowed. Output has to be
a[]={1,2,3,5,77} and b[]={78,79,81,90}.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
Ans :- 3
let bottles be1,2,3,4,5,6
and mice be a,b,c.
separate bottle 6
make pairs P(1,2,3) ; Q(2,4) ; R(3,4,5) and given to mice a,b,c resp.
if poison is inbottle mice who dies
1 a
2 a,b
3
@ Tushar
the answer is 16 and i have proved it.
if it is 14 , then prove 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
Check the differences between the adjacent elements and store the
differenecs in diff[i] array
then scan through the array .
then keep a count for all the repeated diff elements ,the sequence of
indexes with max count is the solution .
On Thu, Jul 7, 2011 at 11:43 PM, Piyush Sinha
@Sumit
lets consider the case the Egg does not break even from 100th floor
in your case u will get to know the answer in 8th trial.after 91 trying
from 100
but worst case solution is 16 for your solution.
we can do better by starting at 14 as above explained
@rajiv
Fails i think
think for 10 12 24 26
diff is 2 12 2
so do you want to say there is an AP pf 3 elements with d = 2, i can't see
any :P
your solution fails because there can be many APs in the array with the same
value of d and you will finish up by combining all those APs
On Fri,
@sunny
dude i got so excited after finding this solution i did not bother to check
for 14
--
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
So, I think first check for excellent groups then good and then usual to
increase the quality.
So to get excellent groups scan the string and keep a count of the
contagious repeating elements ,if count==3 or count==2,then put in one
group
The same procedure for good and usual accord to constraints
@rajiv
if Count = 2 means 3 elements isn't it a,a+d,a+2d
else according to you
for case 10 12 14 24 26 28
diff 2 2 10 2 2
diff 2 has count 4 so will you say ap of 4 elements with diff 2
On Fri, Jul 8, 2011 at 1:06 AM, rajeev bharshetty rajeevr...@gmail.comwrote:
@sunny Keep count of
Should the sequence beContinuos ???
On Fri, Jul 8, 2011 at 1:18 AM, sunny agrawal sunny816.i...@gmail.comwrote:
@rajiv
if Count = 2 means 3 elements isn't it a,a+d,a+2d
else according to you
for case 10 12 14 24 26 28
diff 2 2 10 2 2
diff 2 has count 4 so will you say ap of 4
@radha...i have an algo but its complexity is O(n^2)...check the
following and see if there is any bug as I havent tested for all
cases...also suggestions are welcomed:)
main()
{
int a[]= {1,3,77,78,88};
int b[]= {2,5,79,80,81,99};
int i=sizeof(a)/sizeof(a[0]) - 1;
int
ok ! i got a O(n lgn) finally
i don know exact complexity
Let N = size of first array
Find the first N smallest elements using one pointer in each array
now swap the list of elements from index 0 to second-pointer in
second array to first array
with first_poiner+1 to N in first Array
I think this
@Rajeev...check ur logic for 4
On 7/8/11, rajeev bharshetty rajeevr...@gmail.com wrote:
So, I think first check for excellent groups then good and then usual to
increase the quality.
So to get excellent groups scan the string and keep a count of the
contagious repeating elements ,if
Nopesits about finding subsequence
On 7/8/11, rajeev bharshetty rajeevr...@gmail.com wrote:
Should the sequence beContinuos ???
On Fri, Jul 8, 2011 at 1:18 AM, sunny agrawal
sunny816.i...@gmail.comwrote:
@rajiv
if Count = 2 means 3 elements isn't it a,a+d,a+2d
else according to
Given 77, it can be divided into 77-77-77 or 777-777
so it will return 77-77-77 with a quality of 6, other than the other
way, which gives quality of 4.
Also , a good group like 229, can be seen as 22-9, which gives a
excellent group.
I assume first looking groups with 2 digits?
On Jul 7,
yes upto the step of swapping the elements it is O(m+n)
but if you need final arrays also sorted (Seems like that from your first
post)it will go nlgn
On Fri, Jul 8, 2011 at 1:25 AM, radha krishnan radhakrishnance...@gmail.com
wrote:
ok ! i got a O(n lgn) finally
i don know exact
It scans 555 count=3(excellent group) it will put in one group than 54
since the count is one puts that in usual group quality =2*1 =2 ,
On Fri, Jul 8, 2011 at 1:28 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
@Rajeev...check ur logic for 4
On 7/8/11, rajeev bharshetty
@RADHA..ya true...my bad i cudnt think dat way...but as pointed out by
Sunny the sorted output cant be brought in O(n)...In order to get the
sorted output only my algo took O(n^2)...tell me if I am missing
anything...
On 7/8/11, sunny agrawal sunny816.i...@gmail.com wrote:
yes upto the step of
i think DP has answer to this question
initialy compute the quality value of all the substrings of length 1,2,3
Ans[i][j] =
max(ans[i,j-2]+ans[j-1][j],ans[i,j-3]+ans[j-2][j],ans[i,i+1]+ans[i+2][j],ans[i,i+2]+ans[i+3][j])
something like that.
On Fri, Jul 8, 2011 at 1:31 AM, rajeev bharshetty
@Rajeev..there is the fault.for 4, there can be 2 excellent groups..
55
55
54
therefore, quality = 2*2 = 4
which is highest...
On 7/8/11, rajeev bharshetty rajeevr...@gmail.com wrote:
It scans 555 count=3(excellent group) it will put in one group than 54
since the count is one puts
sorry a typing mistake...lst line contains only 4
On 7/8/11, Piyush Sinha ecstasy.piy...@gmail.com wrote:
@Rajeev..there is the fault.for 4, there can be 2 excellent
groups..
55
55
54
therefore, quality = 2*2 = 4
which is highest...
On 7/8/11, rajeev bharshetty
@Rajeev...ignore my previous two posts.
the grouping can be done as
55
554
quality is 2*1+1 = 3 which is the highest
On 7/8/11, Piyush Sinha ecstasy.piy...@gmail.com wrote:
sorry a typing mistake...lst line contains only 4
On 7/8/11, Piyush Sinha ecstasy.piy...@gmail.com wrote:
given two sorted arrays a[m] b[2*m], each contains m elements only.
You
need to merge those two arrays into second array b[2*m].
anything better than O(m^2)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
how to make a sufffix tree with different complexities along with its
uses
--
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
I remember there is an swap using XOR that uses no extra space. It's
also O(1).
assume we have a O(1) function: swap(a, b)
a[m], b[n], all sorted separately.
for (i = 0; i m; i++){
if (a[i] b[0]){
swap(a[i], b[0]);
if (b[0] b[1]){
swap(b[1], b[0]);
}
@sunny , yep it looks DP. more of MCM.
solve for substrings of length 1,2,3.
and then apply DP[i][j]=max score for a substring from i to j.
=max(DP[i][k]+DP[k][j]) where ki kj .
The complexity this approach renders would be O(n^3).
with O(n^2) space complexity.
anyone anything better ?
Yep, I was wrong.
for (i = 0; i m; i++){
if (a[i] b[0]){
swap(a[i], b[0]);
push b[0] to the end of array-b as far as possible here.
}
}
Then it's not O(m+n) anymore. O(mn) instead.
On Jul 7, 4:33 pm, Yuduo Zhou yuduoz...@gmail.com wrote:
I remember there is an swap
@Sunny...can u post a definite algo for it??
On 7/8/11, Ravi Shukla shuklaravi...@gmail.com wrote:
@sunny , yep it looks DP. more of MCM.
solve for substrings of length 1,2,3.
and then apply DP[i][j]=max score for a substring from i to j.
=max(DP[i][k]+DP[k][j]) where ki kj .
The
O(m) is always better than O(m^2) :) :P
Simple merge sort
hint : start from end of the arrays
select the text in white font to see the hint :)
On Fri, Jul 8, 2011 at 1:56 AM, Dumanshu duman...@gmail.com wrote:
given two sorted arrays a[m] b[2*m], each contains m elements only.
You
need to
1 - 100 of 113 matches
Mail list logo