Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the order of complexity of comparing two python lists?

Tags:

python

Assume the lists contain hashable objects only.

BTW, I'm not sure if this question makes sense as I am a complete noob when it comes to complexity and academic stuff.

like image 954
cammil Avatar asked Jul 03 '12 15:07

cammil


1 Answers

The complexity of comparing two lists is O(n) if both lists have length n, and O(1) if the lists have different lengths.

like image 157
Sven Marnach Avatar answered Oct 01 '22 16:10

Sven Marnach