Below is a code segment for the Deleteltem function in an un
Below is a code segment for the Deleteltem function in an unsorted list implemented using a static array Fill in the blank sections of code to successfully implement a deleted item void UnsortedType::DeleteItem(ListItemType& item) There is at most one list item with the same key as item; there may be none. Post: No list element has the same key as item. int location = 0; int index; bool moreToSearch; more search = bool found = false; while switch (item.CompardTo(info[location])) case LESS: location^++ moretosearch = break; case EQUAL:....= true break; if (found) {info [location] = leanth^-- What is the running time of the Deleteltem operation?
Solution
A) 1.) false
2.) moreToSearch
3) True
4) True
5) found
6) item
B) Time Complexity T(N) = O(N)
C)
template <class ItemType>
void UnsortedType<ItemType>::InsertItem(ItemType item)
// item is in the list; length has been incremented.
{
NodeType<ItemType>* location;
location = new NodeType<ItemType>;
location->info = item;
location->next = listData;
listData = location;
length++;
}
