C代写/C++代写/linux shell代写: TASK 2

C代写/C++代写/linux shell代写: 这是一个C语言代写和C++代写结合的作业,通过二者结合进一步考察分类算法和linux shell的编写
Once IntListInsertInorder() is working correctly, modify useIntList.c so that it behaves as a sorting program: it reads a list of numbers from its standard input, and writes a sorted version of the numbers to its standard output. This is a simple change to the existing program, and can be accomplished by commenting a couple of lines.

Recompile and check that the new version of usel behaves correctly. Once you’re satisfied, run some tests to compare the time taken by usel with the time taken by the Unix sort command for the same task.

The first thing to do is to check that both commands are producing the same result (otherwise, it’s not useful to compare them). Try the following commands:

$ ./randl 1000 > nums
$ ./usel < nums > out1
$ sort -n < nums > out2
$ diff out1 out2
If the diff command gives no output, then the files have no difference (i.e. the observed output is he same as the expected output). If you try the above a number of times with different sets of numbers each time and get the same result, then you can be more confident that both commands are producing the same result. (However, you cannot be absolutely certain that they will always produce the same result for any input. Why not?)

Note that you need to use the -n option to sort because the default sorting order is lexcial, not numeric. If you don’t use -n, then e.g. 111 is treated as being less than 12. (See man sort for details.)

发表评论

电子邮件地址不会被公开。 必填项已用*标注