Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

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

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92251369

Have any Question?


Related Questions in Programming Language

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As