code using java
---------------------------------------------------------------------------------------------------------------------------------------------
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package max_min_java;
/**
*
* @author Kamal
*/
public class Max_min_java {
/**
* @param args the command line arguments
*/
static void swap(int arr[],int i,int j)
{
int temp;
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
public static void main(String[] args) {
// TODO code application logic here
int arr[]={1,2,30,50,6,7,8};
int n=arr.length-1;
System.out.println(n);
int min=0;
int max=n;
int j;
while(max>min)
{
for(j=min;j<=max;j++)
{
if(arr[j]<arr[min])
swap(arr,j,min);
if(arr[j]>arr[max])
swap(arr,j,max);
}
min=min+1;
max=max-1;
}
System.out.println("min value is " +min);
System.out.println("max value is "+max);
}
}
--------------------------------------------------------------------------------------------------------------------------------------------
Output
Pseudocode to code in java . Pseudocode: ARRAY a e..n] . min = 0 · max...
Prove that is an integer for all n > 0.
Using the pseudocode answer these questions
Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do if A[i]A[i+1] > A[i+2) then return i it i+1 return -1 4. Calculate how many times the comparison A[i]A[i+1] > A[i+2] is done for a worst-case input of size n. Show your work. 5. Calculate how many times the comparison A[i]A[i+1] > A[i+2] is done for a best-case input of size n. Show your work.
Use the Principle of Mathematical Induction to prove that (2i+3) = n(n + 4) for all n > 1.
When the Java source code below is executed, how many times is the boolean expression (j > 0) evaluated? int i 1; do { int j 35; while (j > 0) { j = j / 2; = } i += 1; } while (i <= 3); 18 none of the other answers are correct 0 6 36
this is a while array mystery from java. please help me to write
the code for this question to run it on eclipse !! I want the full
code to run this program !!
Consider the following method: public static void arrayMystery (int[] a) { for (int i = a. length - 1; i >= 1; i--) { if (a[i] > ali - 1] + 10) { ali - 1] = a[i - 1] + 5; Indicate in the right-hand...
java by the way
What is the value of the variable y after the following code is executed? int x = 10; int y = 0; while (x > 0) { x = x / 2; y++; } 4 3 2 1
Using the pseudocode answer these questions
Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do if A[i]A[i+1] > A[i+2) then return i it i+1 return -1 1. Describe what it does and compute what value is returned when the input is the list {1, 2, 3, 4, 5}. (Hint: We're using 0-based array indexing, so 0 would represent the index of the first element, 1 the second element, etc.) 2. Identify and describe the worst-case input. 3. Identify and...
1. Suppose that an array al] is a max-heap that contains the distinct integer keys 1, 2,.., N with N> 7. The key N must be in gl1] and the key N-1 must be in either al2) or al3) a. Give all possible positions for the key N-2 as a function of N. b. Repeat the same question for the key 2
Question 68 (Mandatory) (1 point) When the Java source code below is executed, how many times is the boolean expression (j > 0) evaluated? = int i 1; int p 0; while (i <= 2) for(int j = 28; (j > 0); j /= 2) { p+= 5; { } i i + 1; مه none of the other answers are correct 12 6 18
need help writing code to make this gui in java
To review the basics of user interfaces Directions Create an interface for a program that helps a group of people to calculate how much each of them owes for a restaurant meal that looks like the one below. The interface does not need to do anything in response to user clicks.