Created a linked list class

Assignment Help Data Structure & Algorithms
Reference no: EM13165202

created a linkedlist class,the set() method and listiterator() method. I need someone to finish for me.

 

here is what i got so far:

 

import java.util.Iterator;

import java.util.ListIterator;

import java.util.NoSuchElementException;

 

 

public class MyLinkedList<Product> {

private Node<Product> head = null;

private Node<Product> tail = null;

private Node<Product> temp = null;

 

private int counter = 0;

public MyLinkedList() {

}

public int size(){return counter;}

 

public Product get(int position){

assert (position >= 0 && position < size());

temp = head;

for(int i = 0; i < position; i++) temp = temp.next;

return temp.element;

}

 

public void add(Product element) {

if (head == null) {

head = tail = new Node<Product>();

head.element = element;

head.next = tail;

tail = head;

}else{

tail.next = new Node<Product>();

tail = tail.next;

tail.element = element;

}

counter++;

 

}

 

/*public void set(int position, Product element) {

if (position == size()) {

add(element);

return;

} else if (position == 0) {

 

}

 

}*/

public void set(int inLayer, Product element) {

if (head == null) {

head = tail = new Node<Product>();

head.element = element;

head.next = tail;

tail = head;

}else{

tail.next = new Node<Product>();

tail = tail.next;

tail.element = element;

}

counter++;

}

public ListIterator<Product> iterator() {

return ListIterator<Product>();

}

Node<Product> current = head;

 

boolean hasNext() {

return (current.next != null);

}

 

Product next() {

if (!hasNext()) {

throw new NoSuchElementException();

}

current = current.next;

return current.value;

}

 

 

Reference no: EM13165202

Questions Cloud

What resources did you use in preparing this tax return : What resources did you use in preparing this tax return?  Provide references to page numbers in your textbook and specific addresses within the IRS website.
What is the compound empirical formula : a 175.0g sample of a compound contains 56.15g C, 9.43g H, 74.81g O, 13.11g N, and 21.49g Na. What is the compound's empirical formula?
State how many moles of oxygen atoms : 1. How many CO2 molecules are needed to produce 1 glucose molecule (in photosynthesis)? 2. How many moles of oxygen atoms are in 1 mole of calcium phosphate?
Calculate the mass of lycopene : (a)how do I calculate the concentration of the lycopene solution in the spectrophotometer cell before isomerization, given that the molar absorptivity of lycopene at 471 nm is 1.86 x 10^4. (b) Calculate the mass of lycopene in 3.0mL of the solutio..
Created a linked list class : created a linkedlist class
How many grams of naoh should we have used : The molar mass of corn oil is 890g/mole. How many moles and how many grams of sodium hydroxide are required to react with the 15mL (13.7g) of corn oil? Show your calculations.
Develop an interface evaluation questionnaire : Develop an interface evaluation questionnaire that contains 20 generic questions that would apply to most interfaces.
How many ozone molecules are in a liter : If the pressure exerted by ozone, O3, in the stratosphere is 3.0*10^-3 atm and the temperature is 250 K, how many ozone molecules are in a liter?
Decomposition for r = (a,b,c,d,e ) : Give a good decomposition for R = (A,B,C,D,E ) with the following functional dependencies:

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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