Prerequisite: Selection Sort
In this article, we are going to apply selection sort algorithm, in which the source of input is A FILE CONTAINING 10000 INTEGERS and output will be the total time taken to sort.
Important functions to be used:
- rand(): Used to generate random numbers.
- fopen(): Used to open file .
- fscanf(): Used to scan data from file .
- clock(): Return the number of clock cycle
Program to generate random number in a file “random.txt”
- clock_t or Clock ticks are units of time of a constant but system-specific length, as those returned by function clock.
Algorithm for this program:
- Open the file using fopen().
- Scan the file and copy it to the array using fscanf().
- Apply any sorting algorithm that you want.
- Print to console.
Below are the implementation of above algorithm.
- Measuring script execution time in PHP
- Measure execution time with high precision in C/C++
- Time Complexities of all Sorting Algorithms
- Program for sorting variables of any data type
- What is data type of FILE in C ?
- Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages)
- Know Your Sorting Algorithm | Set 2 (Introsort- C++’s Sorting Weapon)
- Difference between Data Scientist, Data Engineer, Data Analyst
- Sorting Big Integers
- Alternative Sorting
- Sorting Terminology
- External Sorting
- Pancake sorting
- Sorting in Java