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 that asks the user to enter up to 100 integer score

Write a C program that asks the user to enter up to 100 integer scores, which are to be stored in an array. (You should allow the user to terminate input prior to entering all 100 scores.) The program should then display all the scores, ten per line,..

  Battleship redux

Game Battleship is back and better than ever. Instead of hacking everything together in C, you will instead leverage C++ and all of your newly gained object oriented programming knowledge to construct a much cleaner end product.

  Ohio phonebook has gotten mixed up

In an accident, the Ohio phonebook has gotten mixed up. The names are now really out of order. You and your enthusiastic, but naive, assistant Carl must fix the problem. No one can use the phonebook while you are sorting it, so every extra second of ..

  Write c++ program that reads in the average monthly rainfall

Write a C++ program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months

  Ansi-c program which allows the user to play a game

Your task is to write an ANSI-C program which allows the user to play a game. This will require I/O from both the user and from ?les.

  Calculates different formulas that converge to the number pi

Write a C program (Care should be taken not to use extensions of C + + language in your work ) that calculates different formulas that converge to the number  pi,  to compare the speed of convergence of these formulas. Each form will be calculated by..

  Develop the implementation file student.cpp

The data fields have self explanatory identifiers, and their meaning should be clear from the Introduction.

  The staffs need a program that can determine

The staffs need a program that can determine whether children have been naughty or nice. individual data files(can be any name) for each childred are available that consist of 368(365+3)integer number each.

  You are to implement a simple file system with login

you are to implement a simple file system with login authentication and access control. specificallyconstruct a

  Loops in what ways are the initialization repetition test

in what ways are the initialization repetition test and update steps alike for a sentinel-controlled loop and an

  Optimization is to add a sorting algorithm

The second optimization is to add a sorting algorithm. Each time you add an item to the array (from disk or from keyboard), you call a function called SortMyArray(), which use the bubble sorting algorithm to sort the array in the ascending order, ..

  Design a program that asks for the number of fat grams

Starting out with Programming logic and design 3rd Author Tony Gaddis - Pg 279, PE 3 Fat Grams Calculator

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