Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is this O(1) or O(n)?
#3
Quote:O(1) (n being the length of str1 or str2) would mean that the calculation time is independent of the length of str1 or str2
I only came to a conclusion of O(1) because, im not looping through the entire string str1 or str2. Since im using list slicing technique, from an application respective it appears that each line of code in function zigzag was touched once. Do you still believe its O(n)?

I agree with the space complexity.
Reply


Messages In This Thread
Is this O(1) or O(n)? - by hshivaraj - Dec-17-2017, 02:36 PM
RE: Is this O(1) or O(n)? - by squenson - Dec-17-2017, 03:54 PM
RE: Is this O(1) or O(n)? - by hshivaraj - Dec-17-2017, 04:23 PM
RE: Is this O(1) or O(n)? - by Mekire - Dec-17-2017, 05:20 PM
RE: Is this O(1) or O(n)? - by hshivaraj - Dec-17-2017, 05:26 PM
RE: Is this O(1) or O(n)? - by wavic - Dec-17-2017, 05:32 PM
RE: Is this O(1) or O(n)? - by micseydel - Dec-17-2017, 08:50 PM

Forum Jump:

User Panel Messages

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