, , , , , , , ,

[SOLVED] Cs 1713 introduction to computer programming ii assignment 4

$25

File Name: Cs_1713_introduction_to_computer_programming_ii_assignment_4.zip
File Size: 565.2 KB

Rate this Assignment

1. (100 pts) Write a program to find the k largest elements of a file. Allocate an array of size
k and while you read the numbers from the file, store the k largest numbers in the array.
When you read the next element from the file, find if the array needs to be modified or not.Consider the below figure as an example. Assume that next element read is 80. Since 80 is
larger than the smallest element, we need to shift elements < 80 to the right by 1 position and create space for 80. We then insert 80 into the new position. 0 1 2 3 4 97 83 0 1 2 3 4 97 83 0 1 2 3 4 97 83 76 65 54 76 65 80 76 65 Figure 1: Insert 80 into 5 largest elements In main() use argc and argv to read the filename and k from the user and compute and print the k largest elements. Name your program assign4.cSample execution of the program is given below. First parameter is filename and second parameter is k. You need to use atoi() in stdlib.h to convert strings to integer. fox01> assign4 a.txt 5
996 980 956 932 929
Submit your program electronically using the blackboard system
The program you submit should be your own work. Cheating will be reported to office of academic
integrity. Both the copier and copiee will be held responsible.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Cs 1713 introduction to computer programming ii assignment 4
$25