This repository contains an algorithm that performs various operations on a given sentence.
The algorithm takes a sentence as input and performs the following operations:
- Counts the number of words in the sentence.
- Counts the total number of characters in the sentence.
- Counts the number of vowels in the sentence.
The algorithm uses a for loop to iterate over each character in the sentence. If the character is a space, it increments the word count. If the character is not an empty string, it increments the character count. If the character is a vowel (a, e, i, o, u), it increments the vowel count.
sentence
: A string that represents the sentence to be analyzed.sentence_length
: An integer that stores the total number of characters in the sentence.vowels
: An integer that stores the total number of vowels in the sentence.word_length
: An integer that stores the total number of words in the sentence.vowels
: A string that contains all the vowel characters.
To use this algorithm, you need to provide a sentence as input. The algorithm will then calculate and return the number of words, total characters, and vowels in the sentence.
##SECOND CHECKPOINT
This repository also includes a function called insertionSort
that sorts an array of numbers in ascending order.
The insertionSort
function takes an array of numbers as input and sorts the numbers in ascending order using the insertion sort algorithm. The function iterates over each element in the array, starting from the second element. For each element, it finds the correct position in the sorted part of the array and inserts the element at that position.
arr
: An array of numbers that needs to be sorted.current
: The current element that needs to be inserted into the sorted part of the array.j
: An index used to iterate over the sorted part of the array.
To use this function, you need to provide an array of numbers as input. The function will then sort the numbers and return the sorted array.
Here is an example of how to use the function: