Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Using Arrays Vs. Vectors?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I have a project where I must use quick sort,bubble sort, and merge sort. I have the following code:
void bubbleSort(int a[], int n);
void Merge( vector <int>& list, int low, int mid, int low1, int high);
void MergeSort(vector<int>& list, int low, int high);
void Quicksort(vector <int> & list, int lower, int upper);
void Partition ( vector <int> &list, int lo, int hi, int & pivot);

I have the numbers in an Array called &quot;Array&quot;. The bubblesort works : bubbleSort(Array,limit);

Any suggestions on what I need to do to get the array to work as a vector for the other sorts? I tried setting a vactor : vector new = Array;

That didnt work. Any suggestions would be greatly appreciated.

Thanks,
WZiggy
<jgardne@stedwards.edu>
 
I think that you should be sending the address of the array into this function
if you called the array Array then I think it should look something like this
void Merge( vector <int>& Array, int low, int mid, int low1, int high);
I think the statement vector <int>& Array is declaring Array as a vector.
[sig][/sig]
 
yes, the statement vector <int> & array
declares an stl vector, which is very different from an array. You need to look at some stl documentation on how to either convert this to an array or re-write your searches using vectors, which I believe support random access, much like arrays.


Mike B.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top