Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do it in C. NOT C++. HW2 Problem 0 Write a C code to sort n positive integer numbers (including zero) from smallest to

Please do it in C. NOT C++.image text in transcribed

HW2 Problem 0 Write a C code to sort n positive integer numbers (including zero) from smallest to largest using following sort algorithm. Bubble Sort Algorithm Steps are: I. In each iteration, compare adjacent numbers (starting from first and second numbers) and swap them if ith number is bigger than (i + 1)th number. II. repeat step I to reach to (n)th number. III. Repeat steps I and II n times. example: 5 0213 05213 02513 02153 02135 02135 01235 01235 and continues... your C code should have following features: a. You need to read (n) from command line. b. Use the random number generator in C ( srand() and rand() % 1000 ) to generate random positive integer numbers between 0 and 1,000. c. Your C code requires to allocate n elements for numbers on the memory, d. Sort operation needs to get implemented using a function. e. Measure the execution time for different values of n and complete the following table and draw a bar-chart for it using Microsoft Excel. n = 40,000 Execution Time n = 50,000 n = 100,000 n = 200,000 Operation Bubble Sort HW2 Problem 0 Write a C code to sort n positive integer numbers (including zero) from smallest to largest using following sort algorithm. Bubble Sort Algorithm Steps are: I. In each iteration, compare adjacent numbers (starting from first and second numbers) and swap them if ith number is bigger than (i + 1)th number. II. repeat step I to reach to (n)th number. III. Repeat steps I and II n times. example: 5 0213 05213 02513 02153 02135 02135 01235 01235 and continues... your C code should have following features: a. You need to read (n) from command line. b. Use the random number generator in C ( srand() and rand() % 1000 ) to generate random positive integer numbers between 0 and 1,000. c. Your C code requires to allocate n elements for numbers on the memory, d. Sort operation needs to get implemented using a function. e. Measure the execution time for different values of n and complete the following table and draw a bar-chart for it using Microsoft Excel. n = 40,000 Execution Time n = 50,000 n = 100,000 n = 200,000 Operation Bubble Sort

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions