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

  Develop a functional c program that implements a design

Develop a functional C program that implements a design and create a C program that declares and uses strings.

  What is unixs main philosophy

Describe and critically evaluate the similarities between the Windows and Unix operating systems - what are some of the advantages of running UNIX and what is UNIX's main philosophy

  Display the property tax for n property owners

Write a java application that calculates and displays the property tax for N property owners. N should be declared as a constant and it should be equal to the largest digit of your student ID number

  Create math sorting game using visual basic studio

using visual basic studio 2010, Create math sorting game. Random number between 1 and 99 will be generated and displayed to the user.

  Describe issues-web site designers when adding multimedia

Describe some of the issues web site designers must consider when adding multimedia to a web site. Consider issues such as bandwidth, server load, or others you consider to be important. Please provide references.

  Wite a program to display a countdown timer

Wite a program to display a countdown timer which displays minutes and seconds as the timer counts down from the starting point. At runtime, the user should be asked how many minutes they want the timer to countdown.

  Create a class named account with data fields

Create a class named Account with data fields for an account number, payment amount and balance as well as the appropriate set and get methods. Include a constructor method that contains no arguments.

  Determine if a word is a palindrome

Determine if a word is a palindrome. Using a doubly link list read in a word character by character Store each character in its own node. Keep a counter of the number of characters that make up the word.

  What happens when a class with parameterized

What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?

  Decrypt all entries of username variable

Need a another cgi file to decrypt all entries of ' username ' variable and restore it to original plain/text, it should be start restoring the inputs to original text the cgi file

  Write a web application which will give report of balance

Write a web application which will provide a report of the balance held in the visitor's account during the past several months.

  Fortran-77 to sort an array of numbers entered

Write a program in Fortran-77 to sort an array of numbers entered from the keyboard and then using binary search, search for a number in the array.

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