What is the Ordo for a java equals method? We dont know what type the objects that are being compared are. Does it make it a O(1) because its constant time for comparing object?
example:
X.equals(Y)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It completely depends on the type of the object. An object with
Nrelevant sub-data will beO(N).For example,
List.equals()isO(n)wheren = size(). However, if each element of the list is a list of sizem, then it will beO(n*m).