Python Forum
HELP - Calculating the complexity of my algorithm.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP - Calculating the complexity of my algorithm.
#2
If the bit-strings have a bounded/"constant" length then it's just O(len(L)). Otherwise it's O(sum(map(len, L))) if you treat L as having real bit-strings instead of numbers.

By the way, you have a lot of indirection in your code. You create lists and append 1 to them to later add those 1s to a counter. You can skip putting 1s in the lists and just increment the counter directly. I would also in-line the str() call, no need for an extra list there.
Reply


Messages In This Thread
RE: HELP - Calculating the complexity of my algorithm. - by micseydel - Dec-26-2018, 10:54 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020