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

  Identify where each security application or countermeasure

Briefly describe each of the listed network security applications and security countermeasures. Identify where each security application or countermeasure is located within the seven domains of a typical IT infrastructure.

  Write a query to confirm that the changes have taken effect

write the SQL command to add a new redo log group with two members

  Write iterative program which finds largest number

Write the iterative program which finds largest number of McNuggets which cannot be bought in exact quantity. Your program must print the answer in the following format.

  Create a solution that allows manager to enter up food items

Create an object-oriented solution that allows the restaurant manager to enter up to 10 food items. An error message must display if the manager tries to enter more than 10 food items.

  During the middle ages

During the Middle Ages, to determine the successor to the throne of France, the French used the Salic law. It is formulated as follows: the next to the throne is the living male descendant of the most direct male royal. Male royal here means that ..

  Write program that will allow two users to play tic-tac-toe

BIS 320- Write a program that will allow two users to play tic-tac-toe. The program should ask for moves alternatively from player X and player O.

  Program-dynamically check store-s inventory-central office

You are the outside consultant to large chain of grocery stores. Store's management would like to dynamically check store's inventory from central office.

  Program to enter answer to a math problem

Write a program which ask student to enter an answer to a math problem. The user must enter two values, one at time, and then ask for answer.

  Logic for a program that allows a user to enter 15 numbers

Design the logic for a program that allows a user to enter 15 numbers, then displays each number and its difference from the numeric average of the numbers entered

  Calculate and display the weight of the object on that body

Calculate and display the weight (N) of the object on that body - Objective Become familiar with the C++ compiler/environment that you plan to use for the programming assignments in this class

  Recursive method to replace all occurrences of character

Write down the program which uses the recursive method to replace all occurrences of character with another character in given sentence.

  Create application to allow user to enter a five-dgit number

Create an application that allows the user to enter a five-digit credit card number; assume that the fifth digit is the check digit. The application should use the method.

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