04.01.2015 Views

Recursion

Recursion

Recursion

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Efficiency of Binary Search and<br />

the Comparable Interface<br />

• At each recursive call we eliminate half the array<br />

elements from consideration<br />

• O(log 2 n)<br />

• Classes that implement the Comparable interface must<br />

define a compareTo method that enables its objects to<br />

be compared in a standard way<br />

• CompareTo allows one to define the ordering of<br />

elements for their own classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!