question archive Please make search method to find the the highest value in the linked list and then output the highest value Go through the double-ended doubly-linked list to find the largest int value held in any of the links

Please make search method to find the the highest value in the linked list and then output the highest value Go through the double-ended doubly-linked list to find the largest int value held in any of the links

Subject:Computer SciencePrice:3.86 Bought9

Please make search method to find the the highest value in the linked list and then output the highest value

Go through the double-ended doubly-linked list to find the largest int value held in any of the links. If the doubly-linked list is empty or defective in any way, return 0.

I have most of the code written.

Please write the search() method which reports to the main method. 

 

There is no input

 

Use java programming language

 

package linkedList;

import java.util.*;

 

public class Main {

public static void main(String args[] ) throws Exception {

Scanner myscanner = new Scanner(System.in);

int num = Integer.parseInt(myscanner.nextLine());

Link[] array = new Link[num];

for(int i=0;i

array[i]=new Link(Integer.parseInt(myscanner.nextLine()));

}

while(myscanner.hasNext()){

int select=myscanner.nextInt();

int previous=myscanner.nextInt();

int next=myscanner.nextInt();

if(previous!=-1){

array[select].previous=array[previous];

}

if(next!=-1){

array[select].next=array[next];

}

}

LinkedList mylist = new LinkedList();

if(num>0){

mylist.first=array[0];

mylist.last=array[num-1];

}

 

System.out.println(search(mylist));

 

}

 

//don't edit the code above, only edit the search method below

 

public static int search(LinkedList mylist){

/* return the highest value held in any of the links, 0 if defective or empty*/

 

 

      return 0;

}

 

//don't edit the code below, only edit the search method above

 

}

 

class Link{

  public int data;

  public Link next;

  public Link previous;

 

public Link(int input){

data=input;

next=null;

previous=null;

}

}

 

class LinkedList {

  public Link first;

public Link last;

 

  public LinkedList( ){

    first=null;

last=null;

  }

 

  public boolean isEmpty( ){

    return (first==null);

  }

 

public void insertHead(Link insert){

if(isEmpty()){

first=insert;

last=insert;

}else{

first.previous=insert;

insert.next=first;

first=insert;

}

}

}

Option 1

Low Cost Option
Download this past answer in few clicks

3.86 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 9 times

Completion Status 100%

Related Questions