Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
bartleby

Concept explainers

Question
Book Icon
Chapter 3, Problem 38P
Program Plan Intro

Game application using doubly linked list

Program plan:

  • Create a class Node.
    • Construct the empty list using default constructor.
    • Initialize the required variables using the parameterized constructor.
    • Set the scores using the setScore() method.
    • Set the name of the game using setName() method.
    • Set the previous node of score using setPrev() method.
    • Set the next node of score using setNext() method.
    • Get the score using getScore() method.
    • Get the name of game using getName() method.
    • Get the previous node of score using getPrev() method.
    • Get the next node of score using getNext() method.
  • Create a class ScoresList.
    • In the add() method,
      • Adds a new score to the list of scores.
        • In the remove() method,
          • Delete a score from the list of scores.
        • In the display() method,
          • Displays the top ten scores.
  • Create a class Main.
    • In main() method.
      • Create an object for scanner class.
      • Read the input from user.
      • Call add() method and remove() method.
      • Finally, display top ten score from the list.

Blurred answer
Students have asked these similar questions
Add a new public member function to the LinkedList class named reverse() which reverses the items in the list.  You must take advantage of the doubly-linked list structure to do this efficiently as discussed in the videos/pdfs, i.e. swap each node’s prev/next pointers, and finally swap headPtr/tailPtr.  Demonstrate your function works by creating a sample list of a few entries in main(), printing out the contents of the list, reversing the list, and then printing out the contents of the list again to show that the list has been reversed.   Note: your function must actually reverse the items in the doubly-linked list, not just print them out in reverse order! Note: we won't use the copy constructor in this assignment, and as such you aren't required to update the copy constructor to work with a doubly-linked list.   This is what I have so far but its not working! template<class ItemType>void LinkedList<ItemType>::reverse(){   Node<ItemType>*curPtr,*prev,*next;…
Important: Make all your implementation in the same attached file and submit only one file in the submission link. Given the linked list data structure discussed in the lecture, implement a sub-class TSortedList that makes sure that elements are inserted and maintained in an ascending order in the list. So, given the input sequence {1,7,3,11,5}, when printing the list after inserting the last element it should print like 1, 3, 5, 7, 11. Note that with inheritance, you have to only care about the insertion situation as deletion should still be handled by the parent class. In the basic implementation, assume that you only have head which is a pointer to the head of the list. Now, if we have both head and tail pointers, what improvements can be done to speed up the insertion?
Implement a recursive function void deleteMax() on the IntList class (provided). The function will delete from the IntList the IntNode containing the largest value. If there are multiple nodes containing this largest value, only delete the 1st one. Be careful not to cause any memory leaks or dangling pointers. You may NOT use any kind of loop (must use recursion). You may NOT use global or static variables. You may NOT use any standard library functions.   Ex: list: 5->7->1->16->4->16->3 list.deleteMax(); list: 5->7->1->4->16->3   IntList.h #ifndef __INTLIST_H__#define __INTLIST_H__ #include <ostream> using namespace std; struct IntNode {int value;IntNode *next;IntNode(int value) : value(value), next(nullptr) {}}; class IntList { private:IntNode *head; public: /* Initializes an empty list.*/IntList() : head(nullptr) {} /* Inserts a data value to the front of the list.*/void push_front(int val) {if (!head) {head = new IntNode(val);} else {IntNode…
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education