Implementing a doubly linked list

Assignment Help Basic Computer Science
Reference no: EM13837090

Exercise 1: Implementing a Doubly Linked List

Modify the class LinkedList to make it a doubly linked list. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards:

voidaddEnd(int x): create this method to add x to the end of the list. 
voiddisplayInReverse(): create this method to display the list elements from the last item to the first one. 

Create a main class to test your DoublyLinkedList class. 

Exercise 2: Using a Doubly Linked List

Using the class DoublyLinkedList completed in the previous exercise, write a program to store all the prime numbers up to 100 in a DoublyLinkedList object. The numbers should be stored in such a way that when "display" is invoked, the listing will be shown in increasing order: 2, 3, 5, 7, 11, 13, 17, ... .

Exercise 3: Implementing a Bag Class

Create a class bag that uses a linked list to store the bag items. The item type must be a Java String type, that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class. This main class should fill a bag with the keywords of the Java language.

  1. . Bag(): default constructor
  2. booleanisEmpty(): determines whether the bag is empty
  3. void print(): prints the bag elements
  4. intgetLength(): returns the number of items in the bag
  5. void clear(): removes all of the items from the bag
  6. void add(String item): adds an item to the bag
  7. voidremoveOne(String item): removes an item from the bag; only one occurrence of the item should be removed.

  int count(String item): counts the number of occurrences of an item in the bag. 

(Note that you can reuse the code in Exercise 1 for the LinkedList class to create your bag class. It will help you to save development time.) 

Attachment:- text.txt

Reference no: EM13837090

Questions Cloud

Develop a policy for recruiting and hiring employees : develop a policy for recruiting and hiring employees
Assignment in python : You will complete this assignment in Python 3.x. Make sure you have downloaded the software and it is installed correctly. You will download it from this site: https://www.python.org/downloads/.
Write a report about memory management ram technologies : Write a report about Memory Management: RAM technologies. It has been widely acknowledged that many students will work in jobs that are not known yet.
What are three possible interpretations that cooper gives : What is the main point of the article? (Tip: The abstract of any article typically offers a concise overview of the article's main point). What are the three possible interpretations that Cooper gives for the correlation between drinking and risky ..
Implementing a doubly linked list : Modify the class LinkedList to make it a doubly linked list. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards:
Which graph depicts the end of the war : Explain how the extreme point on the vertical axis is identified and how the extreme point on the horizontal axis identified when the production possibilities curve is drawn.
Incorporate employee relations doctrines : Incorporate employee relations doctrines
Import tariffs that president bush placed on imported steel : The import tariffs that President Bush placed on imported steel likely had what effect?
Compete in a cournot duopoly : Firms 1 and 2 compete in a Cournot duopoly. If firm 2 adopts a strategy that raises firm 1's marginal cost:

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write select statement determines paymentdate column invoice

Write a Select statement that determines whether the PaymentDate column of The Invoices table has any invalid values.

  Complete the requirements using dbdl

Complete the requirements using DBDL and create Diagram. Make sure all tables are normalized to 3NF and exhibit proper relationships.

  Create a hierarchy of no more or no less than five

Create a hierarchy of no more or no less than five (5) of the most important topics that you believe that a one-day course entitled "Introduction to Networking: The Essentials Presented in One Day" should address. Provide a detailed rationale for eac..

  Issue -internet changed political interactions globally

Write a 500 word essay based on the issue of ways in which the internet has changed political interactions globally. These might involve political activity in several specific countries,

  Which design strategy would you recommend

Assume that you are developing a new system for a local real estate agency. The agency wants to keep a database of its own property listing and also wants to have access to the citywide multiple listing service used by all real estate agents Which de..

  Analyze use of databases in business environment

Create the 2-3 page memorandum analyzing use of databases in the business environment. Include what database applications must be used: Microsoft Access, IBM DB2, Oracle, etc.

  Want to confirm and verify prior to notifying users

The database administrator for your company. Your staff just informed you that they have noticed several unauthorized attempts to access the database. You are trying to decide how to address this issue to your management team. What type of informatio..

  Write a program that will read in a length in meters

Write a program that will read in a length in meters and centimeters and output the equivalent length in feet and inches. Use at least three functions; one for input, one or more for calculating and one for output.

  Write the query to display the employee number

Write the query to display the employee number,last name,first name,salary "from" date,salary end date, and salary amount for employees 83731,83745 , and 84039.Sort the output by employee number and salary "from"date

  What are the benefits of these noninvasive procedures

List three medical technologies that rely on the physics of elementary particles? What are the benefits of these noninvasive procedures?

  Demand-paged environment

Which of the following programming techniques and data structures (in a user-level program) are good for a demand-paged environment, and which are bad? Explain your answer.

  Circuit diagram-truth table for half subtractor-full adder

Illustrate the circuit diagram of the following circuit and create truth table for half subtractor and full adder. Full subtractor and Half adder.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd