Question

Class UnsortedType{ public: //all the prototypes go here. private: int length; NodeType* listData; };    void...

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 = _____________; // 20

length--;

// Find node to delete.

while (____________) ; // 21

{

switch (__________________) ; // 22

{

case GREATER:

case LESS   : predLoc = location;

location = ___________; // 23

break;

case EQUAL : found = ___________; // 24

break;

}

}

// delete location

tempPtr = _____________; // 25

              if (____________) // 26

____________ = location->next; //27

else

predLoc->next = _____________; //28

              delete tempPtr;

            }

Read the code segment above and fill in blank # 20.

A. NULL
B. True
C. false
D. listData
E. answer not shown

Read the code segment above and fill in blank # 21.
A. true
B. !found
C. false
D. moreToSearch
E. answer not shown

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.CompareedTo(location)
E. answer not shown

Read the code segment above and fill in blank # 23.
A. item
B. *location.next
C. (*location).next
D. predLoc
E. answer not shown

Read the code segment above and fill in blank # 24.
A. false
B. true
C. predLoc == NULL
D. location != NULL
E. answer not shown

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.

1) OPTION A IS CORRECT

2) OPTION B IS CORRECT

3) OPTION C IS CORRECT

4) OPTION A IS CORRECT

5) OPTION B IS CORRECT

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Class UnsortedType{ public: //all the prototypes go here. private: int length; NodeType* listData; };    void...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Class SortedList { Public: SortedType(); int getLength(); //returns size of the list void putItem(Itemtype item); //inserts...

    Class SortedList { Public: SortedType(); int getLength(); //returns size of the list void putItem(Itemtype item); //inserts an item Itemtype getNextItem(); //returns the next item pointed by the index void deleteItem(Itemtype item) //deletes a specified item Private: int length; //length of the list Nodetype* listData //head of the list Nodetype* currentPos; //current pointer to the list } Class Itemtype { Public: Itemtype(); int getValue();// returns the value Private: int value; } struct Nodetype { Itemtype info; Nodetype* next; } Add a...

  • Fill in the missing code in the following code segment to insert node into list.   ...

    Fill in the missing code in the following code segment to insert node into list.    void SortedType::PutItem(ItemType newItem) {                            NodePtr* newNode;                        // pointer to node being inserted                            NodePtr* predLoc;              // trailing pointer                            NodePtr* location;               // traveling pointer                            boolean moreToSearch;                            location = listData;                            predLoc = NULL;                            moreToSearch = (location != NULL);                            length++;                            // Find insertion point while (moreToSearch)                            { if (location->info < newItem) { predLoc = location; location = location->next; moreToSearch = (location != NULL); }                                        else                                                         moreToSearch = false;                            }                            // Prepare...

  • Double linked list implementation of PutItem function. How to fix my code to get desired output b...

    Double linked list implementation of PutItem function. How to fix my code to get desired output below: Output: 2 5 8 #ifndef ITEMTYPE_H #define ITEMTYPE_H enum RelationType { LESS, GREATER, EQUAL}; class ItemType { public:     ItemType();     void setValue(int newValue);     int getValue() const;     RelationType ComparedTo(ItemType newItem); private:     int value; }; #endif // ITEMTYPE_H // ItemType.cpp #include "ItemType.h" ItemType::ItemType() {     value = 0; } void ItemType::setValue(int newValue) {     value = newValue; } int ItemType::getValue() const {     return value; } RelationType ItemType::ComparedTo(ItemType newItem)...

  • Write a function, swapSubtrees, that swaps all of the left and right subtrees of a binary...

    Write a function, swapSubtrees, that swaps all of the left and right subtrees of a binary tree. Add this function to the class binaryTreeType and create a program to test this function. #include <iostream> using namespace std; //Definition of the Node template <class elemType> struct nodeType { elemType info; nodeType<elemType> *lLink; nodeType<elemType> *rLink; }; //Definition of the class template <class elemType> class binaryTreeType { public: //Overload the assignment operator. const binaryTreeType<elemType>& operator=(const binaryTreeType<elemType>&) { if (this != &otherTree) //avoid self-copy...

  • Introduction In this lab, you are supposed to implement a graph class with the data structure...

    Introduction In this lab, you are supposed to implement a graph class with the data structure implemented before like linked list and queue. graph The class graph contains three member variables: linkedList *adjacentVertices; //an array of linked list. For a vertice i, adjacentVertices[i] stores the linked list that contains all other vertices connected to vertice i. int numVertices; //The number of vertices in the graph. int maxNumVertices; //The maximum number of vertices the graph can hold. Following public methods are...

  • could somone please help me to complete this ! public class MyLinkedList<AnyType> { private Node<AnyType> head,...

    could somone please help me to complete this ! public class MyLinkedList<AnyType> { private Node<AnyType> head, tail; private int size; public MyLinkedList() { this.head = null; this.tail = null; this.size = 0; } //1.Insert a node at the end of the list public void insert(AnyType data) { Node<AnyType> newNode = new Node(); newNode.data = data; if (head == null) { head = newNode; tail = newNode; head.next = null; tail.next = null; } else { tail.next = newNode; tail =...

  • c++ please Given the following skeleton of an unsorted list class that uses an unsorted linked...

    c++ please Given the following skeleton of an unsorted list class that uses an unsorted linked list: template<class ItemType> struct NodeType {                 ItemType item;                 NodeType* next; }; template<class ItemType> class UList { public:                 UList(); // default constrctor                 UList(const UList &x); // we implement copy constructor with deep copy                 UList& operator = (UList &x); // equal sign operator with deep copy                 bool IsThere(ItemType item) const; // return true of false to indicate if item is...

  • How would you get this lab to work with the numbers 37 14 68 47, the...

    How would you get this lab to work with the numbers 37 14 68 47, the book we are using is Data structures using C++ by D.S. Malik. Please I need help? Just keeps repeating the same question. Code: #include <iostream> #include <cstdlib> using namespace std; struct nodeType { int info; nodeType *link; }; void createList(nodeType*& first, nodeType*& last); void printList(nodeType*& first); void insertFront(nodeType*& first); void insertBack(nodeType*& last); void deleteFirst(nodeType*& first); void deleteLast(nodeType*& last, nodeType* first); int main() { nodeType...

  • 41. True or False? Searching the components of an unordered list ADT is faster with a...

    41. True or False? Searching the components of an unordered list ADT is faster with a linked list representation than with a direct array representation. a) true b) false 42. True or False? If an operation that allows random access to individual components of a list ADT is defined and occurs frequently, it is better to represent the list directly as an array than to use a linked list. a) true b) false 43. To prevent a compile-time error, how...

  • MUST USE C++ PLEASE READ THE QUESTION CAREFULLY ADD COMMENTS AND EXPLAIN THE CODES PLEASE. Given...

    MUST USE C++ PLEASE READ THE QUESTION CAREFULLY ADD COMMENTS AND EXPLAIN THE CODES PLEASE. Given the following skeleton of an unsorted list class that uses an unsorted linked list: template < class ItemType > struct NodeType {                 ItemType item;                 NodeType* next; }; template < class ItemType > class UList { public:                 UList(); // default constrctor                 UList(const UList &x); // we implement copy constructor with deep copy                 UList& operator = (UList &x); // equal sign...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT