Computer Science, asked by jew15, 7 months ago

QUESTION 14
The process of combining/merging of the two sorted arrays into the third array in sorted form (without
sorting) without any duplicate element is known as merge sort.
For example : Array A[] = {2, 3, 5, 11) and array BU1=2, 5, 7, 11, 14, 15), then the merge array
CD =(2, 3, 5, 7, 11, 14, 15).
Design a class MergeSort to merge the two sorted arrays into the third array in sorted form without any
duplicates. Some of the data members and member functions of the class are given below:
Class name : MergeSort
Data members/instance variables :
A[J. BIL : arrays to store sorted integers.
C: to store merged array in sorted form.
MN : integers to store the actual sizes of array Aland BO.
Member functions/methods :
MergeSort(int nx, int ny ) : parameterized constructor to assign M=nx, N=ny and also creates
the integer arrays All of size M and B[ 1 of size N.
void inpdata(): to input and store the sorted integers into the arrays All of size
M and B[] of size N.
void merge_sort(): to merge the two sorted arrays Al/ and B[] into C[ such that
the elements of Al and B[] appears in sorted form into C[l
without any duplicate elements. However, arrays Al) and
B[] can have common elements (do not sort array C[ ).
void DispArray(); to print the array elements.
(a) Specify the class MergeSort giving the details of the constructor and void inpdata(), void
merge_sort and void DispArray(). Define a main() function to create object and call the methods
to enable the task.
(b) State, why a constructor does not require any return type (or data type) during its definition?

Answers

Answered by fayaz48
0

Answer:

Explanation: Merge sort uses divide and conquer in order to sort a given array. This is because it divides the array into two halves and applies merge sort algorithm to each half individually after which the two sorted halves are merged together.

please mark it as a brainlist answer

Similar questions