Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The language is Java, Need help changing my One-dimensional array to a two-dimensional array import java.util.Arrays; import java.util.Random; public class ArrayReview { private int[] array;

The language is Java, Need help changing my One-dimensional array to a two-dimensional array

import java.util.Arrays; import java.util.Random;

public class ArrayReview { private int[] array; public ArrayReview(int length) { Random r = new Random(100); array = new int[length]; for(int i =0 ;i

public void setArray(int[] array) { this.array = array; } public void setKthItem(int k, int item) { array[k] = item; } public int pickMaxIndex( int start, int end) { int max = array[start]; int index=start; for(int i = start + 1 ;i< end ;i++) { if(array[i] >= max) { max = array[i]; index=i; } } return index; } public void swap(int i , int j) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } public void selectSort() { int max;int pos; for(int i = 0;imax) { max = array[j]; pos = j; } } swap(i,pos); } } public void printArray() { for(int value:array) System.out.println(value+ " "); } public static void main(String[] args) { ArrayReview a1=new ArrayReview(5); System.out.println(a1); System.out.println(" Index of maximum number from 0 to 4 is: "+a1.pickMaxIndex(0, 4)); a1.swap(2, 3); System.out.println(" After swaping array is : "); System.out.println(a1); a1.selectSort(); System.out.println(" After sorting array is : "); System.out.println(a1); } }

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

What score do you think he would get on Blake and Moutons grid?

Answered: 1 week ago

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago