Question

how to implement a linked list object using only singly linked list toolkit. Then implement a...

how to implement a linked list object using only singly linked list toolkit. Then implement a FREQUENCY function to count the ovcurrence of each element in the list.

task#1:
Add = operator to node:
implement the assignment operator for the node such that setting a node = overwrites the value in the node with the value.

task#2:Linked List class
implement the methods of linked list.
insert
search and locate
remove
node* operator []

task#3: Implement the Frequency
0 0
Add a comment Improve this question Transcribed image text
Answer #1


class LinkedListMy {

   private static int value_count;
   private Node head;

   // Default constructor
   public LinkedListMy() {

   }

   // appends at last of the list.
   public void add(Object your_values) {

       // incase of 1st element initiliz node
       if (head == null) {
           head = new Node(your_values);
       }

       Node temp_variable = new Node(your_values);
       Node current_val = head;

      
       if (current_val != null) {

           // iterate and then add element after last
           while (current_val.getnext_point() != null) {
               current_val = current_val.getnext_point();
           }

          
           current_val.setnext_point(temp_variable);
       }

       //update number of element in the list
       incrementvalue_count();
   }

   private static int getvalue_count() {
       return value_count;
   }

   private static void incrementvalue_count() {
       value_count++;
   }


   public Object get(int index)
   // to retreive element on the basis of position.
   {
       if (index < 0)
           return null;
       Node current_val = null;
       if (head != null) {
           current_val = head.getnext_point();
           for (int i = 0; i < index; i++) {
               if (current_val.getnext_point() == null)
                   return null;

               current_val = current_val.getnext_point();
           }
           return current_val.getyour_values();
       }
       return current_val;

   }

   // total size of list.
   public int size() {
       return getvalue_count();
   }


   private class Node {
       Object your_values;
       Node next_point;

       // Node constructor
       public Node(Object your_valuesValue) {
           next_point = null;
           your_values = your_valuesValue;
       }
   
       @SuppressWarnings("unused")
       public Node(Object your_valuesValue, Node next_pointValue) {
           next_point = next_pointValue;
           your_values = your_valuesValue;
       }
       public Node getnext_point() {
           return next_point;
       }

       public void setnext_point(Node next_pointValue) {
           next_point = next_pointValue;
       }
      
       public Object getyour_values() {
           return your_values;
       }

       @SuppressWarnings("unused")
       public void setyour_values(Object your_valuesValue) {
           your_values = your_valuesValue;
       }

   }
}

Add a comment
Know the answer?
Add Answer to:
how to implement a linked list object using only singly linked list toolkit. Then implement 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
  • Given a singly-linked list interface and linked list node class, implement the singly-linked list which has...

    Given a singly-linked list interface and linked list node class, implement the singly-linked list which has the following methods in Java: 1. Implement 3 add() methods. One will add to the front (must be O(1)), one will add to the back (must be O(1)), and one will add anywhere in the list according to given index (must be O(1) for index 0 and O(n) for all other indices). They are: void addAtIndex(int index, T data), void addToFront(T data), void addToBack(T...

  • C# is the language Create a generic class called “LinkedList” and implement the singly linked list....

    C# is the language Create a generic class called “LinkedList” and implement the singly linked list. Implement the following functions: - In C# Function Name Function Parameters Description Empty - Return true if empty else return false. Size - Return the current size of the list. Insert Value Insert the Value at the end of the list. Insert Index, Value Insert the Value at the specified Index. If the Index is out of range then insert the Value at the...

  • ANSWER IN JAVA ASAP 1.Implement a stack on the singly linked list with the operations of...

    ANSWER IN JAVA ASAP 1.Implement a stack on the singly linked list with the operations of Lab Assignment 1. Hint: Using the same Stack class you implemented, change the array to an object of the singly linked list class. The functionality of push and pop is now based on the methods of the linked list class.

  • 1. Create a class MLL, a singly linked, non-circular list where each node only has one...

    1. Create a class MLL, a singly linked, non-circular list where each node only has one link next and the list has a head and a tail link (think about implementation of node). The MLL class also implements the Iterable interface. The following should be implemented as well: 2. Add the methods to the MLL class: a. iterator() to implement the Iterable interface. This method returns an instance of MLLI initialized appropriately. b. addFirst( value) that adds a value to...

  • 8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code...

    8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code Your answers to this homework must be your own work.You are not allowed to share your solutions.You may not engage in any other activities that will dishonestly improve your results or dishonestly improve or damage the results of others. Plagiarism Plagiarism is when you copy words, ideas, or any other materials from another source without giving credit. Plagiarism is unacceptable in any academic environment....

  • Write a Java class myLinkedList to simulate a singly linked list using arrays as the underlying...

    Write a Java class myLinkedList to simulate a singly linked list using arrays as the underlying structure. Include the following methods: 1. insert an element within the linked list.(this should also work for the front and the rear of the list) 2. Remove an element from the linked list 3. Display (print) the elements of the linked list in order. 4. A method to check if the list is "empty". Test your solution using a linked list that initially has...

  • Write a Python function to implement the quick sort algorithm over a singly linked list. The...

    Write a Python function to implement the quick sort algorithm over a singly linked list. The input of your function should be a reference pointing to the first node of a linked list, and the output of your function should also be a reference to the first node of a linked list, in which the data have been sorted into the ascending order. (You may use the LinkedQueue class we introduced in the lecture directly in your program.)

  • Implement an application based on a singly linked list that maintains a list of the top...

    Implement an application based on a singly linked list that maintains a list of the top five performers in a video game. An entry on the list consists of a name and a score (you can make this into a blueprint class if you like), and the list must be maintained in descending order of scores. Here is an example of such a list when it only has three elements. ​Spike​120 ​Whiz​105 ​G-man​ 99 Use a class based on singly...

  • In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class...

    In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class (50 pts): Create node with public properties: Block type block and block ptr next. Create a linked list class that uses the node you generated without an add or delete method with a head and optional tail and counter. Make a driver that generates a node to test your implementation. Part 2 Add Method (30 pts): Create an add method in your linked list...

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