Created Alg Design Block (Besides Big O)
This commit is contained in:
parent
00edd1e95d
commit
b935c1f10e
52
src/Assignments/A2/Substrings.java
Normal file
52
src/Assignments/A2/Substrings.java
Normal file
@ -0,0 +1,52 @@
|
||||
// Name: Jonathan Turner
|
||||
// Class: CS 4306/01
|
||||
// Term: Spring 2024
|
||||
// Instructor: Dr. Haddad
|
||||
// Assignment: 2
|
||||
// IDE Name: IntelliJ
|
||||
/*
|
||||
Algorithm Design Block
|
||||
Algorithm title: Finding Substrings
|
||||
|
||||
Logical steps:
|
||||
Step 1: Gather input for the text and store them in a string.
|
||||
Step 2: Create a counter that tracks how many substrings are in the text.
|
||||
Step 3: Iterate through a for loop (i) that goes from 1->n.
|
||||
Step 4: If the ith letter in the text is equal to A, then move to Step 5. Otherwise, continue loop.
|
||||
Step 5: Iterate through a for loop (j) which is inside loop (i) and goes from i+1->n.
|
||||
Step 6: If the jth letter in the text is equal to B, increment counter.
|
||||
Step 7: At the end of the loop (i), return the counter to show the number of substrings.
|
||||
|
||||
Pseudocode Syntax:
|
||||
text <- input
|
||||
counter <- 0
|
||||
comps <- 0
|
||||
|
||||
for i <- 1 to n
|
||||
if text[i] = A
|
||||
for j <- i+1 to n
|
||||
if text[j] = B
|
||||
counter + 1
|
||||
comps + 1
|
||||
comps + 1
|
||||
|
||||
return counter, comps
|
||||
|
||||
Big-O Analysis: (Based on Implementation)
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
package Assignments.A2;
|
||||
|
||||
/**
|
||||
* Performs a brute force/exhaustive search for
|
||||
* how many substrings start with A and end with B.
|
||||
*
|
||||
* @author Jonathan Turner
|
||||
*/
|
||||
public class Substrings {
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user