Explore BrainMass
Share

Javascript: merge two sorted arrays into one sorted array

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

I'm trying to write a function merge that take two sorted arrays as parameters. The function should create a new array whose size is the sum of the two parameter array lengths. The merge function should then fill in the new array with elements from the two parameters such that the two sorted arrays are merged into one sorted array.

I'm creating the function in JavaScript and calling it in a HTML file.

© BrainMass Inc. brainmass.com October 17, 2018, 12:42 am ad1c9bdddf
https://brainmass.com/computer-science/javascript/javascript-merge-two-sorted-arrays-into-one-sorted-array-306134

Attachments

Solution Preview

Please find attached 306134.zip that contains two files ...

Solution Summary

A function to print the argument array content neatly has also been added in the html file, and two individual arrays are also printed apart from the merged array.

$2.19
Similar Posting

Create a sorting algorithm in JavaScript

I'm trying to create a sorting algorithm in JavaScript and call it in a HTML page.

View Full Posting Details