You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arrays: in python it is kind of list defined by [], heterogeneous memory location unlike other programming languages. But python makes it contiguous by saving the memory reference of the array element in the array instead of saving the element itself.
Say, 'a' in ['a', 'b', 'c'] code does a Linear Search operation. If sorted then we could have run binary search but that incurs a cost again. So, languages mainly focuses on linear search operations if the array is small.
Specific Data Structures can solve specific problems. We can create our own data structures.
Say arrays: pretty good at accessing because O(1). But bad at inserting and deleting which is O(N)
LinkedList is better than arrays in inserting & deleting but have some caveats. But if we do a lot of insert & delete & few access. LinkedList will be a better choice.
Algorithms
The maximum recursion depth in Python is 1000. READ
Binary Search space complexity is constant O(1), first & last (high & low) index being updated.
Recursive version of binary search is O(log N). But here language also plays a role. In python maximum recursion depth is 1000. Python don't have tail call optimization life Swift.
In python iterative binary search will be a better choice.