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.

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

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:

  1. 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.

  1. 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....

  1. PrintElementsinBothArraysAlgforRandomInput (int A[], int B[])

Design an algorithm to print elements in both arrays where both arrays are in a random   order.

  1. PrintElementsinBothArraysAlgforSortedInput (int A[], int B[])

Design a different algorithm that prints the elements that both arrays where both arrays             are in sorted order.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

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