Hello, as it can be inferred from profile, I am new. I have read the community guidelines and I have done prior research. I am a very weak coder(through my own fault). However, I like to believe I firm conceptual understanding. **So What is my problem?** I have an assignement that requires analysis of three fast sorting algorithms(radix, quick sort, and merge sort). The exact specifications are as follows: 1. Design and implement a variation of QuickSorter class that partitions the sequence to be sorted using the pivot other than the first element in the sequence. Run a sequence of … |
+0 forum
3 | ||

I am trying to sort an ArrayList of Strings using the Merge Sort algorithm. However, I am having an error where it occurs on line 67 **`result.set(i,right.get(r));`** Where I get the IndexOutOfBoundsException. I have tried printing out the index of the result, and it seems to be that I am trying to access the i element (which is result's size) However, I am not sure where in the code am I setting i to result's size. I am new to Java so much help will be appreciated! import java.util.*; public class MergeSort { public static void sort(ArrayList<String> s) { if … |
+0 forum
1 | ||

Assume that we have a mergesort algorithm which takes 2 series as an input and returns 1 after the merge each time. So that if we want to count say memory blocks we would need 2 blocks for the input and 1 for the output accordingly, total size of 3 blocks (3B). My question is whether this algorithm could run if the memory size is 2B + O(1)? |
+0 forum
3 | ||

I was asked to write a program, based on parent-child cooperation, which uses a “parallel” merge sort to a sequence of 800 numbers from a text file.I have to read the sequence of 800 integers, which I store in an array, and then pass half of them to a child, and the other half to the second child of the parent class. I have to do this until only 100 numbers are left in each child. When I have reached this the numbers must be sorted, which I am doing using a bubble sort.Once these are sorted the must be … |
+0 forum
7 | ||

Hi! What could be the best algorithm for "Merge Sort" where the memory must be used "most effectively"? I just know the standard way to do this, but that's not the most effective way how to use the memory. This is the only variant which I know: [CODE=c] #include <iostream> using namespace std; int main() { int arr1[20]= {0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; int arr2[14]= {0,23,25,27,29,31,33,35,37,39,40,41,42,43}; int arr3[34]; int indexA=0, indexB=0, indexC=0; while((indexA<20) && (indexB<14)) { if(arr1[indexA] < arr2[indexB]) { arr3[indexC] = arr1[indexA]; indexA++; } else { arr3[indexC] = arr2[indexB]; indexB++; } indexC++; } while(indexA<20) { arr3[indexC] = arr1[indexA]; indexA++; indexC++; } while(indexB<14) { … |
+0 forum
3 | ||

I need to use mergesort to sort the data in a file that has the names and ages of 10 different people , first i have to sort the names in ascending ascii order and then i have to sort them by their age but im not sure how to do it this is what i have so far [CODE] #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define NUMBER_OFPEOPLE 10 typedef struct{ char name[6] ; int age ; }people ; typedef char byte ; void memcopy( byte *to, byte *from, int count ) { while (count-- > 0 ) … |
+0 forum
4 | ||

Hi. Basically I first made some code to do mergesort on a list of numbers. Worked like a champ. Then I said, what the heck, why not do a mergesort on an array of structs, this is where it gets a little funky. While the first sort of the data works fine it goes to the number sort and starts to screw up. It'll sort the numbers but mix up the data in the fields! I don't have a clue as to what causes the mix up, anyone got any ideas as to what is causing this? [QUOTE]example of messing … |
+0 forum
1 | ||

Hi! I'm writing the mergesort algorithm, theoretically everything is fine in it but when the function gets to call itself the program crashes. I belive that I'm doing something worng when I pass the vector<int> as a parameter to the function. [B]procedure mergesort(T[1 .. n]) if n is small then insert(T) else arrays U[1 .. n div 2], V[1 .. (n+1) div 2] U <- T[1 .. n div 2] V <- T[1 + (n div 2) .. n] mergesort(U); mergesort(V) merge(T, U, V)[/B] [CODE] void mergeSort(vector<int>& mass){ if(mass.size() <= 16) sort(mass.begin(),mass.end()); else { vector<int> u,v; int size1,size2; size1 = … |
+0 forum
3 |

The End.