Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Create a randomly generated Doubly linked list of 10 integers using the class

ID: 3650078 • Letter: 3

Question

3. Create a randomly generated Doubly linked list of 10 integers using the class IntDLList.java. For example, your list could be:

[ 3 1 2 5 8 7 9 0 1 6 ].

Now delete every 7th element from the list and print it. Note that if you reach the end then you have to reverse the direction of counting. Your output could be as follows:

After deleting 7th element:

[ 3 1 2 5 8 7 9 0 1 6 ] => [ 3 1 2 5 8 7 0 1 6 ].

After deleting 7th element again (counting in the same direction, then moving reverse),

[ 3 1 2 5 8 7 0 1 6 ] => [ 3 1 2 5 7 0 1 6 ].

After deleting 7th element again (counting in the same direction, then moving reverse),

[ 3 1 2 5 7 0 1 6 ] => [ 3 1 2 7 0 1 6 ]

Continue doing this until there is only one element left in the list.

Add any necessary methods required in the IntDLList.java file.


TheIntDLList.java and all other files, SLLNode and other are here.

https://dl.dropbox.com/u/3075114/LinkedLists-1.rar

Explanation / Answer

public class LinkRecursion { class Node { public int num; public Node next; public Node(int num) { this.num = num; next = null; } } public String listString(Node head) { if (head == null) return ""; String out = "[ " + head.num; for(Node p = head.next; p != null; p = p.next) { out += ", " + p.num; } return out += " ]"; } public Node deleteNum(Node currentNode, int target, int pos) { if(currentNode == null) // empty list, or reached end of list return currentNode; //
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote