Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

question is on first page and you have to do solution by using the second page in that you have to write a code of

question is on first page and you have to do solution by using the second page in that you have to write a code of the question. image text in transcribed
image text in transcribed
[Assignment] 1 - Lists Available from: Friday, 21 January 2022, 7:00 PM Due date: Friday, 28 January 2022, 7:00 PM Requested files: Solution.java (Download) Type of work: 8 Individual work Reduction by automatic evaluation: 2 Free evaluations: 10 In "Topic-2 Lists", you have learned linked lists and the basic operations of them. Let's do something useful! Suppose you are given two linked lists of integers, the values in which are non-decreasing (e.g., 1 -> 3 -> 5 and 2-> 4 -> 6). Try to implement a method to merge these two lists by splicing together their nodes so that we can get a sorted list that contains all elements (e.g., 1 -> 2 -> 3 -> 4 -> 5 -> 6). Inputs: the header nodes of two sorted linked lists; Outputs: the header node of the merged linked list. Note: The ListNode class is provided in the template file. Please keep it when you submit the code. Also, please don't modify other existing class/method headers in the template file. Hints: Consider edge cases (e.g., null inputs). 32 Editing 1 1 2 3 4 5 6 7 8 9 public class Solution 10 11 12 13 14 15 The definition for the linked list. DO NOT modity this class. */ public static class ListNode int value: ListNode next; ListNode (int value) this.value - value; 1 /* + The method for you to implement. DO NOT change the method header. */ public ListNode merge (ListNode 11, ListNode 12) // TODO return null; 3 I /** The main method is for test only and won't be evaluated. */ public static void main(String[] args) { Solution solution = new Solution (); ListNode a = new ListNode(1); ListNode b = new ListNode (2); ListNode nextA - a; ListNode nextB = b; for (int i = 1; i

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

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

Students also viewed these Databases questions

Question

What are some career options in the hotel industry?

Answered: 1 week ago