Define a collection of nodes that are arranged

Assignment Help JAVA Programming
Reference no: EM131595771

Singly-linked Lists Remember that a singly linked list defines a collection of nodes that are arranged in a linear order. The order in a linked list is determined by a reference in each node.

The first and the last node of a linked list are called the head and tail of the list, respectively. Linked list operations usually include:

1) insertFirst(e) Insert element e to be the head of the linked list;
2) removeFirst() Remove and return the first element from the linked list and an error would occur if the list is empty;
3) size() Return the number of elements in the linked list;
4) isEmpty() Return TRUE if the linked list is empty, FALSE otherwise;
5) search(e) search for the first appearance of the element e in the list.

For each node in the list, the following methods are provided.
1) getElement() Return the element of the current node;
2) getNextNode() Return the next node of the current node;
3) setElement(e) Set the value of the element of the current node;
4) setNextNode(n) Set the next node to node n.

A generic framework Java implementation of singly-linked lists is provided for this project. The class LinkedList including several methods to be implemented by you. The main() method is defined in the Driver.java. You are required to modify the code within this method to carry out a variety of different operations. As an example, the following code defines a linked list A and then do the operations: insertF irst(7) and remove(). The status after each operation is also displayed.

Object o;
LinkedList A = new LinkedList();
A.status("Define new Integer linked List A", null);
A.insertFirst(7);
A.status("A.insertFirst(7)", null);
o = A.removeFirst();
A.status("A.removeFirst()", o);

One should obtain results shown below

Operation: Define new Integer linked List A, Returns: null
Linked List Status: size = 0, isEmpty = true, Linked List Content: [ ]

Operation: A.insertFirst(7), Returns: null
Linked List Status: size = 1, isEmpty = false, Linked List Content: [ 7 ]

Operation: A.removeFirst(), Returns: 7
Linked List Status: size = 0, isEmpty = true, Linked List Content: [ ]

 

You need to • Download the starter code from the course web site. Read the starter code and make sure you understand how it works before attempting to modify it. • Design modifications to the starter code for the methods that described in the Introduction section.
Update the starter code with your modifications. • Run the code and your simulation. • Submit a printout of every file that you modified or added to the starter code.


Test your implementation with the following code added in Driver.java, where a linked list of Integer should be defined and the following operations are to be performed with the linked list.


insertFirst(1);
insertFirst(2);
insertFirst(2);
insertFirst(3);
search(1);
search(2);
search(3);
search(5);
removeFirst();
removeFirst();
removeFirst();
removeFirst();
removeFirst();

Attachment:- Java Code.rar

Reference no: EM131595771

Questions Cloud

Would there be differences in the decision making process : Would there be differences in the decision making process when involving these individuals? Use at least one resource to support your key points.
Explain the nature of the business : Pick a specific business and do the following: Explain the nature of the business...what product or service they sell to the public for profit
Do you believe people are poor listeners or good listeners : In a 250-300 word response, answer the following question: Do you believe most people are poor listeners or good listeners?
Take the form of stating a claim : Your position should take the form of stating a claim (what your point of view or position is; typically a single sentence) followed by offering reasoning.
Define a collection of nodes that are arranged : Defines a collection of nodes that are arranged in a linear order. The order in a linked list is determined by a reference in each node.
How significantly were global stock markets affected : How significantly were global stock markets affected? How did the major currencies react during each crisis? What are lessons to be learned from each crisis?
Best financing option for a business : Find an article or video offering advice on choosing the best financing option for a business. Post a link to the article or video.
Build a methed to return a new array : Build a methed to return a new array centaining all elements - public static int add?rraya
Develop strategy map that describes company performance : Using that information, develop a strategy map that describes the company's performance

Reviews

Write a Review

JAVA Programming Questions & Answers

  Define a car structure type

For this assignment you will write a program that determines which of a set of rental cars the user can rent for a user-specified rental rate. The rental car data is contained in a text file which will be fed into your program using stdin redirect..

  Supply constructor that makes polynomial from a single term

Supply methods to add, multiply, and print polynomials - Need help with the assignment

  Main method to test a student graduate record examination

I need a Java solution named TestGRE.java with a main method to test a Student Graduate Record Examination Score Managment System using BinarySearchTree java classes.

  Directly cause thread to stop executing-thread execution

Which cannot directly cause a thread to stop executing? What is the name of the method used to start a thread execution?

  Role of setter and getter in mortgage calculator

The setter and getters must stay in MortgageCalculator.java and everything should output from main (Driver.java).

  Define application using java in the eclipse environment

Within this project create a package called task01. Within this package you will be required to author (write, develop) some classes. These classes are described below

  Create a class named employee and its subclasses

Create a class named Employee and its 3 subclasses named Contractor, HourlyEmployee, FullTimeEmployee. The class Employee hold first name and last name information, and defines two methods, respectively computing pay and vacation hours, that needs..

  Overview in this assignment you are provided with an

overview in this assignment you are provided with an interface that contains a generic type.you are asked to create two

  Bilinear and nearest neighbour algorithm in java

How to do bilinear and nearest neighbour algorithm in java. Show how to eliminate change in pixel aspect ratio in java.

  Implement a class called shortaddress

inally write an application class to allow the user to input an address details and then give the user the choice of viewing the short address details or the long address details. This means your final answer should have a minimum of 3 classes for..

  Create a graphical user interface that has two buttons

Create a Graphical User Interface that has two buttons and a textArea. Create a String array to store the following messages (Enter your name where it says YourName).

  Better programming language

1. Describe three features that make Java a better programming language than C to write secure programs.

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