Question
C++ please ReadFile Create a linked list from an input file (input.txt) that contains an even number of first names. The number of items in
C++ please
ReadFile
Create a linked list from an input file (input.txt) that contains an even number of first names. The number of items in the file is unknown.
SplitMerge
Create a split function that divides the newly created linked list into two equal sublists: myList1 and myList2. For example, originally you would point to (John, Jack, Jill, Jim). After the split, myList1 would point to john and jack and myList2 would point to jill and Jim.
Traverse
Accepts a pointer and displays each of the lists (myList1 and myList2 on the screen) Note: the traverse function takes only one argument, so the function would have to be called twice, once for each of the lists.
Merge
Feed the pointer variables myList1 and myList2 into the Merge function. Create a single list. Return the list.
Traverse
Pass in the pointer variable and display the returned list from the Merge function
Summary:
You need to write at least 5 functions: main, readFile, splitMerge, merge and traverse. The inputs will come from one input files (input.txt). There is no output file. The program should be in a single .cpp file.
From within main call
ReadFile (Read the contents of file, create a linked list and return the list to main)
SplitAndMerge (pass list, splits into list 1 and list 2, void return)
From within splitMerge
call Traverse (Display contents of list1)
call Traverse (Display contents of list2)
call Merge (Pass list1 and list2, merge and return one list)
call Traverse (Display contents of list coming back from Merge)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started