Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 21.6, Problem 21.6.1CP
Program Plan Intro
Map:
Map is an interface which contains values on the basis of key and a value pair and represents a mapping between them. Each key and a value pair in the map are unique.
A map can be of three types: HashMaps, LinkedMaps and TreeMaps.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
using namespace std;
class SinglyLinkedListNode {
// INSERT YOUR CODE HERE
};
class SinglyLinkedList {
public:
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
SinglyLinkedList() {
this->head = nullptr;
this->tail = nullptr;
}
voidinsert_node(intnode_data) {
// INSERT YOUR CODE HERE
}
};
void free_singly_linked_list(SinglyLinkedListNode* node) {
// INSERT YOUR CODE HERE
}
// Complete the has_cycle function below.
/*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode* next;
* };
*
*/
bool has_cycle(SinglyLinkedListNode* head) {
SinglyLinkedListNode* temp = head;
bool isCycle = false;
while (temp != nullptr)
{
// INSERT YOUR CODE HERE
}
}
int main()
{
// INSERT YOUR CODE HERE TO TEST YOUR CODE
return0;
}
using namespace std;
class SinglyLinkedListNode {
// INSERT YOUR CODE HERE
};
class SinglyLinkedList {
public:
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
SinglyLinkedList() {
this->head = nullptr;
this->tail = nullptr;
}
voidinsert_node(intnode_data) {
// INSERT YOUR CODE HERE
}
};
void free_singly_linked_list(SinglyLinkedListNode* node) {
// INSERT YOUR CODE HERE
}
// Complete the has_cycle function below.
/*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode* next;
* };
*
*/
bool has_cycle(SinglyLinkedListNode* head) {
SinglyLinkedListNode* temp = head;
bool isCycle = false;
while (temp != nullptr)
{
// INSERT YOUR CODE HERE
}
}
int main()
{
// INSERT YOUR CODE HERE TO TEST YOUR CODE
return0;
}
Help in C++ please:
Write a program (in main.cpp) that:
Prompts the user for a filename containing node data.
Outputs the minimal spanning tree for a given graph.
You will need to implement the createSpanningGraph method in minimalSpanTreeType.h to create the graph and the weight matrix.
There are a few tabs:
main.cpp, graphType.h, linkedList.h, linkedQueue.h, queueADT.h, minimalSpanTreeType.h, and then two data files labeled: CH20_Ex21Data.txt, CH20Ex4Data.txt
Chapter 21 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 21.2 - Prob. 21.2.1CPCh. 21.2 - Prob. 21.2.2CPCh. 21.2 - Prob. 21.2.3CPCh. 21.2 - Prob. 21.2.4CPCh. 21.2 - Prob. 21.2.5CPCh. 21.2 - Suppose set1 is a set that contains the strings...Ch. 21.2 - Prob. 21.2.7CPCh. 21.2 - Prob. 21.2.8CPCh. 21.2 - What will the output be if lines 67 in Listing...Ch. 21.2 - Prob. 21.2.10CP
Ch. 21.3 - Prob. 21.3.1CPCh. 21.3 - Suppose you need to write a program that stores...Ch. 21.3 - Suppose you need to write a program that stores...Ch. 21.3 - Suppose you need to write a program that stores a...Ch. 21.3 - Prob. 21.3.5CPCh. 21.3 - Prob. 21.3.6CPCh. 21.4 - Prob. 21.4.1CPCh. 21.4 - Prob. 21.4.2CPCh. 21.5 - Prob. 21.5.1CPCh. 21.5 - Prob. 21.5.2CPCh. 21.5 - Prob. 21.5.3CPCh. 21.6 - Prob. 21.6.1CPCh. 21.6 - Prob. 21.6.2CPCh. 21.6 - Prob. 21.6.3CPCh. 21.6 - Prob. 21.6.4CPCh. 21.7 - Prob. 21.7.1CPCh. 21.7 - Prob. 21.7.2CPCh. 21 - Prob. 21.1PECh. 21 - (Display nonduplicate words in ascending order)...Ch. 21 - Prob. 21.3PECh. 21 - (Count consonants and vowels) Write a program that...Ch. 21 - Prob. 21.6PECh. 21 - (Revise Listing 21.9, CountOccurrenceOfWords.java)...Ch. 21 - Prob. 21.8PECh. 21 - Prob. 21.9PE
Knowledge Booster
Similar questions
- ? mapMystery ♡ Language/Type: What is the output of the following code? Map map = new TreeMap(); map.put("K", "Schwarz"); map.put("C", "Lee"); map.put("M", "Sahami"); map.put("M", "Stepp"); map.remove("Stepp"); map.remove("K"); map.put("J", "Cain"); map.remove("C, Lee"); System.out.println(map); output a. O {J-Cain, M=Sahami} b. O {J-Cain, C=Lee, M=Sahami, M=Stepp} c. O {C-Lee, J-Cain, M=Stepp} d. O {C-Lee, J-Cain, M=Stepp, M=Sahami} (order shuffled) Java Map TreeMap collectionsarrow_forward//give the output of the following program and draw the link list. struct node{ int info; struct node *link;};typedef struct node *nodePTR;void insort(nodePTR*,struct Info);nodePTR getnode();int main(void){nodePTR p=NULL,head=NULL,save;inti; for(i=0;i<3;i++){ insort (&head,i+5);}save=head;do{ printf("%d",save->info); save=save->link;}while(save!=NULL); return0;}nodePTR getnode(){nodePTR q;q=(nodePTR)malloc(sizeof(struct node));return q;}void insort(NODEPTR *head , int x){ NODEPTR p,q,r; q=NULL; for(p=*head; p!=NULL &&x>p->info; p=p->link) q=p; if(q=NULL) { p=getnode(); p->info=x; p->link=head; head=p; }else{ r=getnode(); q->link=r; r->info=x; r->link=p; }}arrow_forwardPlease fill in the code gaps if possible. This problem has been giving me trouble. Any help is appreciated. public class Node { private String element; // we assume elements are character strings private Node next; /* Creates a node with the given element and next node. */ public Node(String s, Node n) { //fill in body } /* Returns the element of this node. */ public String getElement() { //fill in body } /* Returns the next node of this node. */ public Node getNext() { //fill in body } // Modifier methods: /* Sets the element of this node. */ public void setElement(String newElem) { //fill in body } /* Sets the next node of this node. */ public void setNext(Node newNext) { //fill in body } }arrow_forward
- What does this part of code do? void addRecord(Node *& head, Node *& tail, string name, double balance){ Node *newNode = new Node; newNode->name = name; newNode->balance = balance; newNode->next = NULL; newNode->prev = NULL; // If list is empty, make newNode the first node if(head == NULL){ head = newNode; tail = newNode; } else{ Node *temp = head; // Loop through list until temp->next is NULL while(temp->next != NULL){ temp = temp->next; } temp->next = newNode; newNode->prev = temp; tail = newNode; }} /*arrow_forwardnot sure how to do this problem output doesnt matterarrow_forwardNonearrow_forward
- C++ DATA STRUCTURES Implement the TNode and Tree classes. The TNode class will include a data item name of type string,which will represent a person’s name. Yes, you got it right, we are going to implement a family tree!Please note that this is not a Binary Tree. Write the methods for inserting nodes into the tree,searching for a node in the tree, and performing pre-order and post-order traversals.The insert method should take two strings as input. The second string will be added as a child node tothe parent node represented by the first string. Hint: The TNode class will need to have two TNode pointers in addition to the name data member:TNode *sibling will point to the next sibling of this node, and TNode *child will represent the first child ofthis node. You see two linked lists here??? Yes! You’ll need to use the linked listsarrow_forwardWhat does the following function do for a given Linked List? void fun1(struct node* head){if(head == NULL)return;fun1(head->next);printf("%d ", head->data);}arrow_forwardI have an assignment that requires me to read strings from a text file and insert them into a binary search tree. I am having a hard time reading the data from the file and passing it through a function. This is the code I have right now: struct tree_node {char *data;tree_node *left;tree_node *right;}; char **Read();tree_node *create_node(char **val); int main(){tree_node *root= NULL, *temp_node;char **val = (char**)malloc(sizeof(char*)*17);for (int i = 0; i < 17; i++) {val[i] = (char*)malloc(sizeof(char)*strlen(*val));}temp_node = create_node(val);root = insert(root, temp_node);printf("In Order: ");inorder(root);printf("\n");return 0;} char **Read() {int size;FILE *fp = fopen("in.txt", "r");fscanf(fp, "%d", &size);char** value = (char**)malloc(sizeof(char*));for(int i = 0; i < size; i++) {fscanf(fp, "%s", &value[i]);} fclose(fp);return value;} tree_node *create_node(char **val) {tree_node* temp = (tree_node*)malloc(sizeof(tree_node));for(int i = 0; i < 17; i++)for(int…arrow_forward
- In C++ write a program that prints the first cycle in a directed graph from any given node. The graph is stored in and adajency list in the form "vector adj[]"arrow_forwardExplain this code by putting comments in detail. Language used is c++. Topic is Linkedlist // void deleteByData(int data) { // if(head->data == data) { // head = head->next; // } // next = head; // Node *prev = next; // while (next != NULL) { // if (next->data == data) { // prev->next = prev->next->next; // } // prev = next; // next = next->next; // } // }; };arrow_forwardC+ Write a program that outputs the shortest distance from a given node to every other node in the graph. I NEED THESE HEADER FILES INCLUDED IN THE PROGRAM PLEASE These are the header files: graphType.h, linkedList.h, linkedQueue.h, queueADT.h, testProgGraph.cpp, unorderedLinkedList.h, weightedGraph.harrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education