Added Big O Efficiency Table. Substrings.java Completed.

This commit is contained in:
Jonathan Turner 2024-02-15 14:22:18 -05:00
parent 2f6b87d20d
commit ddfa72731f

View File

@ -67,11 +67,16 @@ import java.util.Scanner;
*/
public class Substrings {
/**
* Starts the program.
* @param args the program arguments.
*/
public static void main(String[] args) {
Substrings program = new Substrings();
program.start();
}
/* Private fields that store the text, and results from the algorithm */
private String text;
private int subStringCount;
private int comparisons;
@ -121,10 +126,12 @@ public class Substrings {
* @postcondition the results are generated.
*/
private void performAlgorithm() {
/* Resets the counters to prevent them being added on reruns */
this.subStringCount = 0;
this.comparisons = 0;
char[] values = this.text.toLowerCase().toCharArray();
/* Allows to grabbing specific values are certain indexes. */
char[] values = this.text.toLowerCase().toCharArray();
for (int i = 0; i < this.text.length(); i++) {
if (values[i] == 'a') {
for (int j = i+1; j < this.text.length(); j++) {