Solve Following Programming Problems:: (There Will Be 10% Class Evaluation in Lab 3 Based On Lab 1 and Lab 2)
Solve Following Programming Problems:: (There Will Be 10% Class Evaluation in Lab 3 Based On Lab 1 and Lab 2)
1. WAP that will randomly generate 50000 integer numbers in the range -250 to 249. Write those
numbers in a text file named “in.txt”.
2. Sort (in ascending order) all the integer numbers in the file “in.txt” using insertion sort. Use separate
function for INSERTION_SORT. Call it from main function. Save the sorted output into another text
file named “out.txt”.
3. Find the actual running time of insertion-sort for the given input. [use time.h header, clock variable
and clock function]
Pseudocode:
4. Now do linear search on the data in “out.txt”. Maintain following separate functions:
a. input // read all integers from “out.txt” and load it into an array
(for array, perform dynamic memory allocation)
b. lin_search // do linear search against a KEY integer and return its index / array position
// if not found then return -1
c. show // Show search result (found or not found)
[There will be 10% class evaluation in Lab 3 based on Lab 1 and Lab 2]
Page 1 of 1