Using C++, create a doubly linked list data structure that stores strings. At a minimum, you must have a List class that contains the list functionality (including an insert function) and a linkable object ("link node") class. For convenience, you may include the data directly or the data may be external to the link node, connected with a reference. You may use an inner class for the LinkNode and/or include the LinkNode class with the List class file if you wish. Your list must have functions to both insert and remove (and return) values from both the front and end of the list. Use of a "standard container" (such as an STL class, Vector, or ArrayList) is not permitted.
Using composition (with the List class,) define a Queue class that has enque and deque functions, as well as an isEmpty function. (Each of your classes may have any additional functionality that you deem necessary)
Write a main function that will read an unspecified number (until EOF) of input strings (each string may include whitespace and is terminated with a newline) from STDIN. Enque each string into your Queue. After you have read all of the input, deque each string from your Queue, printing it to STDOUT (one per line) until the Queue us empty. Your program should have no other output.
solution:
Source & Screens: List.h & List.cpp
|
#ifndef LIST_H_ #include <string> using namespace std; class List { }; public:
#endif /* LIST_H_ */ |
![]() |
|
/* #include "List.h" List::List() { void List::insertFirst(string data) { void List::insertLast(string data) { } string List::removeFirst() { string List::removeLast() { } |
|
|
Source & Screens: Queue.H & Queue.cpp
|
#ifndef QUEUE_H_ class Queue { #endif /* QUEUE_H_ */ |
![]() |
|
#include "Queue.h" Queue::Queue() { void Queue::enque(string data) { string Queue::deque() { bool Queue::isEmpty() { |
![]() |
Source & Screens: TestQueue.cpp
|
#include "Queue.h" Queue::Queue() { void Queue::enque(string data) { string Queue::deque() { bool Queue::isEmpty() { |
![]() |
please give me thumb up
Using C++, create a doubly linked list data structure that stores strings. At a minimum, you...
Using C++, create a doubly linked list data structure that stores strings. At a minimum, you must have a List class that contains the list functionality (including an insert function) and a linkable object ("link node") class. For convenience, you may include the data directly or the data may be external to the link node, connected with a reference. You may use an inner class for the LinkNode and/or include the LinkNode class with the List class file if you...
In this lab, using C++, you will create an abstract data type, using a doubly-linked circular structure to store the values and links. You must create it by your own and not use any existing containers. You will need a QueueNode. You can use a struct for this, as each node will not have any associated functions. It will have members for data, and the next and previous pointers. Data will be positive integers. There will be no NULL pointers....
implement a doubly-linked list in C. Each node in the linked list should contain a string, a pointer to the previous node (or NULL), and a pointer to the next node (or NULL). The nodes should be sorted by their strings. struct node_t { char* str; struct node_t* prev; struct node_t* next; } To maintain the doubly-linked list, you should keep a pointer to the head node of the list (or NULL if the list is empty), and a pointer...
CS 373 Home Work project 11 Create a queue class by priviate inherting the unorderedArrayListType class. A queue class is a First-In-First-Out data structure. To understand a queue, think of a checkout line at a grocery store: the person at the front is served first (removed), and people are added to the line from the back end. class queue : private unorderedArrayListType { public: bool isEmpty() const; // test whether queue is empty // Post: returns true if queue is...
Problem: Implement an interface that manipulates a list of strings. You will be provided with the following files (see below): • StringList.h containing a class declaration, set up for a linked list representation. • Driver.cpp containing a main function you can use to test your implementation. You will be responsible for providing the StringList.cpp file, including the implementation of the StringList member functions (described below): StringList and ~StringList: creates an empty list, and deallocates all the nodes in the list,...
Instructions Part 1 - Implementation of a Doubly Linked List Attached you will find the code for an implementation of a Singly Linked List. There are 3 files: Driver.java -- testing the List functions in a main() method. LinkNode.java -- Class definition for a Node, which is the underlying entity that stores the items for the linked list. SinglyLinkedList.java -- Class definition for the Singly Linked List. All the heavy lifting happens here. Task 1 - Review & Testing: Create...
Instructions Part 1 - Implementation of a Doubly Linked List Attached you will find the code for an implementation of a Singly Linked List. There are 3 files: Driver.java -- testing the List functions in a main() method. LinkNode.java -- Class definition for a Node, which is the underlying entity that stores the items for the linked list. SinglyLinkedList.java -- Class definition for the Singly Linked List. All the heavy lifting happens here. Task 1 - Review & Testing: Create...
C++ Linked List Implementation Motivation As we discussed in class, the data structures that you use to implement your program can have a profound impact on it's overall performance. A poorly written program will often need much more RAM and CPU time then a well-written implementation. One of the most basic data structure questions revolves around the difference between an array and a linked list. After you finish this assignment you should have a firm understanding of their operation. Problem...
[C++] Create three functions for a singly linked list: - Function 1: Insert a string into the linked list - Function 1: Insert a node after a given node (Node* curNodeptr, Node* newNodePtr) - Function 2: Delete the node passed to it by a pointer, it will take in the head and curPtr '(Node*, Node*)' struct Node{ string data; Node *next; };
This class implements a doubly linked list in which the nodes are of the class DLNode. This class must implement the interface DLListADT.java that specifies the public methods in this class. The header for this class will then be public class DLList implements DLListADT This class will have three private instance variables: • private DLNode front. This is a reference to the first node of the doubly linked list. • private DLNode rear. This is a reference to the last...