- This is a program for insertion sort
- The programming language used is ruby
- Data from the files are read
- Output is shown in a file
- Total time taken for sorting is shown
for i in 1…(array.length)
j = i
while j > 0
if array[j-1] > array[j]
temp = array[j]
array[j] = array[j-1]
array[j-1] = temp
j = j – 1
output_file = File.open(“output.txt”, “w+”)
file = File.open(“input.txt”)
data = file.read
array = data.split(“,”).map(&:to_i)
start_time = Time.now.to_i
sorted = insertion_sort(array)
end_time = Time.now.to_i
total_time = end_time – start_time
People are Loving
What is an IP Addressing? Can I Trace Location By Using IP Address
We all mobile phone and computer user need to know that all of us has an unique virtual address attached...
Best 5G Mobile Phones for 2021
Best 5G mobile phones is in the rivalry at this current moment. Well famous populars brands are in this game...
How to transfer data from your old iPhone to new one
Transfer data from your old iphone to new one In iOS world, currently there is best iPhone line up i.e...
Step-wise Instructions to Discover Lost Apple Watch
Sometimes people lost their valuable gadgets in house, office or somewhere concerned. In such situation they may get frustrate and...
Background Processing in Linux. Here is what you need to know!
Introduction of Process Process is an instance of program. A new process is started when you gibe any command to...