Write the linearlist class

Assignment Help Basic Computer Science
Reference no: EM13867876

The Project
For this assignment, you will write the LinearList class, a singly linked list based implementation of the LinearListADT interface (given below). A 'list' is a sequence of values. The ordering of the items in the list is not specified but does matter, and is in fact problem dependent. No insertion ever occurs at an arbitrary location. When an item is removed from the list, the ordering of the remaining elements in the list is unchanged.
We want to segregate our data structures and separate them from any application programs. Accordingly, you must place all data structures in a package nameddata_structures. Your LinearList class must implement the LinearListADT interface. Your project will consist of exactly the following two files, both of which must be in a data_structures/ package:
? LinearListADT.java The linear list interface (provided below)
? LinearList.java Your implementation of the this interface
Both of the above files must go in package data_structures. Any driver/tester programs will go in the level above the data_structures subdirectory. [ The sample tester program provided for assignment #1 will also work for this one. ] IMPORTANT: The package organization is of critical importance. If your project fails to compile during the grading process due to package errors, your grade for this project 
will be zero.
The LinearListADT interface:
/*  Your name
    Your masc account number
*/
package data_structures;
import java.util.Iterator;
import java.util.NoSuchElementException;
public interface LinearListADT<E> extends Iterable<E> {
    public static final int DEFAULT_MAX_CAPACITY = 100;
//  Adds the Object obj to the end of list.  
    public void addLast(E obj);
    
//  Adds the Object obj to the beginning of list.  
    public void addFirst(E obj);    
    
//  Inserts the Object obj at the position indicated.  If there is an element at
//  that location, all elements from that location to the end of the list are 
//  shifted down to make room for the new insertion.  The location is one based.
//  If the location > size()+1 then a RuntimeException is thrown. List elements 
//  must be contiguous.
    public void insert(E obj, int location);    
//  Removes the object located at the parameter location (one based).
//  Throws a RuntimeException if the location does not map to a valid position within the list.
    public E remove(int location);
    
//  Removes and returns the parameter object obj from the list if the list contains it, null otherwise.
//  The ordering of the list is preserved.  The list may contain duplicate elements.  This method
//  removes and returns the first matching element found when traversing the list from first position.
    public E remove(E obj);
    
//  Removes and returns the parameter object obj in first position in list if the list is not empty,  
//  null if the list is empty. The ordering of the list is preserved.
    public E removeFirst();   
    
//  Removes and returns the parameter object obj in last position in list if the list is not empty, 
//  null if the list is empty. The ordering of the list is preserved.
    public E removeLast();             
//  Returns the parameter object located at the parameter location position (one based).
//  Throws a RuntimeException if the location does not map to a valid position within the list.
    public E get(int location);      
//  Returns true if the parameter object obj is in the list, false otherwise.
    public boolean contains(E obj);  
    
//  Returns the one based location of the parameter object obj if it is in the list, -1 otherwise.
//  In the case of duplicates, this method returns the element closest to position #1.
    public int locate(E obj);       
//  The list is returned to an empty state.
    public void clear();
//  Returns true if the list is empty, otherwise false
    public boolean isEmpty();
//  Returns the number of Objects currently in the list.
    public int size();
    
//  Returns an Iterator of the values in the list, presented in
//  the same order as the underlying order of the list. (position #1 first)
    public Iterator<E> iterator();
 }
Additional Details
? The DEFAULT_MAX_CAPACITY constant in the interface is not applicable to this implementation. 
Linked lists are never full unless the user has exhausted all available memory. You are not 
responsible for this situation, nor do you need to test for it. It should also be obvious that the 
array resizing operations needed for the first version are not applicable here.
? All references to list element position are one-based, not zero-based. The first element in the list 
is at position #1, not #0.
? The ordering of the elements in the list is user defined. Thus, you must never alter the ordering 
of items in the list internally. 
? Your LinearList class will have a single constructor that takes no arguments.
? Both files specified in this assignment must have the exact names and signatures as given.
? You must not make any changes to the LinearListADT interface; I will use my copy to compile 
and run your program. 

Reference no: EM13867876

Questions Cloud

Explain the concept of beam filtration or beam hardening : Describe X-ray tube operation. Discuss principal components and explain the inverse linear relationship between the number and energy of X-rays produces as seen in an unfiltered, bremsstrahlung spectrum.
Minimising the mass of the beam : Choose the beam dimension a to reduce the deflection to below 1cm whilst minimising the mass of the beam.
Prepare the journal entries related to this transaction : Ahlers Clocks is a retailer of wall, mantle, and grandfather clocks and is located in the Empire Mall in Sioux Falls, South Dakota. Assume that a grandfather clock was sold for $ 10,000 cash plus 4 percent sales tax. The clock had originally cost Ahl..
Compare types of mortgage loans offered by different lenders : Compare types of mortgage loans offered by different lenders
Write the linearlist class : For this assignment, you will write the LinearList class, a singly linked list based implementation of the LinearListADT interface (given below). A 'list' is a sequence of values. The ordering of the items in the list is not specified but does matter..
How ashgate enterprises uses the npv method : Ashgate Enterprises uses the NPV method
Relationship between policy advocacy and policy making : Analyze the relationship between policy advocacy and policy making. Include in your discussion the role of leadership as an input in the advocacy process
Calculate the donor ionization energy : What effects occur at about this concentration, and why - Calculate the donor ionization energy
Calculate the percentage power saving : Calculate the percentage power saving when the carrier and one of the sidebands are suppressed in an AM wave modulated to a depth of 100 %.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  The two main forms of documentation

The two main forms of documentation of program design are flowcharts and pseudcode. Based on this week's text chapter and some relevant web resources, discuss the differences between flowcharts and pseudocode, as well as their merits and faults.

  Short paper on firewalls and intrusion detection system

Both firewalls and intrusion detection systems are used to monitor network traffic and implement network security policies. Research these technologies and determine how they are similar and how they differ. Are both needed? Explain your answer in..

  Differentiate centralised and distributed data processing

Explain the differences between centralised and distributed data processing. Describe the pros and cons of each approach.

  Finding counterexample-algorithm based on greedy strategy

Determine a counterexample for following algorithm based on greedy strategy.

  Cores on computer systems

Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency,

  Requirements for the corporate computing function

Your new corporate CIO has devised a nine-point mission statement for the company. As one of the operations managers in the department, you have received a memo on the new policy and an associated task.

  Use of menus in our applications enhance a user experience

Let's start at the very beginning. What is a file? Why is it necessary to "open" and "close" a file? What happens when we do that? What is "writing" to a file? What is the difference between writing to a sequential file and appending to it? How can t..

  Represent 99 and -99 in 2s complement format

what are the largest(positive) and smallest (negative) integers a word can represent - Represent 99 and -99 in 2's complement format.

  What are some ways that company''s can use to get the word

Security awareness programs are their so employees cannot make ignorance an excuse. What are some ways that company's can use to get the word out, and to make sure their employees cannot make that excuse?

  What do the terms liquidity and solvency mean

we saw how cells of similar size, shape, and function form tissues. As a tissue, muscle is very diverse! Let's kick off our study of muscles by discussing the subtypes of muscle tissue, beginning with smooth muscle. Where do we find this muscle tissu..

  Different software packages to different departments

Did you explain how they would deploy different software packages to different departments?

  Explain an increase in spending on items related to hardware

Amend the Riordan IT budget, according to the following requirements- An increase in spending on items related to hardware, software, and outside IT support services by 4 percent

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