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

  How would this ip address be expressed

How many possible hosts would there be on the above network if all usable addresses were assigned (show your work)? d. How would this IP address be expressed using CIDR notation (show your work)? e. What is the range of the block of addresses this..

  Write a class called student that will keep track of student

Write a class called Student that will keep track of a student and a grade.

  Aggregation of ip addresses

A router has just received the following new IP addresses: 57.6.96.0/21, 57.6.104.0/21, 57.6.112.0/21, and 57.6.120.0/21. If all of them use the same outgoing line, can they be done aggregated? If so, to what? If not, why not?

  Write identifying and describing how information is used

1. Write, identifying and describing how  information is used and how it flows in an  organization

  The importance of it and how it has increased over the years

the importance of IT and how it has increased over the years as more technology enters daily use

  Description of social-political and economic effects

What role does digital technology play in freedom of speech and democracy.

  Most important benefit of virtualization

Green computing is the study and practice of ecofriendly computing resources. Green computing is often seen where huge data centers apply server virtualization to reduce the number of servers that would otherwise have to be installed. Determine wh..

  Biggest advantages of mathematical model

What would be the biggest advantages of a mathematical model that supports major investment decisions? Discuss in scholarly detail.

  Distributed computing applications

Distributed Computing Applications

  Three major information security threats

Write a 1,000- to 1,500-word essay on at least three major information security threats that a specific organization you choose faces today.

  Calculating total addressing capacity of computer system

A computer system uses 20-bit address bus and can address an 8-bit wide memory. The memory of this computer system contains 2 × 32 Kbytes ROM (ROM1, ROM2) and 2 × 16 Kbytes of RAM (RAM1 & RAM2).

  Own a consulting company that designs installs

Assume you own a consulting company that designs, installs, and maintains wide area networks. You currently have two companies requesting bids for their wide area networks to be installed. You must provide all of the relevant information to the..

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