Posts

Showing posts with the label time complexity

Time Complexity Analysis

Image
How to analyze Time Complexity?                        Running time of an algorithm depends upon multiple factors: Single vs Multiple Processors(It is using a single processor, then we cannot run our program parallelly) Read and write speed of the program to the memory or the disk. 32-bit vs 64-bit architecture Configuration of the machine Input Consider a Model Machine with: Single Processor 32 bit Sequential Execution 1 unit of time for arithmetic and logical operations 1 unit of time for assignment and return statements Let's define a function which calculates the sum of two numbers: sum(n1, n2):     return (a+b) Now, we know that 1 unit of time is taken for arithmetic operations and 1 unit of time for return statement. Therefore, irrespective of the inputs, the above program is executed in two units of time. Let's define a function which calculated the sum of the list: sum(list, n):     total = 0  ...