Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. Write a program, SubArrays.java, that asks the user to enter two arrays, then checks if the second array is a subarray of the first.

image text in transcribed

6. Write a program, SubArrays.java, that asks the user to enter two arrays, then checks if the second array is a subarray of the first. To read the two arrays, the user should be prompted to enter a positive integer n followed by n integers for the first array, then another integer m followed by m integers for the second array. You need to implement the following method public static boolean isSubarray (int] al, int[] a2) this method checks if a2 is a subarray in a1 Note: You are not allowed to use strings to solve this problem Sample Run 1: Enter a positive integer n: 5 Enter 5 integers: 5 438 6 Enter a positive integer m: 3 Enter 3 integers: 43 8 4, 3, 8) is a subarray of (5, 4, 3, 8, 6) Sample Run 2: Enter a positive integer n: 5 Enter 5 integers: 5 438 6 Enter a positive integer m: 3 Enter 3 integers: 4 3 4 4, 3, 4) is not a subarray of 15, 4, 3, 8, 6)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

Strong analytical, communication, and problem-solving skills

Answered: 1 week ago