Computational complexity of higher order functions?

The map and filter seem to be linear O (n) because they only need to go through once, but does their complexity depend on the function being passed? For example, two examples below the same order?

map (+) list

map (complex_function) list
+4
source share
3 answers

, , O(f(n)), , O(1). , n , , : . , / / ..

, g, g h ..., h - , ... - . - g, O(f(n)), O(f(n)) * CostH, CostH h ,

, CostH , h: , O(f(n)) . h, , , h , :

foo :: Int -> Tree ()
foo 0 = Tree []
foo m = Tree [t,t] where t = foo (m-1)

, 2^m, m ( ). 3^m b^m b*m .

- . ,

g :: (a -> Int) -> [a] -> Int

, g h [...] h , . , sortBy h [...] h .

, , , . , .

+5

, , () , - n.

n?

n - , - . ( ) - , .

, map filter n. , , n .

(: , map filter, , , , .)

+5

., ,

, . - .

Bull. Symbolic Logic 3 (1997), no. 4, 469-448. http://projecteuclid.org/euclid.bsl/1182353537 .

+3
source

All Articles