11. Consider the following Linked List programs written in C e This code segment
ID: 3871551 • Letter: 1
Question
11. Consider the following Linked List programs written in C e This code segment is int data, NodeType "next W This is a header file saved under finclude "Node Type.h class Unsortedype the ile name: UnsortedType h UnsortedTyped Constructo void MakeEmptyo bool isFull Mint Getlenghto const void insert void Deleteltem@int item). vois Showo int length NodeType start -Unsorted Typeo: W The folowing are the implementation files saved under the file name: UnsortedType.cpp void UnsortedType. Insertitem(int item) NodeType" temp- new NodeType, temp-->data = item temp->next start start temp, length+ void UnsortedType Show) NodeType* temp start while (start != NULL) cout data next; endl I/This will be the source file under the file name: source.cpp #include #include "UnsortedType" using namespace std / Linked List-based int main() UnsortedType ust ust Insertitem(5), ust Insertitem(2); ust. Insertitem(8) ust. Insertltem(3); ust. Show) What will be the output of this C++ program? (10 points)Explanation / Answer
Constructor of UnsortedType is not shown so we don't know start is set or not. Lets
assume that default constructor puts start to NULL and length = 0.
The program will go to infinite loop because the Show() function is having
issue.In this function while loop is waiting for start to become NULL but
this will never happen as start is not getting modified inside the while loop instead
temp is getting modified but it is not compared.
However the prints will be
3
8
2
5
Once temp becomes NULL , we will get runtime error.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.