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
- Case-specific sorting of Strings in O(n) time and O(1) space
- Program for sorting variables of any data type
- time.h header file in C with Examples
- What is data type of FILE in C ?
- How to delete data from file in Python
- Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages)
- Know Your Sorting Algorithm | Set 2 (Introsort- C++’s Sorting Weapon)
- Sorting objects using In-Place sorting algorithm
- Manufacturing Execution Systems
- Python program to reverse the content of a file and store it in another file
- Difference between Data Scientist, Data Engineer, Data Analyst
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.