Ask
your own question, for FREE!
Computer Science
15 Online
Write a program that, given two sorted arrays of N int values, prints all elements that appear in both arrays, in sorted order. The running time of your program should be proportional to N in the worst case
Still Need Help?
Join the QuestionCove community and study together with friends!
merge sort,for example,there are two array, a={1,3,5},b={2,4,6},give two index ia=0,ib=0; each time you compare a[ia] and b[ib],get the smaller one and let the index(ia or ib) increase,when one of the array was in the end,you check whether the other array is in the end,if not get the remained. may you can google the merge sort.
lena is length of a,lenb is length of b; ia=0,ib=0; while(ia<lena&&ib<lenb) {...} while(ia<lena) {get(a[ia]);ib++;} while(ib<lenb) {get(b[ib]);ib++;}
Can't find your answer?
Make a FREE account and ask your own questions, OR help others and earn volunteer hours!
Join our real-time social learning platform and learn together with your friends!
Join our real-time social learning platform and learn together with your friends!
Latest Questions
Aubree:
Guys, what does love feel like? I've been getting a tight chest and when I talk to him my heart rate hangs out around 100-120 beats per min, and when he doe
thereneelg:
ok... anyone have advice?? ...I did Choir all throughout Middle school and have ALWAYS been put in Soprano those three years.
kamariana:
The Byzantine Procopius is known for (5 points) reconquering much of the old Roma
chuckD:
hellp!!! what does it mean to describe a scientist as skeptical Why is sceptical
DoltonCarlee:
So like do y'all know anything about the first world war?
thehearken:
anyone know how to explain this so its easier for me to understand? b(1)=2, b(n)=
4 hours ago
8 Replies
1 Medal
1 day ago
6 Replies
1 Medal
2 days ago
0 Replies
0 Medals
2 days ago
2 Replies
1 Medal
1 day ago
2 Replies
0 Medals
1 day ago
5 Replies
2 Medals