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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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