[Solved] : ListIterator

30 $

File Name: :_ListIterator.zip
File Size: 131.88 KB

SKU: [Solved] : ListIterator Category: Tag:

Or Upload Your Assignment Here:


Given two nonempty sorted lists, L1 and L2.

(a) a following method in Java that prints true if L2 ⊆ L1, and false otherwise. In

your implementation you can use only the basic list operators (next(), hasNext(), and

compareTo()).

Remember that L2 ⊆ L1 if for all x ∈ L2, x ∈ L1.

public static <AnyType extends Comparable<? super AnyType>>

boolean subset(List<AnyType> L1, List<AnyType> L2)

{

ListIterator<AnyType> iterL1 = L1.listIterator();

ListIterator<AnyType> iterL2 = L2.listIterator();

// get first item in each list

if ( iterL1.hasNext() && iterL2.hasNext() )

{

itemL1 = iterL1.next();

itemL2 = iterL2.next();

}

// YOUR CODE GOES HERE

}

(b) What is the running time complexity of your method?

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] : ListIterator
30 $