Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you write pseudocode and a flowchart for this java code please import java.util.Arrays; public class part2 { public static void main(String[] args) { int

Can you write pseudocode and a flowchart for this java code please

import java.util.Arrays;

public class part2 { public static void main(String[] args) { int [] arr = {2,9,1,2,6,8}; System.out.println("Original Array: " + Arrays.toString(arr)); int n = arr.length; arr = sort(arr); int e = numUniqueArray(arr); System.out.println("Length of Array 'n' = " + n); System.out.println("Unique numbers in Array 'e' = " + e); int [] uniqueArr = uniqueArray(arr,e); System.out.println("Unique Array: " + Arrays.toString(uniqueArr)); } public static int[] uniqueArray(int[] arr, int e) { int a,b; int i = 0; int[]uniqueArr = new int[e]; for (a = 0; a < arr.length; a++) { for (b = 0; b < a; b++) if (arr[a] == arr[b]) break; if (a == b) { uniqueArr[i] = arr[a]; i++; } } return uniqueArr; } public static int numUniqueArray (int[] x) { int numUnique = 1; for(int i = 1; i < x.length; i++) { if(x[i - 1] != x[i]) ++numUnique; } return numUnique; } public static int[] sort (int[] x){ for (int a = 0; a < x.length; a++) { for (int b = a + 1; b < x.length; b++) { int tmp = 0; if (x[a] > x[b]) { tmp = x[a]; x[a] = x[b]; x[b] = tmp; } } } return x; } }

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

Students also viewed these Databases questions

Question

Write short notes on Interviews.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago