Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Problem 1: (35 points) a) Given two sorted lists, L1 and L2, complete a following procedure in Java to compute: L1 L2 = {

image text in transcribed

Problem 1: (35 points) a) Given two sorted lists, L1 and L2, complete a following procedure in Java to compute: L1 \ L2 = { x 1 x E L1 and x L2 } using only the basic list operators (next(), hasNext(), and compareTo)) and one loop public static > void difference(List L1, List Difference) ListteratorAnyType> iterL1 . L1.1ist Iterator(); Listterator iterL2- L2.1istiterator(); if (iterl1.hasNext() 8& iterL2. hasNext(O itemL1 itemL2 iterL1.next(); iterL2.next); /I YOUR CODE GOES HERE b) Write a method in Java to sort a stack of n integer numbers, s, in descending order static Stack sort(Stack s) To implement this method you must use one more auxiliary stack and you should not make any assumptions about how the stack is implemented. The following are the only functions that should be used to write this program: push, pop, peek, and isEmpty. What is the running time complexity of your method? Justify Important Notes: For this problem, you only need to submit the implementation of two methods in Java (difference and sort) . In the case of your sort method don't forget to indicate (and justify) the running time complexity of your solution

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_2

Step: 3

blur-text-image_3

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

More Books

Students explore these related Databases questions