In this Assignment you need to design, analyze and implement an algorithm to print the elements that appear in both arrays in sorted order. Write a C/Java program to read two arrays of N int values, and print all elements that appear in both arrays in a sorted order. You need to calculate the execution time for your algorithm when the input data is randomly created and when the input data is sorted in ascending order. Your program should implement the following operations: Randomly initialize n int values starting from 0 and store them in array inputData(int X[], int n) Call this function to initialize the values of 2 arrays. Initialize n int values starting from 0 in an ascending order and store these values in array X. inputData(int X[], int n, int increment) Call this function two times to initialize the values of 2 arrays sorted in ascending order with different increment. For example, if the increment value is equal to 5 the values of an array will be: 0, 5, 10, 15, 20,25.... PrintElementsinBothArraysAlgforRandomInput (int A[], int B[]) Design an algorithm to print elements in both arrays where both arrays are in a random order. PrintElementsinBothArraysAlgforSortedInput (int A[], int B[]) Design a different algorithm that prints the elements that both arrays where both arrays are in sorted order.
In this Assignment you need to design, analyze and implement an
You need to calculate the execution time for your algorithm when the input data is randomly created and when the input data is sorted in ascending order.
Your program should implement the following operations:
- Randomly initialize n int values starting from 0 and store them in array
inputData(int X[], int n)
Call this function to initialize the values of 2 arrays.
- Initialize n int values starting from 0 in an ascending order and store these values in array X.
inputData(int X[], int n, int increment)
Call this function two times to initialize the values of 2 arrays sorted in ascending order with different increment. For example, if the increment value is equal to 5 the values of an array will be: 0, 5, 10, 15, 20,25....
- PrintElementsinBothArraysAlgforRandomInput (int A[], int B[])
Design an algorithm to print elements in both arrays where both arrays are in a random order.
- PrintElementsinBothArraysAlgforSortedInput (int A[], int B[])
Design a different algorithm that prints the elements that both arrays where both arrays are in sorted order.
Step by step
Solved in 3 steps with 1 images