What is the computational complexity of the following Python code? http://ideone.com/mGBQu
what it does
it's a puzzle, find out :-D
I'm sure ffm would know right away.
idk whats lambda
lambda <parameters> = expression is just syntactic sugar for def identifier(parameters): return expression only difference is that there does not need to be an identifier.
so lambda expressions in Python are simply anonymous functions
and I think they're coming to Java :-D
so you can write messy code just like I did :-D
oops it's lambda <parameters>: expression and if you want to use an identifier, then you write identifier = lambda <parameters>: expression and call it just like you would call a normal function
they can be used in conjunction with the higher order functions like map, reduce, filter etc. for example, reduce(lambda x,y: x+y, map(lambda x: x*x, range(1, 1001))) returns the sum of the squares of every number in the range [1, 1000]
I will guess that the running time is in O(n^2), and maybe \[\Omega(1)\]where n is the size of the list passed to ss, and the best-case is when n = 1.
(assuming lambda calls take constant time)
right @ bmp
Join our real-time social learning platform and learn together with your friends!