
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Write a C++ program.
Node class
You will create a class “Node” with the following private data attributes:
- line – line from a file (string)
- next - (pointer to a Node)
Put your class definition in a header file and the implementation of the methods in a .cpp file.
Follow the style they use in the book of having a "#include" for the implementation file at the bottom of the header file.
You will have the following public methods:
- Accessors and mutators for each attribute
- Constructor that initializes the attributes to nulls (empty string and nullptr)
LinkedList class
You will create a class “LinkedList” with the following private data attributes:
- headPtr – raw pointer to the head of the list
- numItems – number of items in the list
Put your class definition in a header file and the implementation of the methods in a .cpp file.
Follow the style they use in the book of having a "#include" for the implementation file at the bottom of the header file.
You will have the following public methods:
- Accessor to get the current size (numItems)
- Constructor that initializes numItems to zero and headPtr to nullptr
- Add a node – this method will take as input one string value. It will then create a node object and set the attribute. Then it will put it in the linked list at the correct position – ascending order – avoiding duplicates. You will do all of the work while building the linked list.
- toVector – returns
vector with the contents of the list. You will use only the “push_back” method to get the strings into the vector.
Client program
Your program will ask the user for the file name, open the text file , read each line and invoke the addNode method. Make sure the file opened correctly before you start processing it. You do not know how many lines are in the file so your program should read until it gets to the end of the file.
It will display the contents of the list (the lines that were read from the file in sorted order with no duplicates) using the LinkedList class method “toVector” that puts all of the lines into a vector and returns it to the program that will display it.
Your client program will do the following:
- Read file name from user
- Display the number of lines that were read out of the file and were passed to the addNode method.
- Display the lines in your linked list using the class method toVector to get the lines.
Display the number of lines in the vector.
You will write all of the code for processing the linked list - do not use any predefined objects in C++. You do not need to offer a user interface – simply display the number of lines read from the file, the list using the “toVector” method and the number of lines in the vector.

Transcribed Image Text:The sky is blue.
Clovis Bagwel1
Shake rattle and roll.
The quick brown fox jumped over the lazy dog.
One red bean stuck in the bottom of a tin bowl.
Rats live on no evil star.
The sky is blue.
Mark Knopfler
The sky is blue.
Archibald Beechcroft
Oliver Crangle
Workers of the world unite.
Oliver Crangle
Somerset Frisby
Mark Knopfler
Oliver Crangle
Somerset Frisby
Henry Bemis
Mark Knopfler
Data structures is really hard.
A squid eating dough in a polyethylene bag is fast and bulbous.
A squid eating dough in a polyethylene bag is fast and bulbous.
A squid eating dough in a polyethylene bag is fast and bulbous.
A squid eating dough in a polyethylene bag is fast and bulbous.
Somerset Frisby
Henry Bemis
Mark Knopfler
Romney Wordsworth

Transcribed Image Text:The sky is blue.
Clovis Bagwell
Shake rattle and roll.
The quick brown fox jumped over the lazy dog.
One red bean stuck in the bottom of a tin bowl.
Rats live on no evil star.
The sky is blue.
Mark Knopfler
The sky is blue.
Archibald Beechcroft
Oliver Crangle
Workers of the world unite.
Oliver Crangle
A squid eating dough in a polyethylene bag is fast and bulbous.
Somerset Frisby
Mark Knopfler
Oliver Crangle
Data structures is really hard.
It's raining and boring outside.
It's raining and boring outside.
It's raining and boring outside.
Somerset Frisby
Henry Bemis
Mark Knopfler
Expert Solution

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

Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
How can we ensure that this linked list will be in ascending order?
Solution
by Bartleby Expert
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
How can we ensure that this linked list will be in ascending order?
Solution
by Bartleby Expert
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- for c++ please thank you please type the code so i can copy and paste easily thanks. 4, List search Modify the linked listv class you created in the previous programming challange to include a member function named search that returns the position of a specific value, x, in the lined list. the first node in the list is at position 0, the second node is at position 1, and so on. if x is not found on the list, the search should return -1 test the new member function using an approprate driver program. here is my previous programming challange. #include <iostream> using namespace std; struct node { int data; node *next; }; class list { private: node *head,*tail; public: list() { head = NULL; tail = NULL; } ~list() { } void append() { int value; cout<<"Enter the value to append: "; cin>>value; node *temp=new node; node *s; temp->data = value; temp->next = NULL; s = head; if(head==NULL) head=temp; else { while (s->next != NULL) s = s->next; s->next =…arrow_forwardJava programming 1. Write the code that will read the inventory information from a file, populate the object, and populate a linked list with all the inventory objects. Then find a particular item in the linked list based on user input and display the information for that item. Inventory inventory = new Inventory (); Write the line of code to find an inventory object in the linked list using the property for InventoryIDarrow_forwardWrite a C#program that uses a class called ClassRegistration as outlined below: The ClassRegistration class is responsible for keeping track of the student id numbers for students that register for a particular class. Each class has a maximum number of students that it can accommodate. Responsibilities of the ClassRegistration class: It is responsible for storing the student id numbers for a particular class (in an array of integers) It is responsible for adding new student id numbers to this list (returns boolean) It is responsible for checking if a student id is in the list (returns a boolean) It is responsible for getting a list of all students in the class (returns a string). It is responsible for returning the number of students registered for the class (returns an integer) It is responsible for returning the maximum number of students the class is allowed (returns an integer) It is responsible for returning the name of the class. (returns a string) ClassRegistration -…arrow_forward
- In C Programming: Write a function printCourseRow() which receives a course pointer and prints all its fields as a single row. Use proper formatting so that when we print 2 or more courses as rows, the same members align below each other. Test the function, but don’t include the testing code in your homework.Upload a screenshot of a sample output.arrow_forwardIn C++ Define a class called textLines that will be used to store a list of lines of text (each line can be specified as a string). Use a dynamic array to store the list. In addition, you should have a private data member that specifies the length of the list. Create a constructor that takes a file name as parameter, and fills up the list with lines from the file. Make sure that you set the dynamic array to expand large enough to hold all the lines from the file. Also, create a constructor that takes an integer parameter that sets the size of an empty list. Write member functions to: remove and return the last line from the list add a new line onto the end of the list, if there is room for it, otherwise print a message and expand the array empty the entire list return the number of lines still on the list take two lists and return one combined list (with no duplicates) copy constructor to support deep copying remember the destructor!arrow_forwardMy homework was to design and implement a simple social network program in Java. I should use an adjacency matrix data structure in my implementation. Write a social network program in Java. The default information for this network is stored in two files: index.txt and friend.txt. The file index.txt stores the names of the people in the network – you may assume that we only store the given names and these names are unique; and friend.txt stores who knows whom. The program must read these two files. The following section describes the format of these two files. The friend.txt takes the following format. The first line is the number of pairs of friends. Each subsequent line has two integer numbers. The first two numbers are the indices of the names. The following is an example of friend.txt:50 31 30 12 41 5 The index.txt stores the names of the people in the network. The first line is the number of people in the file; for example:60 Gromit1 Gwendolyn2 Le-Spiderman3 Wallace4 Batman5…arrow_forward
arrow_back_ios
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