CS204 Advanced ProgrammingSpring 2019Homework 2 Formula 1 Qualifier Ranking with Linked ListsIn this homework, you are asked to implement a program that calculates the starting positions of Formula 1 drivers. This program must use a Linked List structure to store names of the drivers and their best lap times in a sorted fashion. Driver names and lap times are going to be read from a text file. The program details will be explained in the subsequent sections.The Data Structure to be UsedIn this homework, you must represent drivers and their best lap times as a linked list (regular one-way linked list). As a result, you are going to implement one node type that stores a list item with the drivers name and his best lap time recorded. You are not allowed to use arrays, vectors and similar containers (including extra files) in this homework; all data must be stored and processed within the linked list.The Program FlowYour program is going to start with getting an input from the user regarding the name of the file that contains qualification information. After getting the name of the file, the program must check whether the file has opened correctly. If not, another file name will be required from the user until a correct file name is entered.After successfully opening the file, your program is going to start storing the best lap times of each driver by reading the file line by line. A sample file is shown below:Each line in the file contains two pieces of information regarding a lap. The first word in the file is going to be the name of the driver. And the second one is going to be the lap time in milliseconds (to be read as positive integer). As seen in the example above, there can be any number of spaces between the name and the lap time of the driver. You can assume the file contains correct inputs so no input checks are required for the content of the file. As you see from the sample file above, a particular driver can be listed several times with various lap times.The driver with the smallest lap time is going to start the race in the first place and driver with the largest lap time will start the race in the last place, and other drivers will be placed in the in the ascending order of their best lap times. If two or more drivers record the same time, first one examined by the program is going to start the race ahead.These rules require your program to maintain the linked list in an ascending sorted fashion according to best (smallest) lap times of the drivers. In the list, a driver is going to be represented by a single node. After reading a line from the file, you have basically two options; either that driver exists in the linked list or not. If currently there is no node with a drivers name in the list, then a new node needs to be created and added to the linked list in a proper position to keep it sorted. If a node with that drivers name exists in the list, and the existing best lap time stored in that node is larger than the currently read one, your program is going to update that drivers lap time of the existing node. After that, the position of the drivers node may change in the list since you have to keep the list always sorted.Fernando_Alonso 75402Kimi_Raikkonen 75173Ayrton_Senna 70560Ayrton_Senna 77484James_Hunt 75308Fernando_Alonso 88005Fernando_Alonso 70655James_Hunt 88770Ayrton_Senna 75622James_Hunt 84596James_Hunt 82232Sebastian_Vettel 84514Fernando_Alonso 93280James_Hunt 92556Ayrton_Senna 87909Ayrton_Senna 97530Fernando_Alonso 82716Ayrton_Senna 97755James_Hunt 97733Ayrton_Senna 88975Ayrton_Senna 86534Fernando_Alonso 95724James_Hunt 93512Kimi_Raikkonen 78518Fernando_Alonso 84235Kimi_Raikkonen 77317Sebastian_Vettel 88160Ayrton_Senna 76489Fernando_Alonso 92164Sebastian_Vettel 78635It is strictly forbidden the process the input file more than once. That means, do NOT even think of finding the smallest lap time of a driver by processing the file for him, rather than updating the linked list after each lap of that driver. And do not forget that you are not allowed to use extra helper containers. Thus, the only way is to do all of the data processing within the linked list. Any attempts to bypass this for the sake of simplicity will be penalized.For each lap completed, your program is going to output who completed the lap in how many milliseconds. Moreover, after each lap, that drivers current personal best lap time and his current position should also be displayed. After the program is finished reading and processing the file, the starting positions of all of the drivers will be displayed on the screen in sorted manner. This latter output is actually the content of the linked list at the end of the program.Sample RunsSample runs are given below, but these are not comprehensive, therefore you have to consider all possible cases to get full mark.The sample input files are provided in the .zip package of this homework.Sample Run 1: t1.txtFernando_Alonso 75402Kimi_Raikkonen 70655Ayrton_Senna 70560Ayrton_Senna 77484James_Hunt 75308Fernando_Alonso 88005Fernando_Alonso 70655James_Hunt 88770Ayrton_Senna 75622James_Hunt 84596James_Hunt 82232Sebastian_Vettel 84514Fernando_Alonso 93280James_Hunt 92556Ayrton_Senna 87909Ayrton_Senna 97530Fernando_Alonso 82716Ayrton_Senna 97755James_Hunt 97733Ayrton_Senna 88975Ayrton_Senna 86534Fernando_Alonso 95724James_Hunt 93512Kimi_Raikkonen 78518Fernando_Alonso 84235Kimi_Raikkonen 77317Sebastian_Vettel 88160Ayrton_Senna 76489Fernando_Alonso 92164Sebastian_Vettel 78635Please enter a file name.t.txtUnable to open file t.txtPlease enter a different file name.t1.txtSuccessfully opened file t1.txt###############################Qualifying Laps:###############################Fernando_Alonso completed the lap in 75402 millisecondsFernando_Alonso: current personal best is 75402; current position is 1Kimi_Raikkonen completed the lap in 70655 millisecondsKimi_Raikkonen: current personal best is 70655; current position is 1Ayrton_Senna completed the lap in 70560 millisecondsAyrton_Senna: current personal best is 70560; current position is 1Ayrton_Senna completed the lap in 77484 millisecondsAyrton_Senna: current personal best is 70560; current position is 1James_Hunt completed the lap in 75308 millisecondsJames_Hunt: current personal best is 75308; current position is 3Fernando_Alonso completed the lap in 88005 millisecondsFernando_Alonso: current personal best is 75402; current position is 4Fernando_Alonso completed the lap in 70655 millisecondsFernando_Alonso: current personal best is 70655; current position is 3James_Hunt completed the lap in 88770 millisecondsJames_Hunt: current personal best is 75308; current position is 4Ayrton_Senna completed the lap in 75622 millisecondsAyrton_Senna: current personal best is 70560; current position is 1James_Hunt completed the lap in 84596 millisecondsJames_Hunt: current personal best is 75308; current position is 4James_Hunt completed the lap in 82232 millisecondsJames_Hunt: current personal best is 75308; current position is 4Sebastian_Vettel completed the lap in 84514 millisecondsSebastian_Vettel: current personal best is 84514; current position is 5Fernando_Alonso completed the lap in 93280 millisecondsFernando_Alonso: current personal best is 70655; current position is 3James_Hunt completed the lap in 92556 millisecondsJames_Hunt: current personal best is 75308; current position is 4Ayrton_Senna completed the lap in 87909 millisecondsAyrton_Senna: current personal best is 70560; current position is 1Ayrton_Senna completed the lap in 97530 millisecondsAyrton_Senna: current personal best is 70560; current position is 1Fernando_Alonso completed the lap in 82716 millisecondsFernando_Alonso: current personal best is 70655; current position is 3Ayrton_Senna completed the lap in 97755 millisecondsAyrton_Senna: current personal best is 70560; current position is 1James_Hunt completed the lap in 97733 millisecondsJames_Hunt: current personal best is 75308; current position is 4Ayrton_Senna completed the lap in 88975 millisecondsAyrton_Senna: current personal best is 70560; current position is 1Ayrton_Senna completed the lap in 86534 millisecondsAyrton_Senna: current personal best is 70560; current position is 1Fernando_Alonso completed the lap in 95724 millisecondsFernando_Alonso: current personal best is 70655; current position is 3James_Hunt completed the lap in 93512 millisecondsJames_Hunt: current personal best is 75308; current position is 4Kimi_Raikkonen completed the lap in 78518 millisecondsKimi_Raikkonen: current personal best is 70655; current position is 2Fernando_Alonso completed the lap in 84235 millisecondsFernando_Alonso: current personal best is 70655; current position is 3Kimi_Raikkonen completed the lap in 77317 millisecondsKimi_Raikkonen: current personal best is 70655; current position is 2Sebastian_Vettel completed the lap in 88160 millisecondsSebastian_Vettel: current personal best is 84514; current position is 5Ayrton_Senna completed the lap in 76489 millisecondsAyrton_Senna: current personal best is 70560; current position is 1Fernando_Alonso completed the lap in 92164 millisecondsFernando_Alonso: current personal best is 70655; current position is 3Sebastian_Vettel completed the lap in 78635 millisecondsSebastian_Vettel: current personal best is 78635; current position is 5###############################Results:###############################1. Ayrton_Senna 705602. Kimi_Raikkonen 706553. Fernando_Alonso 706554. James_Hunt 753085. Sebastian_Vettel 78635Sample Run 2: t2.txtPlease enter a file name.t2.txtSuccessfully opened file t2.txt###############################Qualifying Laps:###############################Michael_Schumacher completed the lap in 78718 millisecondsMichael_Schumacher: current personal best is 78718; current position is 1Alain_Prost completed the lap in 85729 millisecondsAlain_Prost: current personal best is 85729; current position is 2Ayrton_Senna completed the lap in 82385 millisecondsAyrton_Senna: current personal best is 82385; current position is 2Juan_Manuel_Fangio completed the lap in 82045 millisecondsJuan_Manuel_Fangio: current personal best is 82045; current position is 2Juan_Manuel_Fangio completed the lap in 88185 millisecondsJuan_Manuel_Fangio: current personal best is 82045; current position is 2James_Hunt completed the lap in 73638 millisecondsJames_Hunt: current personal best is 73638; current position is 1Juan_Manuel_Fangio completed the lap in 93603 millisecondsJuan_Manuel_Fangio: current personal best is 82045; current position is 3Alain_Prost completed the lap in 89437 millisecondsAlain_Prost: current personal best is 85729; current position is 5Ayrton_Senna completed the lap in 77191 millisecondsAyrton_Senna: current personal best is 77191; current position is 2James_Hunt completed the lap in 80564 millisecondsJames_Hunt: current personal best is 73638; current position is 1Juan_Manuel_Fangio completed the lap in 81698 millisecondsJuan_Manuel_Fangio: current personal best is 81698; current position is 4Michael_Schumacher 78718Alain_Prost 85729Ayrton_Senna 82385Juan_Manuel_Fangio 82045Juan_Manuel_Fangio 88185James_Hunt 73638Juan_Manuel_Fangio 93603Alain_Prost 89437Ayrton_Senna 77191James_Hunt 80564Juan_Manuel_Fangio 81698James_Hunt 73062Ayrton_Senna 74972Niki_Lauda 72928Alain_Prost 91068James_Hunt 87926Alain_Prost 93782Michael_Schumacher 80827Ayrton_Senna 89408Ayrton_Senna 89486James_Hunt completed the lap in 73062 millisecondsJames_Hunt: current personal best is 73062; current position is 1Ayrton_Senna completed the lap in 74972 millisecondsAyrton_Senna: current personal best is 74972; current position is 2Niki_Lauda completed the lap in 72928 millisecondsNiki_Lauda: current personal best is 72928; current position is 1Alain_Prost completed the lap in 91068 millisecondsAlain_Prost: current personal best is 85729; current position is 6James_Hunt completed the lap in 87926 millisecondsJames_Hunt: current personal best is 73062; current position is 2Alain_Prost completed the lap in 93782 millisecondsAlain_Prost: current personal best is 85729; current position is 6Michael_Schumacher completed the lap in 80827 millisecondsMichael_Schumacher: current personal best is 78718; current position is 4Ayrton_Senna completed the lap in 89408 millisecondsAyrton_Senna: current personal best is 74972; current position is 3Ayrton_Senna completed the lap in 89486 millisecondsAyrton_Senna: current personal best is 74972; current position is 3###############################Results:###############################1. Niki_Lauda 729282. James_Hunt 730623. Ayrton_Senna 749724. Michael_Schumacher 787185. Juan_Manuel_Fangio 816986. Alain_Prost 85729Sample Run 3: t3.txtPlease enter a file name.t3.txtSuccessfully opened file t3.txtFernando_Alonso 84030James_Hunt 88197Kimi_Raikkonen 79282Ayrton_Senna 92750Kimi_Raikkonen 77201Kimi_Raikkonen 82502Sebastian_Vettel 81741Sebastian_Vettel 73966James_Hunt 80994Ayrton_Senna 71047James_Hunt 80649James_Hunt 71841Ayrton_Senna 99303Fernando_Alonso 95106Kimi_Raikkonen 97888Sebastian_Vettel 90617Ayrton_Senna 81740Ayrton_Senna 82619James_Hunt 75975Sebastian_Vettel 99538James_Hunt 70664Kimi_Raikkonen 99347Sebastian_Vettel 97309Fernando_Alonso 96873James_Hunt 86078Kimi_Raikkonen 90040Fernando_Alonso 76980###############################Qualifying Laps:###############################Fernando_Alonso completed the lap in 84030 millisecondsFernando_Alonso: current personal best is 84030; current position is 1James_Hunt completed the lap in 88197 millisecondsJames_Hunt: current personal best is 88197; current position is 2Kimi_Raikkonen completed the lap in 79282 millisecondsKimi_Raikkonen: current personal best is 79282; current position is 1Ayrton_Senna completed the lap in 92750 millisecondsAyrton_Senna: current personal best is 92750; current position is 4Kimi_Raikkonen completed the lap in 77201 millisecondsKimi_Raikkonen: current personal best is 77201; current position is 1Kimi_Raikkonen completed the lap in 82502 millisecondsKimi_Raikkonen: current personal best is 77201; current position is 1Sebastian_Vettel completed the lap in 81741 millisecondsSebastian_Vettel: current personal best is 81741; current position is 2Sebastian_Vettel completed the lap in 73966 millisecondsSebastian_Vettel: current personal best is 73966; current position is 1James_Hunt completed the lap in 80994 millisecondsJames_Hunt: current personal best is 80994; current position is 3Ayrton_Senna completed the lap in 71047 millisecondsAyrton_Senna: current personal best is 71047; current position is 1James_Hunt completed the lap in 80649 millisecondsJames_Hunt: current personal best is 80649; current position is 4James_Hunt completed the lap in 71841 millisecondsJames_Hunt: current personal best is 71841; current position is 2Ayrton_Senna completed the lap in 99303 millisecondsAyrton_Senna: current personal best is 71047; current position is 1Fernando_Alonso completed the lap in 95106 millisecondsFernando_Alonso: current personal best is 84030; current position is 5Kimi_Raikkonen completed the lap in 97888 millisecondsKimi_Raikkonen: current personal best is 77201; current position is 4Sebastian_Vettel completed the lap in 90617 millisecondsSebastian_Vettel: current personal best is 73966; current position is 3Ayrton_Senna completed the lap in 81740 millisecondsAyrton_Senna: current personal best is 71047; current position is 1Ayrton_Senna completed the lap in 82619 millisecondsAyrton_Senna: current personal best is 71047; current position is 1James_Hunt completed the lap in 75975 millisecondsJames_Hunt: current personal best is 71841; current position is 2Sebastian_Vettel completed the lap in 99538 millisecondsSebastian_Vettel: current personal best is 73966; current position is 3James_Hunt completed the lap in 70664 millisecondsJames_Hunt: current personal best is 70664; current position is 1Kimi_Raikkonen completed the lap in 99347 millisecondsKimi_Raikkonen: current personal best is 77201; current position is 4Sebastian_Vettel completed the lap in 97309 millisecondsSebastian_Vettel: current personal best is 73966; current position is 3Fernando_Alonso completed the lap in 96873 millisecondsFernando_Alonso: current personal best is 84030; current position is 5James_Hunt completed the lap in 86078 millisecondsJames_Hunt: current personal best is 70664; current position is 1Kimi_Raikkonen completed the lap in 90040 millisecondsKimi_Raikkonen: current personal best is 77201; current position is 4Fernando_Alonso completed the lap in 76980 millisecondsFernando_Alonso: current personal best is 76980; current position is 4###############################Results:###############################1. James_Hunt 706642. Ayrton_Senna 710473. Sebastian_Vettel 739664. Fernando_Alonso 769805. Kimi_Raikkonen 77201Some Important RulesIn order to get a full credit, your programs must be efficient and well presented, presence of any redundant computation or bad indentation, or missing, irrelevant comments are going to decrease your grades. You also have to use understandable identifier names, informative introduction and prompts. Modularity is also important; you have to use functions wherever needed and appropriate.Since you will use dynamic memory allocation in this homework, it is very crucial to properly manage the allocated area and return the deleted parts to the heap whenever appropriate. Inefficient use of memory may reduce your grade.When we grade your homework we pay attention to these issues. Moreover, in order to observe the real performance of your codes, we may run your programs in Release mode and we may test your programs with very large test cases. Of course, your program should work in Debug mode as well.You are allowed to use sample codes shared with the class by the instructor and TAs. However, you cannot start with an existing .cpp or .h file directly and update it; you have start with an empty file. Only the necessary parts of the shared code files can be used and these parts must be clearly marked in your homework by putting comments like the following. Even if you take a piece of code and update it slightly, you have to put a similar marking (by adding and updated to the comments below./* Begin: code taken from ptrfunc.cpp *//* End: code taken from ptrfunc.cpp */What and where to submit (PLEASE READ, IMPORTANT)You should prepare (or at least test) your program using MS Visual Studio 2012 C++. We will use the standard C++ compiler and libraries of the abovementioned platform while testing your homework. Itd be a good idea to write your name and last name in the program (as a comment line of course).Submissions guidelines are below. Some parts of the grading process are automatic. Students are expected to strictly follow these guidelines in order to have a smooth grading process. If you do not follow these guidelines, depending on the severity of the problem created during the grading process, 5 or more penalty points are to be deducted from the grade. Name your solution, project, cpp file that contains your main program using the following convention (the necessary file extensions such as .sln, .cpp, etc, are to be added to it):SUCourseUserName_YourLastname_YourName_HWnumberYour SUCourse user name is actually your SUNet user name which is used for checking sabanciuniv e-mails. Do NOT use any spaces, non-ASCII and Turkish characters in the file name. For example, if your SUCourse user name is cago, name is alayan, and last name is zbugszkodyazarolu, then the file name must be:Cago_Ozbugsizkodyazaroglu_Caglayan_hw2In some homework assignments, you may need to have more than one .cpp or .h files to submit. In this case add informative phrases after the hw number. However, do not add any other character or phrase to the file names.Now let us explain which files will be included in the submitted package. Visual Studio 2012 will create two debug folders, one for the solution and the other one for the project. You should delete these two debug folders. Moreover, if you have run your program in release mode, Visual Studio may create release folders; you should delete these as well. Apart from these, Visual Studio 2012 creates a file extension of .sdf ; you will also delete this file. The remaining content of your solution folder is to be submitted after compression. Compress your solution and project folders using WINZIP or WINRAR programs. Please use zip compression. rar or another compression mechanism is NOT allowed. Our homework processing system works only with zip files. Therefore, make sure that the resulting compressed file has a zip extension. Check that your compressed file opens up correctly and it contains all of the solution, project and source code files that belong to the latest version of your homework. Especially double-check that the zip file contains your cpp and (if any) header files that you wrote for the homework.Moreover, we strongly recommend you to check whether your zip file will open up and run correctly. To do so, unzip your zip file to another location. Then, open your solution by clicking the file that has a file extension of .sln. Clean, build and run the solution; if there is no problem, you could submit your zip file. Please note that the deleted files/folders may be regenerated after you build and run your program; this is normal, but do not include them in the submitted zip file.
CS204
[Solved] CS204-Homework 2 Formula 1 Qualifier Ranking with Linked Lists
$25
File Name: CS204-Homework_2__Formula_1_Qualifier_Ranking_with_Linked_Lists.zip
File Size: 593.46 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.