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

String Manipulation Algorithms Overview

The document outlines a series of algorithms for various string manipulation tasks, including character case conversion, word reversal, frequency counting, and palindrome checking. Each algorithm is structured with a clear start and stop, detailing the steps involved in processing input strings or sentences. Several algorithms utilize object-oriented programming concepts, while others are implemented without OOP.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

String Manipulation Algorithms Overview

The document outlines a series of algorithms for various string manipulation tasks, including character case conversion, word reversal, frequency counting, and palindrome checking. Each algorithm is structured with a clear start and stop, detailing the steps involved in processing input strings or sentences. Several algorithms utilize object-oriented programming concepts, while others are implemented without OOP.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q8 Algorithm

1. Start
2. Input the string
3. Traverse each character
4. If character is uppercase → convert to lowercase
5. If character is lowercase → convert to uppercase
6. Add converted characters to new string
7. Display the result
8. Stop

Q9 Algorithm

1. Start
2. Create class ReverseWords with variables sentence & result
3. Initialize variables using constructor
4. In accept() method:
→ Take sentence as input
5. In reverseWords() method:
→ Split sentence into words
→ For each word, reverse characters
→ Add reversed word to result string
6. Display the final reversed sentence
7. Create object in main() and call methods
8. Stop

Q10 Algorithm — Q10 (Without OOP)

1. Start
2. Input a sentence from the user
3. Split the sentence into words
4. For each word:
→ Extract the first character
→ Convert it to uppercase
→ Add to result string
5. Display the final string of uppercase letters
6. Stop

Q11 Algorithm

1. Start
2. Create class WordFrequency with variables sentence, word, freq
3. Initialize variables using constructor
4. In process() method:
→ Accept a sentence
→ Convert to lowercase
→ Accept a word and convert to lowercase
→ Split the sentence into words
→ Count the number of times the word occurs
→ Display the frequency
5. Create object in main() and call process()
6. Stop

Q12 Algorithm

1. Start
2. Create class ShiftWord with variables: word and n
3. Read the word in accept()
4. In generate() method:
→ Find length of the word
→ Loop n times
• Print the current word
• Move 1st letter to the end
5. Create object in main() and call methods
6. Stop

Q13 Algorithm

1. Start
2. Create class LongestWord with variables → sentence, longest, maxLen
3. In accept() method:
→ Input the sentence
4. In find() method:
→ Split sentence into words
→ Compare lengths of each word
→ Store the longest word and its length
5. Display the longest word and its length
6. Create object in main() and call methods
7. Stop

Q14 Algorithm

1. Start
2. Create class FirstLetterWord with variables → sentence, result
3. In accept() method:
→ Input sentence
4. In form() method:
→ Split sentence into words
→ Extract first letter of each word
→ Convert to uppercase
→ Add to result string
5. Display the formed word
6. Create object and call methods
7. Stop

Q15

Algorithm — Q15 (Without OOP)

1. Start
2. Input a sentence
3. Split the sentence into words using space as separator
4. Traverse the array in reverse order
5. Add each word to a new string result
6. Display the reversed-word sentence
7. Stop

Q16 Algorithm

1. Start
2. Input a string
3. Convert string to uppercase
4. For each character:
→ Compare with every character after it
→ If any character repeats → mark Not Unique
5. If no repetition found → mark Unique String
6. Display result
7. Stop

Q17 Algorithm

1. Start
2. Create class LetterFrequency with variable s
3. Initialize s to empty string using constructor
4. In process() method:
a) Accept a sentence in uppercase
b) Create an integer array freq of size 26
c) Loop through each character of sentence
→ If character is between 'A' and 'Z'
→ Increase its frequency in array
d) Display all characters whose frequency > 0
5. Create object in main() and call process()
6. Stop

Q18 Algorithm

1. Start
2. Create class SpecialWord with variable word
3. Initialize word in constructor
4. In process() method:
a) Input the word in uppercase
b) Check palindrome: reverse and compare
c) Check special word: compare 1st and last letter
d) Display output:
→ If palindrome → “Palindrome Word”
→ Else if special → “Special Word”
→ Else → “Neither Special nor Palindrome”
5. Create object in main() and call process()
6. Stop

You might also like