SilkyFalcon

Generation

time complexityFri, 25 Nov 2022

ps aux | grep ssh | awk '{print $2}' | xargs kill -9

### How to deal with time complexity? - Use data structures with good time complexity for basic operations. - Use libraries with good time complexity for basic operations. - Measure time complexity of the code. - Look for bottlenecks. - Think about time complexity before writing the code. ### Space Complexity - Space complexity of an algorithm quantifies the amount of space or memory taken by an algorithm to run as a function of the length of the input. - Space complexity needs to be taken seriously for multi-user systems, embedded systems, and systems where memory is at a premium. - Space complexity includes both Auxiliary space and space used by input. - Auxiliary space is the extra space or temporary space used by an algorithm. - Space complexity of an algorithm is mostly the function of input size. - Example: If the input size is n, then space complexity can be O(1), O(n), O(n2), O(log n), O(n log n), etc. - Space complexity can be defined as a function relating the input length to the space required by the algorithm.

Questions about programming?Chat with your personal AI assistant