Checking for Musical Palindromes using Queues

Continuing with the discussion on queues, one easy type of question is Valid Palindrome. We can check if a string is a palindrome using a queue. The palindrome is defined as a string that, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, reads the same forward and backward. We can check if a string has alphanumeric characters using isalnum() and we can convert a string to lowercase letters using lower(). Additionally, we can use the deque class of queues (double-ended queues) to literally check both ends of the string.

Read more

Welcome to My Corner of the Internet

Hey, I’m Jami Nishelle — and this is my little corner of the internet.

I built this site because I believe in transparency, community, and sharing the creative process openly. That’s what the Open Source Artist movement is all about.

You’ll find my music here, updates on shows, and honest reflections on what it means to create independently. I hope it inspires you to make something of your own.

Peace and joy,

Read more

Queues with One Stack using Recursion and Generating Recursive Fractal Melodies

blue green and purple abstract paintingPhoto by Daria Durand on Unsplash

Continuing with the discussion of interchanging stacks and queues, I want to dive into how to implement a queue with one stack. This implementation is a little tricky because it requires recursion. Recursion is an important computer science concept that is used in many divide-and-conquer strategies to solve hard problems. Recursion occurs when a function calls itself. To prevent having an infinite loop, every recursive function has a base case and a recursive case. The base case tells when to stop recursing and calling itself again. It’s usually some kind of if statement with the stopping condition and is the simplest version of the problem that you can solve directly without recursing further. The recursive case is the function calling itself.

Read more