1. Provide a function which takes two lists and shuffles them. This shuffling should go in an alternating way. First node from first list, second node front second list, third node front first list, 4th node front second list……. So on. If length of list 1 is greater than size of list 2, start again from the first node and follow the same procedure.
#include<iostream>
using namespace std;
void shuffle(int arr1[], int arr2[], int m, int n){
int k = m +n;
int arr3[k];
int x = 0;
int a = 0;
for(int i=0; i<k; i++){
arr3[i] = arr1[x];
arr3[i+1] = arr2[a];
x++;
a++;
}
for(int i=0; i<k; i++){
cout<<arr3[i]<<" ";
}
}
int main(){
}
Comments
Leave a comment