Showing posts with label time-complexity. Show all posts
Showing posts with label time-complexity. Show all posts

Friday, May 18, 2012

If strings are immutable in .NET, then why does Substring take O(n) time?


Given that strings are immutable in .NET, I'm wondering why they have been designed such that string.Substring() takes O( substring.Length ) time, instead of O(1)?