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

Pseudocode and Java

The document contains pseudocode and Java implementations for various algorithms and mathematical concepts, including selection sort and bubble sort. It outlines the steps for inputting an array, sorting it, and displaying the sorted results. Additionally, it mentions other topics such as binary search, linear search, factorial, Fibonacci, and perfect numbers.

Uploaded by

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

Pseudocode and Java

The document contains pseudocode and Java implementations for various algorithms and mathematical concepts, including selection sort and bubble sort. It outlines the steps for inputting an array, sorting it, and displaying the sorted results. Additionally, it mentions other topics such as binary search, linear search, factorial, Fibonacci, and perfect numbers.

Uploaded by

abiroop.balaji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1) Selection sort pseudocode

2) Binary search
3) Linear search
4) Factorial
5) Even odd numbers
6) Bubble sort
7) Fibonacci
8) Perfect numbers
9) Positive negative
10) Special no
11) Multiplication
12) Sum of n numbers
Selection sort pseudocode
public class SelectionSort {
input N public static void main(String[] args) {
ARRAY = new ARRAY[N] Scanner scanner = new
Scanner(System.in);
System.out.print("Enter the size of the
output "Enter the elements of the array:"
array: ");
loop INDEX from 0 to N - 1
int n = scanner.nextInt();
input ARRAY[INDEX]
int[] array = new int[n];
end loop
System.out.println("Enter the elements of
the array: ");

loop I from 0 to N - 2 for (int i = 0; i < n; i++) {

MIN_INDEX = I array[i] = scanner.nextInt();


}

loop J from I + 1 to N - 1 for (int i = 0; i < n - 1; i++) {

if ARRAY[J] < ARRAY[MIN_INDEX] then int minIndex = i;

MIN_INDEX = J for (int j = i + 1; j < n; j++) {

end if if (array[j] < array[minIndex]) {

end loop minIndex = j;


}

if MIN_INDEX ≠ I then }

TEMP = ARRAY[I] int temp = array[minIndex];

ARRAY[I] = ARRAY[MIN_INDEX] array[minIndex] = array[i];

ARRAY[MIN_INDEX] = TEMP array[i] = temp;

end if }

end loop System.out.println("Sorted array:");


for (int num : array) {

output "Sorted array:" System.out.print(num + " ");

loop INDEX from 0 to N - 1 }

output ARRAY[INDEX] } }

end loop 1) Bubble sort pseudocode


input N
ARRAY = new ARRAY[N]

Selection sort java


output "Enter the elements of the array:"
import java.util.Scanner;
loop INDEX from 0 to N - 1
input ARRAY[INDEX]
end loop

loop I from 0 to N - 2
loop J from 0 to N - I - 2
if ARRAY[J] > ARRAY[J + 1] then
TEMP = ARRAY[J]
ARRAY[J] = ARRAY[J + 1]
ARRAY[J + 1] = TEMP
end if
end loop
end loop

output "Sorted array:"


loop INDEX from 0 to N - 1
output ARRAY[INDEX]
end loop

You might also like