Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hello, can you help me with this exercise. I'm trying to practice it. thank you, import java.util.Collection; public interface Tree < E > extends Collection

hello, can you help me with this exercise. I'm trying to practice it.

thank you,

import java.util.Collection; public interface Tree<E> extends Collection<E> {  /** Return true if the element is in the tree */  public boolean search(E e);  /** Insert element e into the binary tree  * Return true if the element is inserted successfully */  public boolean insert(E e);  /** Delete the specified element from the tree  * Return true if the element is deleted successfully */  public boolean delete(E e);   /** Get the number of elements in the tree */  public int getSize();     /** Inorder traversal from the root*/  public default void inorder() {  }  /** Postorder traversal from the root */  public default void postorder() {  }  /** Preorder traversal from the root */  public default void preorder() {  }    @Override /** Return true if the tree is empty */  public default boolean isEmpty() {   return this.size() == 0;  }  @Override  public default boolean contains(Object e) {   return search((E)e);  }   @Override  public default boolean add(E e) {   return insert(e);  }   @Override  public default boolean remove(Object e) {   return delete((E)e);  }   @Override  public default int size() {   return getSize();  }  @SuppressWarnings("unchecked") @Override  public default boolean containsAll(Collection c) {   // Left as an exercise    return true;  } @SuppressWarnings("unchecked") @Override  public default boolean addAll(Collection c) {   // Left as an exercise     return true;  } @SuppressWarnings("unchecked") @Override  public default boolean removeAll(Collection c) {   // Left as an exercise    return true;  } @SuppressWarnings("unchecked") @Override  public default boolean retainAll(Collection c) {   // Left as an exercise    return true;    }  @Override  public default Object[] toArray() {   // Left as an exercise    return temp;  } @SuppressWarnings("unchecked") @Override  public default  T[] toArray(T[] array) {   // Left as an exercise    return array;  }  } 

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

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions