Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hw9starter.cpp Parts.txt P-28690 A 45 19.34 P-34050 B 16 18.99 P-11245 D 45 0.93 P-27969 C 2 12.52 P-34512 B 2 69.17 P-20491 B 32

image text in transcribed
image text in transcribed
hw9starter.cpp
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Parts.txt
P-28690 A 45 19.34
P-34050 B 16 18.99
P-11245 D 45 0.93
P-27969 C 2 12.52
P-34512 B 2 69.17
P-20491 B 32 43.2
P-14518 D 9 5.56
P-17243 A 7 69.19
P-19780 A 33 44.66
P-28061 A 38 117.29
P-22844 D 10 0.5
P-23975 D 5 6.84
P-37542 B 39 26.43
P-29182 A 11 26.83
P-34554 A 33 11.27
For this homework, write a program that implements searching and sorting functionality on the data contained in the parts.txt file located on Canvas under Week 10 homework. Each row of this file is comprised of four related pieces of data: 1) part number; 2) class; 3) on-hand inventory (number of parts); and 4) cost. Use the starter code hw9starter.cpp, also listed under Week 10 homework, to read in the parts.txt file. Compile the starter code and make sure the program generates the message "Parts file read successfully!" If it doesn't, double check where your copy of the file resides and make sure the function readFile0 is reading from that location. . After the file has been read in, we will be working with the string vector vecPartNum only. The remaining three vectors may be ignored. In your program, implement the following functions: 1. mergeSort0 The pseudocode for this sort function is discussed in Lecture 19 from Wed. 10/25. Note that mergeSort0 requires an additional function merge0 2. linearSearch The code for a linear sequential search with early exit is discussed in Lecture 18 from Mon. 10/23. You may also modify the linearSearch0 function detailed in Chapter 8 (pp. 465) to work with a string vector 3. binarySearch0 The code for a binary search function is given in the course text in Chapter 8 (pp. 497). There are already function prototypes and stubs given in the starter code. If you do not have the course text, then implement your own version of each function in order to perform a linear sequential search with early exit and a binary search on a sorted string vector. Make sure that each search function displays the number of loops performed during the respective search. Implement a user-input loop in your code to continually prompt the user for a search key until a sentinel value of your choice is entered. Perform a binary and linear search of the vecPartNum string vector using the user specified key. Make sure to report the index where a search key was found, or that it was not found. A sample program exec ution is shown in the figure on the next page. For full credit on this assignment, make sure to include: 1. Fully implemented mergeSort0, merge0, linearSearch0, and binarySearch0 functions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions