Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freddiehaddad/palindrome
Multithreaded palindrome detector written in Go.
https://github.com/freddiehaddad/palindrome
concurrency concurrent-programming go golang leetcode leetcode-go leetcode-golang leetcode-solution multithreading
Last synced: about 1 month ago
JSON representation
Multithreaded palindrome detector written in Go.
- Host: GitHub
- URL: https://github.com/freddiehaddad/palindrome
- Owner: freddiehaddad
- Created: 2024-02-04T18:50:57.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-02-10T16:25:48.000Z (11 months ago)
- Last Synced: 2024-06-19T16:35:46.316Z (6 months ago)
- Topics: concurrency, concurrent-programming, go, golang, leetcode, leetcode-go, leetcode-golang, leetcode-solution, multithreading
- Language: Go
- Homepage: https://leetcode.com/problems/valid-palindrome/description/?envType=study-plan-v2&envId=top-interview-150
- Size: 2.93 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Multithreaded Palindrome Detector
Program to check if a string is a palindrome using channels and concurrency.
The program works by spawning three threads with specific responsibilities. One
thread reads characters starting from the left and feeds palindrome characters
to a unique channel. The second thread reads characters from the right also
feeding palindrome characters to another unique channel. The third thread reads
characters from these two channels and compares them until the indices cross or
two non-matching characters are encountered and reports the result of comparing
to another separate channel.Palindrome characters are alphanumeric. Anything else is ignored. For example,
in the string `"A man, a plan, a canal: Panama"`, the spaces, commas and the
colon are ignored and the palindrome comparison occurs as if the string was
`"amanaplanacanalpanama"`.Also note that the strings are case insensitive.
```text
+-------------------------+
| "Madam, I'm Adam" G |
| |
| +--+---------------------+
| isPalindrome() | | |
+--+----------------------+ | |
| v v
| +--------------------------+ +--------------------------+
| | "Madam, I" G | | "I'm Adam" G |
| | | | |
| | | | |
| | feedCharactersForward() | | feedCharactersReverse() |
| +----+---------------------+ +-------------+------------+
| | |
| | +-------------------------+
| | |
| v v
| +--------------------------+
| | "madami" "madami" G |
| | |
+-->| |
| compareCharacters() |
+--------------------------+G: Go Routine
```