
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
C++ Queue LinkedList, Refer to the codes I've made as a guide and add functions where it can add/insert/remove function to get the output of the program, refer to the image as an example of input & output. Put a comment or explain how the program works/flow.

Transcribed Image Text:***Queue Linked List Implementation***
What do you want to do?
Enter letter of choice: c
Queue:
NULL
a. Inqueue item into the Queue
b. Dequeue item out of the Queue
c. Display Queue
Run program again? Press y if yes: y
What do you want to do?
Enter letter of choice: b
You can't dequeue from an empty Queue
Run program again? Press y if yes: y
What do you want to do?
Queue:
0
a. Inqueue item into the Queue
b. Dequeue item out of the Queue
c. Display Queue
Enter letter of choice: a
Enter the item to the queue: 0
Queue:
0 1
a. Inqueue item into the Queue
b. Dequeue item out of the Queue
c. Display Queue
Enqueue more item? Press if yes: y
Enter item to the queue: Y
Enqueue more item? Press
Enter item to the queue:
Queue:
012
Enqueue more item? Press
Enter item to the queue: ž
Queue:
0 1 2 3
Enqueue more item? Press y if yes: n
Ending Enqueue function...
if yes: y
Run program again? Press y if yes: y
What do you want to do?
Enter letter of choice: c
Queue:
0 1 2 3
if yes: y
Queue:
1 2 3
Run program again? Press y if yes: y
What do
want to do?
Dequeue more items? Press y if yes: y
How many items to be dequeued off the Queue? 2
Queue:
3
a. Inqueue item into the Queue
b. Dequeue item out of the Queue
c. Display Queue
Dequeue more items? Press y if yes: y
How many items to be dequeued off the Queue? 2
You can't dequeue from an empty Queue
a. Inqueue item into the Queue
b. Dequeue item out of the Queue
c. Display Queue
Enter letter of choice: b
How many items to be dequeued off the Queue? 1

Transcribed Image Text:1 #include <iostream>
2
using namespace std;
3
4 class Node
58{
6
7
8
15
16
17
18
19 };
20
9
10
};
11 class Linked List public Node
12 {
13
public:
14
21
22
23
HH H
24
25
26
27
28
29
30
31
32
33
34
35
{
}
Node::Node()
//ctor
{
public:
}
LinkedList::LinkedList()
{
Node();
int value;
Node" next;
}
void LinkedList::printLinked List (Node* n)
47
48
LinkedList();
49
void printLinked List (Node* n);
50
void insertAtTheFront (Node** head, int newValue); 51
void insertAtThe End (Node** head, int newValue);
void insertAfter (Node* previous, int newValue);
52
53
54
55
56
57
58
59
//ctor
{
while(n!=NULL)
}
36
37
38
39
40
41
42
43
44
45
46
cout << n->value << endl;
n=n->next;
60
61
62
63
64
65
66
67
68
69
70
71
void LinkedList::insertAtTheFront (Node** head, int newValue)
{
Node newNode = new Node();
newNode->value=newValue;
newNode->next="head;
*head=newNode;
}
void LinkedList::insertAt The End (Node** head, int newValue)
{
Node* newNode= new Node();
newNode->value = newValue;
newNode->next = NULL;
if (*head = NULL)
{
*head=newNode;
}
Node" last=*head;
while(last->next!=NULL)
last-last->next;
{
}
return;
last->next=newNode;
}
void LinkedList::insertAfter (Node* previous, int newValue)
{
if(previous ==NULL)
{
cout << "Previous node cannot be NULL.";
return;
}
Node* newNode = new Node();
newNode->value=newValue;
newNode->next-previous->next;
previous->next=newNode;
73 int main()
74 {
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
}
Node head = new Node();
Node* second = new Node();
Node* third new Node();
head->value=1;
head->next=second;
second->value=2;
second->next=third;
third->value=4;
third->next=NULL;
LinkedList 11;
11.insertAtTheFront (&head, -1);
11.insertAtThe End (&head, 5);
11.insertAfter (head, 0);
11.insertAfter (second, 3);
11.printLinkedList (head);
return 0;
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 6 images

Knowledge Booster
Similar questions
- C++Create a text file storage for the list of movies and store your those movies in a linked list when you retrieved them from the text file. They must also be stored in a linked list data structure during processing. Saving back to the text file will be done when the user chooses to Exit the Program.arrow_forwardWrite code in assembly language Question 1: Construct a program using 2D array. Define a list of strings in the 2D arrays, the list should be only a string. Get a string from a user as input Search the user's string in the list of strings. If string is found print the string, and a message "String is Found". If string is not found print only a message "String is Not Found".arrow_forwardWrite code in assembly language Question 1: Construct a program using 2D array. Define a list of strings in the 2D arrays, the list should be only a string. Get a string from a user as input Search the user's string in the list of strings. If string is found print the string, and a message "String is Found". If string is not found print only a message "String is Not Found".arrow_forward
- Data structure and algorithms. DYNAMIC DATA STRUCTURE LINKED LIST. PURPOSE OF WORK : Consolidation of knowledge on the theoretical foundations of presentation of data in the form of links, classification of lists, learning to solve problems using the LIST standard template library in C++. Task : Write a program to process a linked list from the standard template library. Perform an individual task as a separate function. Implementation of automatic filling and display functions with random data in the program. The task is : The list is given. Create a function to calculate the arithmetic mean value of the elements of the list equal to the Fibonacci number.arrow_forward4. In C++, write a program to input a string and show how can you reverse the string using a queue data structure. Reverse the original string and do not declare any other string variable in the program.arrow_forwardPLEASE SEPARATE EACH SOURCE CODEarrow_forward
- Using c++ Contact list: Binary Search A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use binary search. Modify the algorithm to output the count of how many comparisons using == with the contactName were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Frank 867-5309 Joe…arrow_forwardHelp make a C++ program that:1. Queries the user for the name of a file of text.2. Opens the file, and maintains two lists: one list for words beginning with the letter"D" or "d", and a second list for words beginning with any other letter. Each listmust maintain words in alphabetical order.3. Each node in the list must contain the word and the number of times that the word appears.4. Display (a screen at a time) each of the lists showing the alphabetized list of words and thenumber of times that each appears. Please have the main function as the first function in the program. Please make the least amount of functions as possible. Like for the file input have the file error thing in the same function. And please add comments throughout the code.arrow_forwardData structure and algorithms. DYNAMIC DATA STRUCTURE LINKED LIST. PURPOSE OF WORK : Consolidation of knowledge on the theoretical foundations of presentation of data in the form of links, classification of lists, learning to solve problems using the LIST standard template library in C++. Task : Write a program to process a linked list from the standard template library. Perform an individual task as a separate function. Implementation of automatic filling and display functions with random data in the program. The task is : The list is given. Create a function to calculate the arithmetic mean value of the elements of the list equal to the Fibonacci number.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY