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

  Two vulnerability analysis tools used in research

two Vulnerability Analysis tools used in research and/or commercially available and describe their main features and functionality. Compare and contrast their relative strengths and weaknesses

  Which item in the stack is to be removed first

Which item in the stack is to be removed first?

  Write a method that accepts a stringbuilder object

Write a method that accepts a StringBuilder object as an argument and converts all occurrences of the lowercase letter ‘t' in the object to uppercase.

  Solve for the optimal investment decision

Solve for the optimal investment decision by constructing a decision tree.

  Write method called swappairs accepts string as parameters

Write a method called swapPairs that accepts a String as a parameter

  Pd4 this is for a company selling airline partsthis

this is for a company selling airline parts ltbrgt ltbrgtthis assignment consists of two 2 sections an infrastructure

  Relates part of the grammar to a requirement

question1: Given the following grammars with start symbol , specify the type (0, 1, 2 or 3) of each  one and give a reason that relates part of the grammar to a requirement for the grammar type. Note:  while technically any grammar is Type 0, the..

  The data rate of the transmission line is doubled

Bernie's speed is doubled; (ii) each tape capacity is doubled; (iii) the data rate of the transmission line is doubled.

  What is the standard iana-registered higher-level

How could you determine whether or not a TCP service is running at port 13 of a given Internet host? Test this for the host(s) assigned by your instructor. What is the standard IANA-registered higher-level protocol associated with this port?

  Evaluate the user dialog strategies used by a menu-driven

Evaluate the user dialog strategies used by a menu-driven interface. Determine why menu-driven interfaces continue to be popular in the modern computing age.

  Program that allows a user to enter 10 item stock

Write a program that allows a user to enter 10 item stock numbers, prices, quantities in stock into three parallel arrays. Display all the data in report form - that is, aligned correctly in columns.

  Give a polynomial time reduction

Give a polynomial time reduction from the 3-Color (coloring a graph so that no vertices adjacent to each other have the same color using 3 colors) problem to 3-CNF SAT.

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