# Simulate sorting times for Bubble Sort, Merge Sort, and Quick Sort
set.seed(42)
bubble_sort_times <- rnorm(100, mean = 200, sd = 20)
merge_sort_times <- rnorm(100, mean = 50, sd = 5)
quick_sort_times <- rnorm(100, mean = 40, sd = 4)
# Combine data for plotting
execution_data <- data.frame(
time = c(bubble_sort_times, merge_sort_times, quick_sort_times),
algorithm = rep(c("Bubble Sort", "Merge Sort", "Quick Sort"), each = 100)
)
# Create a histogram
ggplot(execution_data, aes(x = time, fill = algorithm)) +
geom_histogram(binwidth = 5, alpha = 0.6, position = "identity") +
labs(title = "Distribution of Execution Times for Sorting Algorithms",
x = "Execution Time (ms)", y = "Frequency") +
theme_minimal()
