Question
Please use C++ Here's the Ordered List ADT #include OrderedList.h template OrderedList ::OrderedList ( int maxNumber ) { :List (maxNumber) } template void OrderedList ::insert
Please use C++
Here's the Ordered List ADT
#include "OrderedList.h"
template OrderedList
template void OrderedList
if (binarySearch(newDataItem.getKey(), cursor)) dataItems[cursor] = newDataItem;
else { for (int j = size - 1; j > cursor; --j) dataItems[j + 1] = dataitems[j]; ++cursor; ++size; dataItems[cursor] = newDataItem; }
}
template void OrderedList
if (newDataItem.getKey() == dataItems[cursor].getKey()) { dataItems[cursor] = newDataItem; } else { remove(); insert(newDataItem); }
}
template bool OrderedList
if (binarySearch(searchKey, cursor)) { searchDataItem = dataItems[cursor]; result = true; } else { cursor = holdCursor; result = false; } return result; }
template void OrderedList
if (size + fromL.size > maxSize) throw logic_error("merged items do not fit within list");
while ((j >= 0) && (k >= 0)) if (fromL.dataItems[k].getKey() == dataItems[j].getKey()) throw logic_error("lists are supposed to have no common keys"); else if (fromL.dataitems[k].getKey() > dataItems[j].getKey()) dataItems[m--] = fromL.dataItems[k--]; else dataItems[m--] = dataItems[j--];
for (m = k; m >= 0; m--) dataItems[m] = fromL.dataItems[m];
size += fromL.size;
if (size != 0) cursor = 0;
}
template bool OrderedList
while ((j
if (k == subList.size) result = true;
else result = false;
return result; }
#include "show4.cpp"
Step 1: Create a program that simulates reassembling an incorrectly sequenced message by reading in the packets from a text file, resequencing them, and outputting the original message. Your program should use the Ordered List ADT to assist in reassembling the packet. Each packet in the message file contains a position number and five characters from the message (the packet format shown previously). Ideally, you would base your program on the following declarations. Read each successive packet in the input file into a Packet object and insert the Packet object into the ordered list. Then iterate through the entire list from beginning to end, retrieving each message and printing out the message body. Save your program in packet.cppStep 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