Search code examples
erlangcomplexity-theory

Complexity to determine the size of an Erlang's binary


I know that, for a list, we have to traverse the entire list and then determine the size of it?

What is the complexity to determine the size of a binary in Erlang?


Solution

  • byte_size/1 (the command to measure binary stuff) executes in constant time irrelevant to the size of the binary, while length of a list is proportional to the size of the list.

    See 3 Common Caveats for reference