Question 1: Searching and Sorting

This assignment will expose you to the experience of working with the following topics: data files, arrays, searching and sorting in C. Write a program that reads integer data from an input file into an array of integers. Your program should keep reading data until it reaches the end of the data file. you may read a maximum of 150 numbers. The data file is called ``input.dat''.

Take note that the numbers in the data file may be repeated but you may not accept more than one copy of each number you read. Thus, for each number the program reads, it must, first, search the array if the number is already there or not. If it is, then ignore it and go read another number, else insert this new number at the end of the array and keep going.

Once the data file is empty (i.e all input has been read), the program has to sort the numbers in the array using either the insertion sort algorithm or the selection sort algorithm. Note that both algorithms were given to you in class. Upon successful completion of the sorting process, print the sorted array in the following manner:

You should print ten numbers per line, as many lines as necessary.

A copy of the output is to be send to an output file called "sorted.out". The data to be saved in the input file is given next.

   80  563  173   11  552  241   69  333  324  659
  617  993  868  849  207  546  745  326  655  166
   65  547  557  110  215  756  408  985  659  154
  400  443  844  644   85  162  531  632  306  211
   65  612   87  171  419  537  389  614   27  187
  915  804  722   37  375  725  312  351  895  797
  612  486  482  894  948  646  719  512  464  563
  116  214  748  844  788  689  596  970  374   54
  953  178  381  252  322  703  364  647  197  139
  624  188  315  871  336  744  770  835  282  475
  287   87  622  336  209  906  354   89  980  423
  399  426  191   10  488   56  465  915  250  876
  743  868  204  580  762  650  548  311  765  868
  935  228  763  396  651   83  860  241  870  171



Instructor Code - CS208
Tue Mar 24 16:12:57 EST 1998