Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing a vector of integers to two separate functions but altered data gets passed to the other functions
    primarykey
    data
    text
    <p>*Update: Resolved did a deep copy, thanks for the help</p> <p>I am using a vector of integers to simulate some sorting algorithms, when i insert numbers to the test vector and shuffle the order and pass it to a sorting function, if i pass the void sorting functions the same vector, when the vector gets sorted in a function previously passed the newly sorted vector gets passed to the function following it because it is already sorted i cannot show the sorting process. For example in my following code</p> <pre><code>@SuppressWarnings("unchecked") // Removes error given at when adding elems to int_vec public static void CreateVec (int array_len) { Vector &lt;Integer&gt; int_vec = new Vector(array_len); int temp_int = 1; int low_bound = 0; int high_bound = array_len - 1; for(int i = 0; i&lt;array_len; i++) { int_vec.addElement(temp_int);// creating a vec in respect to array len temp_int ++; } Collections.shuffle(int_vec); System.out.println("OG vec: " + int_vec); //original vector (random order) BubbleSort(int_vec,array_len); //sending int_vec to bubble sort InsertionSort(int_vec,array_len); // retrieves newly sorted vector sorted from BubbleSort (problem) } </code></pre> <p>So my question follows, how can i keep sending my test vector (int_vec) with the randomly ordered elements rather than it keep sending the sorted vector to the other algorithms. Note i correctly implemented these algorithms, it works if i comment out the function calls to the other algorithm functions.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload