write a c++ program that will sort the food orders using Mergesort and to report the efficiency of the algorithm

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

write a c++ program that will sort the food orders using Mergesort and to report the efficiency of the algorithm

• Auto-generate the order ids randomly. You may use a random function to generate the
order ids. The order id takes the form of: FD9999 (the number of digits might change
according to the maximum number of orders, n, that is input by the user).
• For each order id, the total cost of the order should also be auto-generated randomly. The
total cost of the order will be in the following format: RM999.99.
• Sort the orders using Mergesort according to the order ids.
• Display the list of the unsorted orders and the corresponding total cost of the order (if this
option is selected by the user)
Display the list of the sorted orders and the corresponding total cost of the order (if this
option is selected by the user)
• Display the running time of the sorting algorithm.
You are required to:
a. Implement the scenario above using C/C++ programming language. Do apply the
techniques for good programming practices.
b. Sample Input: <User will input the number of order ids, n, to generate and sort>
Sample Output (Note: ii and iii can be in the form of a menu option – users can choose this
option if they wish to see the values):
i. <time taken to perform the sorting>
ii. <all the unsorted order ids and the corresponding total order cost that were
generated >
iii.
<all the sorted order ids and the corresponding total order cost that were generated>
Transcribed Image Text:• Auto-generate the order ids randomly. You may use a random function to generate the order ids. The order id takes the form of: FD9999 (the number of digits might change according to the maximum number of orders, n, that is input by the user). • For each order id, the total cost of the order should also be auto-generated randomly. The total cost of the order will be in the following format: RM999.99. • Sort the orders using Mergesort according to the order ids. • Display the list of the unsorted orders and the corresponding total cost of the order (if this option is selected by the user) Display the list of the sorted orders and the corresponding total cost of the order (if this option is selected by the user) • Display the running time of the sorting algorithm. You are required to: a. Implement the scenario above using C/C++ programming language. Do apply the techniques for good programming practices. b. Sample Input: <User will input the number of order ids, n, to generate and sort> Sample Output (Note: ii and iii can be in the form of a menu option – users can choose this option if they wish to see the values): i. <time taken to perform the sorting> ii. <all the unsorted order ids and the corresponding total order cost that were generated > iii. <all the sorted order ids and the corresponding total order cost that were generated>
In your report:
c. Write a pseudocode for your solution above. Do ensure that the pseudocode models the
entire logical flow of your program.
d. Illustrate the growth of the algorithm by:
i. providing a table that reports the growth of the sorting algorithm in the
implementation above; and
ii. plot a graph to illustrate the growth of the sorting algorithm.
To illustrate the growth of your sorting algorithm, run the program with at least the
following n values (n represents the number of order ids that was generated): 1,000; 5,000;
32,000; 512,000; 1,000,000. The growth of the algorithm is typically measured in
millisecond (ms) or microsecond (us) or nanosecond (ns).
The growth rate of your sorting algorithm may vary due to your processor speed, memory
capacity and etc. Therefore, to illustrate the consistency of the growth rate of your program,
you will need to perform and report a minimum of 5 trial runs on each of the n values. You
may then take the average of the running time for plotting the graph and for the discussion
in the section below.
e. Based on the growth rate for various n values above, your Team Lead has asked you to
write a detailed justification of the performance of the Mergesort algorithm. Your
justification could focus on your observation of (but not limited to) the performance of the
algorithm with various n values and why (your observation should be supported by
evidence of wider reading). Your Team Lead has also asked you to reflect on whether there
are sorting algorithms that could potentially perform better than the Mergesort algorithm.
Provide and justify your recommendation. You should justify your answers with evidence
from your implementation and from other scholarly resources that you have referred to. Be
sure to cite and reference your sources accurately and using the correct referencing
standards.
Transcribed Image Text:In your report: c. Write a pseudocode for your solution above. Do ensure that the pseudocode models the entire logical flow of your program. d. Illustrate the growth of the algorithm by: i. providing a table that reports the growth of the sorting algorithm in the implementation above; and ii. plot a graph to illustrate the growth of the sorting algorithm. To illustrate the growth of your sorting algorithm, run the program with at least the following n values (n represents the number of order ids that was generated): 1,000; 5,000; 32,000; 512,000; 1,000,000. The growth of the algorithm is typically measured in millisecond (ms) or microsecond (us) or nanosecond (ns). The growth rate of your sorting algorithm may vary due to your processor speed, memory capacity and etc. Therefore, to illustrate the consistency of the growth rate of your program, you will need to perform and report a minimum of 5 trial runs on each of the n values. You may then take the average of the running time for plotting the graph and for the discussion in the section below. e. Based on the growth rate for various n values above, your Team Lead has asked you to write a detailed justification of the performance of the Mergesort algorithm. Your justification could focus on your observation of (but not limited to) the performance of the algorithm with various n values and why (your observation should be supported by evidence of wider reading). Your Team Lead has also asked you to reflect on whether there are sorting algorithms that could potentially perform better than the Mergesort algorithm. Provide and justify your recommendation. You should justify your answers with evidence from your implementation and from other scholarly resources that you have referred to. Be sure to cite and reference your sources accurately and using the correct referencing standards.
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education