Any tips on how to sort a file with random numbers using the fwrite, fseek, and fscan without using an array? I want to be able to make a copy of the file, sort it in increasing order, and print out the sorted data.
Thanks.
Any tips on how to sort a file with random numbers using the fwrite, fseek, and fscan without using an array? I want to be able to make a copy of the file, sort it in increasing order, and print out the sorted data.
Thanks.
One possibility that i can see to sort the recs in a file with out using arrays is that u create a temporary file (initially blank).
U first scan the entire source file for the smallest valued record (and fix an index there). Once the file is scanned, pick the indexed record and dump it in the other file. Repeat the process for the next record and so on.
Yeah...this is a very search-intensive process, but thats all i can think of right now...
Happy coding...
-Harsha.
Help everyone you can
Read the file into a binary tree and then print it out to the new file with an in-order traversal. The file is sorted because binary trees by nature sort the data inserted into them.
-Prelude
My best code is written with the delete key.