Runtime Comparative Analysis of Java and Python Programs with Algorithms of Different Time Complexities

Session Number

Project ID: CMPS 06

Advisor(s)

Dr. Yun Wang; Bradley University

Discipline

Computer Science

Start Date

19-4-2023 10:50 AM

End Date

19-4-2023 11:05 AM

Abstract

Runtime, one of the crucial metrics for evaluating program performance, differs between Java and Python programs due to their inherent differences, where Java is statically typed and both compiled and interpreted, while Python is dynamically typed and only interpreted. Our study investigates the extent to how features of Java and Python impact execution time of four programs with algorithms of different complexities (O(1), O(n), O(n*log(n)), and O(n2)). In our experiment, we found that the traditional (one-pivot) Quicksort algorithm in Java runs 10 to16 times faster than the one in Python for input sizes ranging from 100,000 to 1,500,000. Additionally, this study discusses how to speed up a Python program of Quicksort using the external library Numpy and Python’s standard library module 'array'. After updating Quicksort in Python, its speed has become significantly faster than Java’s built-in Dual-Pivot Quicksort for input sizes larger than 1000, by a factor of 7 to 9 times. This improvement, as an example, explains why Python is favored in data science and machine learning, despite being slower than Java in general. This study concludes that the choice between Python and Java depends on the specific use cases.

Share

COinS
 
Apr 19th, 10:50 AM Apr 19th, 11:05 AM

Runtime Comparative Analysis of Java and Python Programs with Algorithms of Different Time Complexities

Runtime, one of the crucial metrics for evaluating program performance, differs between Java and Python programs due to their inherent differences, where Java is statically typed and both compiled and interpreted, while Python is dynamically typed and only interpreted. Our study investigates the extent to how features of Java and Python impact execution time of four programs with algorithms of different complexities (O(1), O(n), O(n*log(n)), and O(n2)). In our experiment, we found that the traditional (one-pivot) Quicksort algorithm in Java runs 10 to16 times faster than the one in Python for input sizes ranging from 100,000 to 1,500,000. Additionally, this study discusses how to speed up a Python program of Quicksort using the external library Numpy and Python’s standard library module 'array'. After updating Quicksort in Python, its speed has become significantly faster than Java’s built-in Dual-Pivot Quicksort for input sizes larger than 1000, by a factor of 7 to 9 times. This improvement, as an example, explains why Python is favored in data science and machine learning, despite being slower than Java in general. This study concludes that the choice between Python and Java depends on the specific use cases.