Question

O indexOf Language/Type: Related Links: Author: Java implementing Linked Lists LinkedIntList LinkedIntList.java Marty Stepp W

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public int indexOf(int value) {
    int index = 0;
    ListNode temp = front;
    while (temp != null) {
        if (temp.data == value) {
            return index;
        }
        ++index;
        temp = temp.next;
    }
    return -1;
}
Add a comment
Know the answer?
Add Answer to:
O indexOf Language/Type: Related Links: Author: Java implementing Linked Lists LinkedIntList LinkedIntList.java Marty Stepp Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA lists and nodes my answer was : ListNode newNode = new ListNode(3); newNode.next = head;...

    JAVA lists and nodes my answer was : ListNode newNode = new ListNode(3); newNode.next = head; head = newNode; it is incorrect. what could it be? linkedNodes 11 > <linkedNodes 9 Main Page -- Problems - Solve a Problem OBJP5 Self-Check 16.10: linkedNodes 10 Language/Type: Java ListNodes LinkedLists Related Links: LinkedIntList.java Author: Marty Stepp (on 2019/09/19) Write the code necessary to convert the following sequence of ListNode objects: list -> [1] -> [2] / Into this sequence of ListNode objects:...

  • if we have following List classes: public class LinkedList<T> { class ListNode { protected T value;...

    if we have following List classes: public class LinkedList<T> { class ListNode { protected T value; protected ListNode next; public ListNode(T val, ListNode nxt) { value = val; next = nxt; } public ListNode(T val) { this(val, null); } public ListNode() { this(null, null); } } can you write the folowing methods in java: 1.Write a method for the LinkedList class called int indexOf(T val) which returns the integer index indicating the location of val in the list, or -1...

  • C# code Arrays and Linked Lists: Write C++/Java/C#/Python code to declare an array of linked lists...

    C# code Arrays and Linked Lists: Write C++/Java/C#/Python code to declare an array of linked lists of any primitive type you want. (Array of size 2020) (This could be based on MSDN libraries or the lab) – you do not need to instantiate any of the linked lists to contain any actual values. Paste your code for that here (this should only be one line) Based on your code or the lab from 4 or your doubly linked list from...

  • Write a method named factorial that accepts an integer n as a parameter and returns the...

    Write a method named factorial that accepts an integer n as a parameter and returns the factorial of n, or n!. A factorial of an integer is defined as the product of all integers from 1 through that integer inclusive. For example, the call of factorial(4) should return 1 2 3 4, or 24. The factorial of 0 and 1 are defined to be 1. You may assume that the value passed is non-negative and that its factorial can fit...

  • Language: Java Topic: Doubly Linked Lists Write a method that removes and returns the last copy...

    Language: Java Topic: Doubly Linked Lists Write a method that removes and returns the last copy of the given data from the list. Do not return the same data that was passed in. Return the data that was stored in the list. Must be O(1) if data is in the tail and O(n) for all other cases.    * @param data the data to be removed from the list * @return the data that was removed * @throws java.lang.IllegalArgumentException if...

  • Need the answers to these RECURSIVE practice problems using Linked Lists in JAVA . Thank you. Complete the Link cl...

    Need the answers to these RECURSIVE practice problems using Linked Lists in JAVA . Thank you. Complete the Link class by writing methods described below. Do not use loops, or create any more methods (other than those specified), class or instance variables. public class Link private Link next; /null if this is the last link private int value; public Link(Link n, int v) nextn valuev; Do not use loops, or create any more methods (other than those specified), class or...

  • In NetBeans Create a new Java Application to manage Linked Lists: (Note: Do not use java.util.LinkedList)...

    In NetBeans Create a new Java Application to manage Linked Lists: (Note: Do not use java.util.LinkedList) a) Create a DateTime class 1. Add day, month, year, hours, minutes as attributes 2. Add a constructor and a toString() method 3. Implement the Comparable interface, and add a CompareTo() method 4. Add methods to get and set all attributes. b) Add to MyLinkedList class the following methods: 1. Insert a Node to a particular position in the List 2. Insert a Node...

  • JAVA (implementing a collection class) write a completed program using ArrayIntList and Client ArrayIntList.java public...

    JAVA (implementing a collection class) write a completed program using ArrayIntList and Client ArrayIntList.java public class ArrayIntList { private int[] elementData; // list of integers private int size; // current number of elements in the list public static final int DEFAULT_CAPACITY = 100; // pre : capacity >= 0 // post: constructs an empty list with the given capacity public ArrayIntList(int capacity) { elementData = new int[capacity]; size = 0; } // post: constructs an empty list of default capacity...

  • JAVA (implementing a collection class) write a completed program (must include MAIN) and straight to the output based on 4. Based on the implementation of ArrayIntlist or ArrayList, write a class Sor...

    JAVA (implementing a collection class) write a completed program (must include MAIN) and straight to the output based on 4. Based on the implementation of ArrayIntlist or ArrayList, write a class SortedIntList or SortedList that provides most of the same operations but maintains its elements in sorted order. When a new value is added to the sorted list rather than appending it to the end of the list, it is placed in the appropriate index to maintain sorted order of...

  • JAVA - Circular Doubly Linked List Does anybody could help me with this method below(previous)? public...

    JAVA - Circular Doubly Linked List Does anybody could help me with this method below(previous)? public E previous() { // Returns the previous Element return null; } Explanation: We have this class with these two implemented inferfaces: The interfaces are: package edu.ics211.h04; /** * Interface for a List211. * * @author Cam Moore * @param the generic type of the Lists. */ public interface IList211 { /** * Gets the item at the given index. * @param index the index....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT