Exercises 20 through 28 refer to blanks in the following code segment. Class Uns
ID: 3793456 • Letter: E
Question
Exercises 20 through 28 refer to blanks in the following code segment.
Class UnsortedType
{
public:
//all the prototypes go here.
private:
int length;
NodeType* listData;
};
void UnsortedType::DeleteItem(ItemType item)
//Pre: Item is in list
{
NodeType* tempPtr; //pointer delete
NodeType* predLoc; //trailing pointer
NodeType* location; //traveling pointer
Bool found = false;
location = listData;
predLoc = ______________; //Question 20
length- -;
//Find node to delete.
while(____________) //Question 21
{
switch(__________________) //Question 22
{
case GREATER: ;
case LESS : predLoc = location;
location = _________________; //Question 23
break;
case EQUAL : found = _______________; //Question 24
break;
}
}
//delete location
tempPtr = __________; //Question 25
if (_________________) //Question 26
___________________ = location->next; //Question 27
else
predLoc ->next = ______________; //Question 28
delete tempPtr;
}
20. Read the code segment above and fill in blank #20.
a. NULL
b. True
c. False
d. listData
e. answer not shown
21. Read the code segment above and fill in blank # 21;
a. true
b. !found
c. False
d. moreToSearch
e. answer not shown
22. Read the code segment above and fill in blank #22.
a. item.ComparedTo(listData->info)
b. item.ComparedTo(location->next)
c. item.ComparedTo(location->info)
d. item.ComparedTo(location)
e. answer not shown
23. Read the code segment above and fill in blank #23.
a. item
b. *location.next
c. (*location).next
d. predLoc
e. answer not shown
24. Read the code segment above and fill in blank #24.
a. false
b. true
c. predLoc == NULL
d. location != NULL
e. answer not shown
25. Read the code segment above and fill in blank #25.
a. preLoc
b. location
c. predLoc->next
d. location->next
e. answer not shown
26. Read the code segment above and fill in blank #26.
a. predLoc == NULL
b. location == Null
c. predLoc == location
d. pred->next == NULL
e. answer not shown
27. Read the code segment above and fill in blank #27.
a. predLoc
b. location
c. location->next
d. listData
e. answer not shown
28. Read the code segment above and fill in blank #28.
a. listData
b. predLoc->next
c. location->next
d. newNode->next
e. answer not shown
Explanation / Answer
20. Read the code segment above and fill in blank #20.
a. NULL
b. True
c. False
d. listData
e. answer not shown
Answer : A (NULL ) if predLoc is Null then we need to decrease the length
21. Read the code segment above and fill in blank # 21;
a. true
b. !found
c. False
d. moreToSearch
e. answer not shown
Answer: B(!found) if the found is true we need to work on the switch statement
22. Read the code segment above and fill in blank #22.
a. item.ComparedTo(listData->info)
b. item.ComparedTo(location->next)
c. item.ComparedTo(location->info)
d. item.ComparedTo(location)
e. answer not shown
Answer : c we need to get the value of the location so that we can compare the values for greater or smaller values
23. Read the code segment above and fill in blank #23.
a. item
b. *location.next
c. (*location).next
d. predLoc
e. answer not shown
Answer : c we need to put the values of the next location
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.