The objective of this question is to generate and read files that contain a list of random numbers. Write a function that generates a file with following parameters: def fillFile(fileSize, fileName): The function should be called to generate files in the following sizes: L000 Fo00 1000 00 2000 01

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

BY USING PYTHON 

You can get source codes of sorting programs from internet. 

QUESTION 1 İS MENTIONED BELOW

The objective of this question is to generate and read files that contain a list of random numbers.
Write a function that generates a file with following parameters:
def fillFile(fileSize, fileName):
The function should be called to generate files in the following sizes:
fileSizes = [1000, 5000, 10000, 25000, 50000, 100000, 200000]
The generated files can have names file1000, file5000, file10000, file25000, file50000, file100000,
file200000. Each file should have serial numbers from 0 to size of file. By using one tenth of file
shuffle numbers among themselves. For example, if your file 100 numbers, choose 10 numbers
randomly and shuffle these numbers.
You can use random.randint(0,fileSize+1000) to generate a random number.
Write another function that reads numbers inside of a file and returns a list.
def readFile(fileName):
The returned list contains the numbers stored in the file.
At each call of fillFile and readFile, record the times before and after the function call as in following
example (import time) :
start = time.time()
fillFile(fileSize, “file" + str(fileSize))
finish = time.time()
runTime = finish – start
Record the run times of functions into a file named “fileStats.txt". The "fileStats.txt" file should
contain entries for run times as follows:
fillFile nl, n2, п3, п4, п5, пб, п7
readFile nl, n2, п3, п4, п5, п6, п7
where n1, n2, n3, n4, n5, n6 and n7 are execution times for file sizes 1000, 5000, 10000, 25000,
50000, 100000, 200000.
Transcribed Image Text:The objective of this question is to generate and read files that contain a list of random numbers. Write a function that generates a file with following parameters: def fillFile(fileSize, fileName): The function should be called to generate files in the following sizes: fileSizes = [1000, 5000, 10000, 25000, 50000, 100000, 200000] The generated files can have names file1000, file5000, file10000, file25000, file50000, file100000, file200000. Each file should have serial numbers from 0 to size of file. By using one tenth of file shuffle numbers among themselves. For example, if your file 100 numbers, choose 10 numbers randomly and shuffle these numbers. You can use random.randint(0,fileSize+1000) to generate a random number. Write another function that reads numbers inside of a file and returns a list. def readFile(fileName): The returned list contains the numbers stored in the file. At each call of fillFile and readFile, record the times before and after the function call as in following example (import time) : start = time.time() fillFile(fileSize, “file" + str(fileSize)) finish = time.time() runTime = finish – start Record the run times of functions into a file named “fileStats.txt". The "fileStats.txt" file should contain entries for run times as follows: fillFile nl, n2, п3, п4, п5, пб, п7 readFile nl, n2, п3, п4, п5, п6, п7 where n1, n2, n3, n4, n5, n6 and n7 are execution times for file sizes 1000, 5000, 10000, 25000, 50000, 100000, 200000.
Perform a benchmark analysis of the following sorting algorithms:
Bubble Sort
Selection Sort
Insertion Sort
Shell Sort
Merge Sort
Quick Sort
Heap sort
You can get source codes of sorting programs from lectures notes. By using the files that you
generated in Question I, read each file and sort file by using each of sorting algorithms. Record the
execution time of each sorting algorithm into a file named “sortStats.txt". The “sortStats.txt" file
should contain entries for execution times as follows:
Вubble_Sort nl, n2, п3, п4, п5, пб, п7
Selection_Sort nl, n2, n3, n4, n5, n6, n7
Insertion_Sort n1, n2, n3, n4, n5, n6, n7
Shell_Sort
Merge_Sort
Quick_Sort
Неар Sort
nl, п2, п3, п4, n5, п6, п7
nl, п2, п3, п4, n5, п6, п7
п1, п2, п3, n4, п5, nб, п7
n1, n2, п3, п4, п5, пб, п7
where n1, n2, n3, n4, n5, n6 and n7 are execution times for file sizes 1000, 5000, 10000, 25000,
50000, 100000, 20000.
Transcribed Image Text:Perform a benchmark analysis of the following sorting algorithms: Bubble Sort Selection Sort Insertion Sort Shell Sort Merge Sort Quick Sort Heap sort You can get source codes of sorting programs from lectures notes. By using the files that you generated in Question I, read each file and sort file by using each of sorting algorithms. Record the execution time of each sorting algorithm into a file named “sortStats.txt". The “sortStats.txt" file should contain entries for execution times as follows: Вubble_Sort nl, n2, п3, п4, п5, пб, п7 Selection_Sort nl, n2, n3, n4, n5, n6, n7 Insertion_Sort n1, n2, n3, n4, n5, n6, n7 Shell_Sort Merge_Sort Quick_Sort Неар Sort nl, п2, п3, п4, n5, п6, п7 nl, п2, п3, п4, n5, п6, п7 п1, п2, п3, n4, п5, nб, п7 n1, n2, п3, п4, п5, пб, п7 where n1, n2, n3, n4, n5, n6 and n7 are execution times for file sizes 1000, 5000, 10000, 25000, 50000, 100000, 20000.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY