[Solved] How do nested variable types change time complexity?


  1. nested[1] and nested[2] have no effect whatsoever on the time taken to perform operations on nested[0]. An object has no knowledge of what containers it might be referenced in or what other objects might be in the container with it.

  2. List operations take the same amount of time regardless of what objects are being added, removed, retrieved, or replaced. It doesn’t matter what nested[2] is; nested.pop(2) takes the same amount of time. Hashing a large or highly nested tuple or other hashable object can take longer, so hash-based data structures like dict and set can take longer to work with large or highly nested keys, though there isn’t any such concern with the values.

solved How do nested variable types change time complexity?