Our instructor asked us to create our own Merge Sort Algorithm before showing us how to make one. He explained how it works and this is what I came up. It works but there is a bug, my code catches garbage number. First garbage number occurs at vector/array size is 7 then next is 11 ..
Category : array-merge
I have a collection of vectors and want to merge them into one big vector. I’ve written a function that takes in a list of integers, which all represent a different vector(e.g. v1 and v2), and returns a vector containing all the elements of the desired vectors. std::vector<int> mergeVectors(std::vector<unsigned int> indices) { std::vector<int> v1 = ..
This is my code,I’ve run an iterator i in the first array and swapped each element with the min_element in array 2 and then called sort on the second array.But the output isn’t sorted at all.I dont know whats wrong with this approach. #include<bits/stdc++.h> class Solution{ public: void swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp; ..
Recent Comments