Question: Analyze step by step the time complexity(BigOh) of your implementations on Q1 on the two methods containsAll( ), addAll(): @Override public default boolean containsAll(Collection c)
Analyze step by step the time complexity(BigOh) of your implementations on Q1 on the two methods containsAll( ), addAll():
@Override public default boolean containsAll(Collection> c) { // Left as an exercise Iterator>iter=c.iterator(); while(iter.hasNext()){ if(!contains(iter.next())){ return false; } } return true; }
@Override public default boolean addAll(Collection extends E> c) { // Left as an exercise boolean flag=true; for (E element:c){ flag&=add(element); } return true; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
