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
`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.
Class UnsortedType{ public: //all the prototypes go here. private: int length; NodeType* listData; }; void...
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. 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...
CODE IN C++ Given: typedef char ItemType; // a struct type named NodeType that includes a ItemType and pointer // (to a NodeType) field struct NodeType { ItemType value; NodeType * next; }; bool Delete (NodeType * & firstPtr, ItemType value) { NodeType * prev, * cur; cur = Search (firstPtr, value, prev); if (cur==NULL) return false; else { // remove cur node from the linked list if (prev!=NULL) { //not the first one prev->next = cur->next;...
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)...
public class CharNode{ private CharNode link; private char info; public CharNode(char info) { this.info = info; this.link = null; } public CharNode(char c, CharNode link) { this.info = info; this.link = link; } public CharNode getLink() { return link; } public void setLink(CharNode link) { this.link = link; } public char getInfo() { return info; } public void setInfo(char info) { this.info = info; } } //Remember Queue is a first-in-first-out data structure public class CharQueue { // front is...
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 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, 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 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 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...