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 a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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