Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am trying to utilize these functions but I do not know how to get them to work. Can you also make the function that
I am trying to utilize these functions but I do not know how to get them to work. Can you also make the function that prints all of the nodes data to work.
I am using the code below for zybooks and am trying to implement it to java:
ListAppend(list, newNode) { if (listhead == null) { // List empty listhead = newNode listtail = newNode } else{ listtailnext = newNode listtail = newNode } }
ListPrepend(list, newNode) { if (listhead == null) { // list empty listhead = newNode listtail = newNode } else { newNodenext = listhead listhead = newNode } }
ListInsertAfter(list, curNode, newNode) { if (listhead == null) { // List empty listhead = newNode listtail = newNode } else if (curNode == listtail) { // Insert after tail listtailnext = newNode listtail = newNode } else { newNodenext = curNodenext curNodenext = newNode } }
ListRemoveAfter(list, curNode) { // Special case, remove head if (curNode is null && listhead is not null) { sucNode = listheadnext listhead = sucNode if (sucNode is null) { // Removed last item listtail = null } } else if (curNodenext is not null) { sucNode = curNodenextnext curNodenext = sucNode if (sucNode is null) { // Removed tail listtail = curNode } } }(1) SinglyLinkedList.java 8 SinglyLinkedListNode.java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started