0% found this document useful (0 votes)
2 views4 pages

Array Assignment Java

Uploaded by

Gurvindar Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Array Assignment Java

Uploaded by

Gurvindar Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Array Java

Assignment Questions
Assignment Questions
Q1. Calculate the product of all the elements in the given array.

Q2. Find the second largest element in the given Array in one pass.

Q3. Find the minimum value out of all elements in the array.

Q4. WAP to find the duplicate elements from the given array of elements.

Q5. WAP to find the smallest missing positive element in the sorted Array. (take the array as input)

Predict the output.

public class Main {

public static void main(String[] args) {

int[] sub = new int[50];

for (int i = 0; i <= 48; i++) {

sub[i] = i;

[Link](sub[i]);

Q6. Count the number of elements strictly greater than x.

Q7. WAP to find the largest three elements in the array.

Q8. Check if the given array is sorted or not

Q9. Find the difference between the sum of elements at even indices to the sum of elements at odd indices.

Q10. Given an array of integers, change the value of all odd indexed elements to its second multiple and

increment all even indexed values by 10.

Q11. Find the unique number in a given Array where all the elements are being repeated twice with one value

being unique.

Q12. If an array arr contains n elements, then check if the given array is a palindrome or not .

Q13. Find the error.

double getAverage(int arr[], int size);

public static void main(String[] args) {

int[] balance = {1000, 2, 3, 17, 50};

double avg;

avg = getAverage(balance[0], 5);

[Link]("Average value is: " + avg);

Java + DSA
Assignment Questions
Q14. You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m

and n, representing the number of elements in nums1 and nums2 respectively.

Merge nums1 and nums2 into a single array sorted in non-decreasing order.

Q15. Count the number of triplets whose sum is equal to the given value x.

Q16. Find the factorial of a large number.

Hint :- use an array to store every digit of answer.

Q17. Find the first non-repeating element in the array .

Java + DSA
THANK

YOU !

You might also like