Loading

[NEW SOLN] ECET 370 WEEK 2 LAB SIMPLE LINKEDLIST CLASS

[SOLVED] ECET 370 WEEK 2 LAB SIMPLE LINKEDLIST CLASS: Exercise 1: Review of Linked Lists
Create a project using the classes in “A Simple LinkedList Class.
(Links to an external site.)
Links to an external site.
” Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture.

[SOLVED] ECET 370 WEEK 2 LAB SIMPLE LINKEDLIST CLASS: Exercise 2: Implementing a Doubly Linked List

Modify the class LinkedList in Exercise 1 to make it a doubly linked list. Name your class DoublyLinkedList. Each node in your list must contain two references, one to the next node and the other to previous node.
In addition to the methods used in Exercise 1, add a method addEnd to add an integer at the end of the list, and a method displayInReverse to print the list backwards:

  • void addEnd(int x): create this method to add x to the end of the list.
  • void displayInReverse(): create this method to display the list elements from the last item to the first one.

[SOLVED] ECET 370 WEEK 2 LAB SIMPLE LINKEDLIST CLASS: Create a main class to test your DoublyLinkedList class. A sample console output that demonstrates double linkage is shown below. See that regardless of which end the list was added onto, the contents of the list print out correctly when going either forward or backward thru the list…

[SOLVED] ECET 370 WEEK 2 LAB SIMPLE LINKEDLIST CLASS: 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 int type, that is, the bag will store integers. 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 ten random integers, each ranging in value between 0 and 9.

  • LinkedListBag(): default constructor
  • boolean isEmpty(): determines whether the bag is empty
  • void display(): prints the bag elements
  • int getLength(): returns the number of items in the bag
  • void clear(): removes all of the items from the bag
  • void add(int item): adds an item to the bag
  • void removeOne(int item): removes an item from the bag; only the first occurrence of the item should be removed.
  • int count(int item): counts the number of occurrences of an item in the bag.
Support