Which will emerge fastest in sorting? Python or Rust? Algorithm performance has always been one of the key factors in solving complex real world use cases. We need efficient algorithms especially in the case of sorting huge amounts of data.
Algorithm performance has always been one of the key factors in solving complex real world use cases. We need efficient algorithms especially in the case of sorting huge amounts of data. In this article, I will walk you through how Bubble, Insertion, Quick and Merge sort algorithms are implemented in Python and Rust programming languages to find out if the programming language does matter in getting the edge in performance.
Before continuing with this article, you should have,
Source Code:
import random
import datetime
def BubbleSortAsc(array):
no_swap = True
while no_swap:
no_swap = False
for position in range(0, len(array)-1):
if array[position] > array[position+1]:
## swap
temp = array[position]
array[position] = array[position+1]
array[position+1] = temp
no_swap = True
To Run:
if __name__ == "__main__":
array = [index for index in range(1, 100001)]
random.shuffle(array)
start = datetime.datetime.now()
BubbleSortAsc(array)
end = datetime.datetime.now()
print("It took: ", (end-start).total_seconds()*1000, "ms to sort")
Performance:
sorting-algorithms python-programming evaluating-technology performance rust-programming
Speed in search algo in Python and Rust? Ever wondered if the search algorithms that you have learnt in high school or college/university, would perform differently in different programming languages?
Guide to Python Programming Language
Solving Two programming problems, one with a sorting algorithm and another with OOP in Python.
There are various types of sorting algorithms out there and sometimes it becomes very difficult to understand their internal working without visualization. Hence I decided to visualize these sorting algorithms in python with the help of matplotlib.animations library.
Get to know the most efficient sorting algorithm. Quicksort is a divide and conquer algorithm which relies on a partition operation: to partition an array an element called a pivot is selected. All elements smaller ...