From c6477b4fae022dd767ed47758d44d8ed46cbca54 Mon Sep 17 00:00:00 2001 From: Thomas Leavy Date: Wed, 26 Jun 2024 22:45:04 +0000 Subject: [PATCH 1/2] Remove files from master branch --- BubbleSort.java | 75 ---------------------------------------------- InsertionSort.java | 34 --------------------- SortingApp.java | 47 ----------------------------- 3 files changed, 156 deletions(-) delete mode 100644 BubbleSort.java delete mode 100644 InsertionSort.java delete mode 100644 SortingApp.java diff --git a/BubbleSort.java b/BubbleSort.java deleted file mode 100644 index 94a672f..0000000 --- a/BubbleSort.java +++ /dev/null @@ -1,75 +0,0 @@ -public class BubbleSort { - - public int basicAscending(int[] collection) { - int collectionLen = collection.length; - int comparisons = 0; - - for (int i = 0; i < collectionLen; i++) { - for (int j = 0; j < (collectionLen - 1); j++) { - comparisons++; - if (collection[j] > collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - } - } - } - return comparisons; - } - - public int basicDescending(int[] collection) { - int collectionLen = collection.length; - int comparisons = 0; - - for (int i = 0; i < collectionLen; i++) { - for (int j = 0; j < (collectionLen - 1); j++) { - comparisons++; - if (collection[j] < collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - } - } - } - return comparisons; - } - - public int endAfterNoSwapsAscending(int[] collection) { - int collectionLen = collection.length; - boolean isSwapped = true; - int comparisons = 0; - int i = 0; - - for (i = 0; (i < collectionLen) && (isSwapped); i++) { - isSwapped = false; - for (int j = 0; j < (collectionLen - 1); j++) { - comparisons++; - if (collection[j] > collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - isSwapped = true; - } - } - } - return comparisons; - } - - public int optimisedAscending(int[] collection) { - int collectionLen = collection.length; - int comparisons = 0; - - for (int i = 0; i < collectionLen; i++) { - for (int j = 0; j < (collectionLen - 1 - i); j++) { - comparisons++; - if (collection[j] > collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - } - } - } - return comparisons; - } - -} diff --git a/InsertionSort.java b/InsertionSort.java deleted file mode 100644 index 3eac796..0000000 --- a/InsertionSort.java +++ /dev/null @@ -1,34 +0,0 @@ -public class InsertionSort { - - public int ascending(int[] collection) { - int comparisons = 0; - - for (int i = 1; i < collection.length; i++) { - int key = collection[i]; - int j; - for (j = (i - 1); (j >= 0) && (collection[j] > key); j--) { - comparisons++; - collection[j + 1] = collection[j]; - } - collection[j + 1] = key; - } - System.out.println("This was completed with a total of " + comparisons + " iterations!"); - return comparisons; - } - - public int descending(int[] collection) { - int comparisons = 0; - - for (int i = 1; i < collection.length; i++) { - int key = collection[i]; - int j; - for (j = (i - 1); (j >= 0) && (collection[j] < key); j--) { - comparisons++; - collection[j + 1] = collection[j]; - } - collection[j + 1] = key; - } - System.out.println("This was completed with a total of " + comparisons + " iterations!"); - return comparisons; - } -} diff --git a/SortingApp.java b/SortingApp.java deleted file mode 100644 index 9b0e793..0000000 --- a/SortingApp.java +++ /dev/null @@ -1,47 +0,0 @@ -public class SortingApp { - - public static String toString(int collection[]) { - String temp = "["; - for (int i = 0; i < collection.length; i++) { - temp += collection[i]; - if (i < (collection.length - 1)) { - temp += ", "; - } - } - temp += "]"; - return temp; - } - - public static void bubbleSort() { - int collection[]; - int iterations; - BubbleSort bubble = new BubbleSort(); - - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.basicAscending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.basicDescending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.endAfterNoSwapsAscending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.optimisedAscending(collection); - - } - - public static void insertionSort() { - int collection[]; - int iterations; - InsertionSort insert = new InsertionSort(); - - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = insert.ascending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = insert.descending(collection); - - } - - public static void main(String[] args) { - bubbleSort(); - insertionSort(); - } -} From 7d9e479c4fe705c569651b2e87177328e373ddc3 Mon Sep 17 00:00:00 2001 From: Thomas Leavy Date: Wed, 26 Jun 2024 22:46:20 +0000 Subject: [PATCH 2/2] Remove BubbleSort folder from master branch --- BubbleSort/BubbleSort.java | 75 ----------------------------------- BubbleSort/InsertionSort.java | 34 ---------------- BubbleSort/SortingApp.java | 47 ---------------------- 3 files changed, 156 deletions(-) delete mode 100644 BubbleSort/BubbleSort.java delete mode 100644 BubbleSort/InsertionSort.java delete mode 100644 BubbleSort/SortingApp.java diff --git a/BubbleSort/BubbleSort.java b/BubbleSort/BubbleSort.java deleted file mode 100644 index 94a672f..0000000 --- a/BubbleSort/BubbleSort.java +++ /dev/null @@ -1,75 +0,0 @@ -public class BubbleSort { - - public int basicAscending(int[] collection) { - int collectionLen = collection.length; - int comparisons = 0; - - for (int i = 0; i < collectionLen; i++) { - for (int j = 0; j < (collectionLen - 1); j++) { - comparisons++; - if (collection[j] > collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - } - } - } - return comparisons; - } - - public int basicDescending(int[] collection) { - int collectionLen = collection.length; - int comparisons = 0; - - for (int i = 0; i < collectionLen; i++) { - for (int j = 0; j < (collectionLen - 1); j++) { - comparisons++; - if (collection[j] < collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - } - } - } - return comparisons; - } - - public int endAfterNoSwapsAscending(int[] collection) { - int collectionLen = collection.length; - boolean isSwapped = true; - int comparisons = 0; - int i = 0; - - for (i = 0; (i < collectionLen) && (isSwapped); i++) { - isSwapped = false; - for (int j = 0; j < (collectionLen - 1); j++) { - comparisons++; - if (collection[j] > collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - isSwapped = true; - } - } - } - return comparisons; - } - - public int optimisedAscending(int[] collection) { - int collectionLen = collection.length; - int comparisons = 0; - - for (int i = 0; i < collectionLen; i++) { - for (int j = 0; j < (collectionLen - 1 - i); j++) { - comparisons++; - if (collection[j] > collection[j + 1]) { - int temp = collection[j]; - collection[j] = collection[j + 1]; - collection[j + 1] = temp; - } - } - } - return comparisons; - } - -} diff --git a/BubbleSort/InsertionSort.java b/BubbleSort/InsertionSort.java deleted file mode 100644 index 3eac796..0000000 --- a/BubbleSort/InsertionSort.java +++ /dev/null @@ -1,34 +0,0 @@ -public class InsertionSort { - - public int ascending(int[] collection) { - int comparisons = 0; - - for (int i = 1; i < collection.length; i++) { - int key = collection[i]; - int j; - for (j = (i - 1); (j >= 0) && (collection[j] > key); j--) { - comparisons++; - collection[j + 1] = collection[j]; - } - collection[j + 1] = key; - } - System.out.println("This was completed with a total of " + comparisons + " iterations!"); - return comparisons; - } - - public int descending(int[] collection) { - int comparisons = 0; - - for (int i = 1; i < collection.length; i++) { - int key = collection[i]; - int j; - for (j = (i - 1); (j >= 0) && (collection[j] < key); j--) { - comparisons++; - collection[j + 1] = collection[j]; - } - collection[j + 1] = key; - } - System.out.println("This was completed with a total of " + comparisons + " iterations!"); - return comparisons; - } -} diff --git a/BubbleSort/SortingApp.java b/BubbleSort/SortingApp.java deleted file mode 100644 index 9b0e793..0000000 --- a/BubbleSort/SortingApp.java +++ /dev/null @@ -1,47 +0,0 @@ -public class SortingApp { - - public static String toString(int collection[]) { - String temp = "["; - for (int i = 0; i < collection.length; i++) { - temp += collection[i]; - if (i < (collection.length - 1)) { - temp += ", "; - } - } - temp += "]"; - return temp; - } - - public static void bubbleSort() { - int collection[]; - int iterations; - BubbleSort bubble = new BubbleSort(); - - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.basicAscending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.basicDescending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.endAfterNoSwapsAscending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = bubble.optimisedAscending(collection); - - } - - public static void insertionSort() { - int collection[]; - int iterations; - InsertionSort insert = new InsertionSort(); - - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = insert.ascending(collection); - collection = new int[] { 2, 1, 7, 8, 4 }; - iterations = insert.descending(collection); - - } - - public static void main(String[] args) { - bubbleSort(); - insertionSort(); - } -} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy