output is 10 10 20 25 30
On Thu, Feb 23, 2012 at 4:44 PM, Karthikeyan V.B wrote:
> Hi,
>
> this logic generates 10 10 20 25 .. and so on it doesn delete the
> duplicates in the result list
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" grou
Hi,
this logic generates 10 10 20 25 .. and so on it doesn delete the
duplicates in the result list
--
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 gro
Input Data : {[1,3],[2,4],[10,11],[4,6]}
Output: {[1,6],[10,11]}
We have to merge all the ranges that are overlapping. You can consider Input
data as any Data structure.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group,
i can't point out the mistake in algo but i can suggest you a good algo for
the same
a[] is the sorted array of size n
b[] is the sorted array of size 2n in which n elements are absent.
now shift all the elements of b[] to the end leaving the first n positions
vacant(sorted order in b[] is still
question:given 2 sorted list: a's size=n and b's size=2*n but has only
n elements.
merge them into 1 single list.
answer:
i came up with dis but am gettin index out of bound exception. can u
pls spot d mistake?
import java.util.*;
public class merge {
static int a[],b[],size;
public static vo
oops , didnt see the unsorted thing. complexity is mnlog(n) + mn log(m)
On Sat, Jul 16, 2011 at 4:23 PM, sagar pareek wrote:
> sort all the arrays first O(nlogn)
>
> then use merge sort
>
>
> On Sat, Jul 16, 2011 at 3:43 PM, Ankur Khurana
> wrote:
>
>> Use divide and conquer. take 2 array at a
sort all the arrays first O(nlogn)
then use merge sort
On Sat, Jul 16, 2011 at 3:43 PM, Ankur Khurana wrote:
> Use divide and conquer. take 2 array at a time and .so you are merging two
> array at a time.
>
> num_of_list=m;
> length of list=n;
>
> while(num_of_list > 1)
> {
> while( (num of list
Use divide and conquer. take 2 array at a time and .so you are merging two
array at a time.
num_of_list=m;
length of list=n;
while(num_of_list > 1)
{
while( (num of list where length = length_of_list) >2)
{
merge two lists of length (length_of_list);
}
if(num_of_list %2==0)
num_of_list/=2;
else
Q2. Given m arrays of n size each, give an algorithm to combine these arrays
into a single array with sorted elements. Also tell the time complexity of
your solution.
Aseem
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group
you can use mean heap like this
you can take all the first element of array & construct mean heap
now delete the root element(let A) & add it in sorted element
take the next element from the array which A was belonging to & add it in
the heap & heappify it again
& repeat the process till you f
k sorted array can be merged in linear time I believe.
If we have K arrays FIRST, SECOND, ., Up to K
and we keep k counters (i, j, , up to k), one for each list
Simply check if FIRST[i] < SECOND[j], ., Up to K
Put the smallest in the merged list and increment the counter of the list i
Given k sorted arrays each of length n, construct a single merged and
sorted array.focus on running time and space complexity
my soln. 1st basic soln..simple merge sort all whet we does in merging
2 sorted array it too complex for big K
2nd i have approach using min-heap as well but not able to f
@ anand kindly elaborate a bit
On Mon, Jul 5, 2010 at 10:09 PM, Anand wrote:
> Use a Heap of n-way merging: O(klogn)
>
>
> On Sun, Jul 4, 2010 at 5:07 AM, Raajay wrote:
>
>> According to the problem there should be 'n * k' elements in all (on an
>> average). For merging all the elements into a
@divya complexity according to ur ques shud be O(klog n) (thats what i
think ... i may be wrong)
plzzz check 4m source where u take ques
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegro
Use a Heap of n-way merging: O(klogn)
On Sun, Jul 4, 2010 at 5:07 AM, Raajay wrote:
> According to the problem there should be 'n * k' elements in all (on an
> average). For merging all the elements into a single list one has to look at
> all the elements at least once. (For eg in case of mergin
According to the problem there should be 'n * k' elements in all (on an
average). For merging all the elements into a single list one has to look at
all the elements at least once. (For eg in case of merging two lists of size
n1 and n2, the worst case complexity in O(n1 + n2)).
Extending to the mu
sory its not not as i said ;(
On Sat, Jul 3, 2010 at 6:21 PM, jalaj jaiswal wrote:
> merge two lists at a time ... in O(k)
> thus reducing number of lists to half at every step
> i.e n*logk
> its more like bottom up merge sort .. look for it
>
>
> On Sat, Jul 3, 2010 at 11:06 AM, divya wrote:
1. First take two lists at a time and merge them so total elements parsed
for all lists =O(n)
This operation results in k/2 lists
2. Repeat steps till k/2 == 1.
*Time complexity of above solution = O(n logk)*
Step1 would loop through *logk *times and each operation would require
parsing all n elem
merge two lists at a time ... in O(k)
thus reducing number of lists to half at every step
i.e n*logk
its more like bottom up merge sort .. look for it
On Sat, Jul 3, 2010 at 11:06 AM, divya wrote:
> How do you merge n sorted lists with average length K in O(n*log(K))
> time?
>
> --
> You receiv
How do you merge n sorted lists with average length K in O(n*log(K))
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
algoge
On 2010-1-28 21:03, Nirmal wrote:
Given two binary search trees, how to merge them in O(n) time and O(1)
space?
It can be done using O(n) space as below,
1. covert BST #1 into linked list or sorted array
2. covert BST #2 into linked list or sorted array
3. merge them...
but how to do this in
Given two binary search trees, how to merge them in O(n) time and O(1)
space?
It can be done using O(n) space as below,
1. covert BST #1 into linked list or sorted array
2. covert BST #2 into linked list or sorted array
3. merge them...
but how to do this in place?
--
You received this message
HI everybody,
I'm wondering what will be more efficient.
Let's say I have p processors (so i can use p processes working
parallel).
I need to create a merge sort so I got two options:
1) Divide the array to half each time and give each process a half
when it's possible.
2) Divide the array to n/p
23 matches
Mail list logo