Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the search(int k), insert(int x), delete() function in LinkedList.java ****post screenshot please***** package ds; public class LinkedList { public ListNode head; public LinkedList ()

Implement the search(int k), insert(int x), delete() function in LinkedList.java

****post screenshot please*****

package ds;

public class LinkedList {

public ListNode head;

public LinkedList () {

head = null;

}

/*

* Implement the LIST-SEARCH(L, k) function

*/

public ListNode search (int k) {

}

/*

* Implement the LIST-INSERT(L, x) function

* Note that x is a integer value, not a ListNode

*/

public void insert (int x) {

}

/*

* Implement the LIST-DELETE(L, x) function

*/

public void delete (ListNode x) {

}

/*

* Convert a LinkedList to a string in the format of [#elements]

*/

public String toString () {

String str;

ListNode n;

str = "[";

n = this.head;

while (n != null) {

str += n.key + ",";

n = n.next;

}

str += "]";

return str;

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

LinkedList l;

l = new LinkedList();

for (int i = 0; i < 5; i++)

l.insert(i);

System.out.println(l.toString());

for (int i = 0; i < 2; i++)

l.delete(l.head.next);

System.out.println(l.toString());

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. What information would the team members need?

Answered: 1 week ago

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago