Implement the mergetwosortedseries function

Assignment Help Programming Languages
Reference no: EM131442622

Programming Assignment: Basics of Pointers

Purpose: Instead of using vectors, we want to have a parallel implementation of the merge-sort algorithm by using pointers, recursion, and dynamic memory allocation. It is intended to give you exposure to the use of pointers and dynamic memory allocation.

Step 1: Implement the mergeTwoSortedSeries function.

Given a series of sizeOfA sorted values starting at the memory location pointed to by ptrA and a series of sizeOfB sorted values starting at the memory location pointed to by ptrB, implement the following function that can merge the values in these two separate sorted series into a single sorted series of values starting at the memory location pointed to by ptrC.

Step 2: Test the implementation of the mergeTwoSortedSeries function.

Create a loop in your main function to repeatedly do the following test on the mergeTwoSortedSeries function until the user enters a negative value for n1 or n2 in the input:

Ask the user to enter two non-negative integers n1 and n2. Dynamically allocate three separate chunks of memory storages that can hold n1, n2, and (n1+n2) double values respectively. Then use a loop to ask the user to enter a series of n1 sorted values and store them in the chunk that can hold n1 values. Similarly use a loop to ask the user to enter a series of n2 sorted values and store them in the chunk that can hold n2 values. Then call the mergeTwoSortedSeries function appropriately to merge the two series of values into the one sorted series of values stored in the chunk that can hold (n1+n2) values. Output the contents of this final sorted series to verify the result. Then appropriately call delete[ ] to free these two chucks of dynamically allocated memory

You have to make sure that mergeTwoSortedSeries is working perfectly (by doing extensive testing in Step 2) before you proceed to Step 3 below.

Step 3: Implement the mergeSort function.

Implement the following recursive merge sort function by using the mergeTwoSortedSeries function implemented in Step#1.

Step 4: Test the implementation of the mergeSort function.

Create a loop in your main function to repeatedly do the following test on the mergeSort function until the user enters a negative value for n in the input:

Ask the user to enter one non-negative integer n. Dynamically allocate a chunk of memory storage that can hold n double values. Use a loop to ask the user to enter a series of n values and store them in the chunk of memory you just allocated.

Then call the mergeSort function appropriately to sort the series of numbers into one sorted series.

Then print out the contents of this final sorted series to verify the result.

Then appropriately call delete[ ] to free the chuck of dynamically allocated memory.

Attachment:- Assignment.rar

Reference no: EM131442622

Questions Cloud

What kind of sort you would use for a given situation : Discuss when you would use a sort and what kind of sort you would use for a given situation. Reply to others with support for or arguments against their proposal of sort usage and implementation.
What is the test statistic for sample : The contractor took 27 water samples and found an average pH of 6.3 with a sample standard deviation of 1.86. What is the test statistic for this sample?
American association of building contractors : A report issued by the American Association of Building Contractors indicates that 40% of all home buyers will do some remodeling to their home within the first 5 years of home ownership. Assuming this is true, use the binomial distribution table ..
Draw a use case model for the information system : Draw a use case model for the information system. Write brief Use Case description for each Use Case in the diagram. Write one fully developed Use Case description for one of the important Use Cases identified.
Implement the mergetwosortedseries function : Implement the mergeTwoSortedSeries function. Given a series of sizeOfA sorted values starting at the memory location pointed to by ptrA and a series of sizeOfB sorted values starting at the memory location pointed to by ptrB
Combine the statement appropriately : Rama has three brothers.All of them are in abroad(combine appropriately)
How do magnus et al define a cover for their purposes : How do Magnus et al. define a cover for their purposes? How do they define "canonical," and on what does the definition of "canonical" depend? Provide an example of a canonical song you are familiar with that does NOT appear in the reading.
Percentage of firms in city : The 2011 gross sales of all firms in a large city have a mean of $2.3 million and a standard deviation of $0.6 million Using the Chebysev's theorem, find at least what percentage of firms in this city had 2011 gross sales of $1.1 to $3.5 million.
Describe your plan of study : Describe your plan of study

Reviews

len1442622

3/28/2017 2:25:16 AM

Peer discussion of code shown on a screen or board is acceptable for explanation of ideas and for debugging purpose. Such discussion may help to cultivate an open learning environment in the class, but you should carefully read the guidelines below to avoid any dishonest behavior and never step over the guidelines explicitly described. Never use any code (i.e. C++ statements, segments of a program or an entire program) written by others (except for examples in our textbooks or reading): Any copy-and-paste of code from other people’s programs or from websites is viewed as cheating and you will get 0 points for the assignment.

Write a Review

Programming Languages Questions & Answers

  Write class postfixevaluator to evaluate postfix expression

Write a class PostFixEvaluator that evaluates postfix expression such as 6 2 + 5 * 8 4 / -. Program must read a postfix expression consisting of digits and operators into a StringBuffer.

  Compute service charge customer owes for writing bad check

Create the output and sketch the flowchart or write pseudocode for program which computes service charge a customer owes for writing bad check.

  Modularizing code and sorting techniques

Modularizing Code and Sorting Techniques-Imagine you are a part of a team that is tasked with writing a mobile application (app) that will allow users to send pictures to their friends

  Super call for constructor to allot value of attribute

We have given a super call, which does some work of constructor. Your code must complete constructor by allotting the value of g to gpa attribute.

  Defining method dashedline with one parameter

Write a definition of method dashedLine, with one parameter, an int .

  Pseudocode for linear search by using clrs3e style

Write pseudocode for linear search by using CLRS3e style used in, which scans through the sequence, looking for v.

  Brief explanations for the solutions in the ms word file

You have a server-side script that cannot handle any ampersands (&) in the form data. Write a function that converts all ampersands in a form field to " and " when the field loses focus (onblur).

  Design bank account class with data members-member functions

Design the Bank Account class with suitable data members and member functions - think of attributes or features of a bank account - think of kind of data (and actions) you require to open account.

  Create the program for iteration control structure

Iteration Control Structure create the program which models worm's behavior - Worm can enter apple when it is in body length of apple.

  Compute the monthly payment on a loan

James wants to buy a motorcycle. Help James compute the monthly payment on a loan, given the loan amount, the annual percentage rate of interest, and the number of monthly payments.

  Assignment on the two-dimensional array sales

Use a two-dimensional array to solve the following problem: A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passesin a slip for each type of product sold. Each slip contains the follo..

  How to change sas system options

How to change SAS system options

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd