Performs a merge sort on 2 number sequences

Assignment Help C/C++ Programming
Reference no: EM13546357

Q2. Write a C program Sort.c that performs a merge sort on 2 number sequences produced by the program in Q1. Sort.c should spawn 2 processes and each of the children processes would exec() the Gen program to produce a sequence. Sort.c should also specify the filenames for the number sequences when spawning the children processes. The parent process should then wait for the termination of the children processes and perform a merge sort on the 2 data files. The final sorted sequence is written to the file "Sort.out". 

The algorithm for merge sort could be roughly described as 
1. read num1 from datafile1 
2. read num2 from datafile2 
3. write the smaller between num1 and num2 to output 
4. "refill" num1 or num2 according to which one has been 
outputted in step(3). 
5. repeat (3) and (4) until both files are exhausted. 

Reference no: EM13546357

Questions Cloud

Prepare the entry to record the final distribution of cash : Prepare the entry to allocate Tyler's debit balance to Mangold and Otis - prepare the entry to record the final distribution of cash.
What is the velocity of given mass after the collision : a block of mass M=46 kg slides down a frictionless inclined plane and collides elastically with another block of mass m=25.0 kg. what is the velocity of m after the collision
Market value of the asset at that date : How close do you suppose the December 31, 2003 balance sheet value of each asset is to the market value of the asset at that date?
Find with what speed was shrapnel ejected by the explosion : A skyrocket explodes just as it reaches the top of its trajectory at a height 1.31 km above the ground. With what speed was the shrapnel ejected by the explosion
Performs a merge sort on 2 number sequences : Write a C program Sort.c that performs a merge sort on 2 number sequences produced by the program in Q1. Sort.c should spawn 2 processes and each of the children processes would exec() the Gen program to produce a sequence.
Compute the manufacturing cost per bd : Compute the manufacturing cost per BD - What do you predict will be the total cost of factory rent and the per unit cost of the factory rent?
What will the buoyant force on the crown be : The density of gold is 19 times that of water. If you take a gold crown weighing 30N and submerge it in water, what will the buoyant force on the crown be
How many volts will appear across the secondary : A transformer consists of a 500 turn primary coil and a 2000 turn secondary coil. if 120v is applied to the primary, how many volts will appear across the secondary
Write a c program generates a ordered sequence of random num : Write a C program Gen.c that generates a ordered sequence of 20 random numbers within a range of 1000 to 9999. The program is invoked by a command line % gen datfile1

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Program on basic arithmetic operation

Two integers must be compared before the arithmetic operation and Subtract the two integers provided the first integer is greater than the second integer, otherwise add the two integers and subtract the second integer from the first integer.

  Assignment 1 boxing amoebadevelop a two dimensional

assignment 1 boxing amoebadevelop a two dimensional interactive game with the following features1.use opengl any

  Demonstrate the construction and output of an array

In fluid mechanics, the Reynolds number (Re) is a dimensionless quantity that is used to help predict similar flow patterns in different fluid flow situations. For example, Reynolds numbers can be computed for different velocities of fluid flow over ..

  How the function delete can be implemented for arrays

Explain in details how the function Delete() can be implemented for arrays to function exactly as it would with lists. Use pseudo code to clarify your explanation.

  Print out the sum of all numbers, the average

Write a program that reads in a list of integer numbers and print out the sum of all numbers, the average, the lowest and the highest value entered. The first input number indicates how many numbers the program is attempting to read

  We base our need to implement composition upon

What criterion, or criteria, should be used to include objects of a class as data members of another class? In other words, what should we base our need to implement composition upon?

  Implement a class address

A theater seating chart is implemented as a two-dimensional array of ticket prices like presented below. Write a program that prompts the users to pick either a seat or a price. Mark sold seats by changing the price to zero.

  Determine an appropriate functional decomposition

Create structure charts for a problem and determine an appropriate functional decomposition or top-down design from a structure chart

  Write an accessor function to get the angle

Write a friend function to compare the area of a rectangle with sides 12 and 8 to the area of a parallelogram with sides 14 and 18 and an acute angle of 40 degrees. Test it in main, and check the answer by hand.

  The user enter the total rainfall for each of 12 months

Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display:the total rainfall for the year,the average monthly rainfall,and the months w..

  Write a c program that reads n positive numbers from the

write a c program that reads n positive numbers from the keyboard calculates and displays the following information.a.

  You will create a linked list module

You will create a linked list module that exactly meets the specifications given in the supplied header (.h) file. The playlist program must accept a filename on the command line (argv).

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