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.
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.
Continuing with the discussion on queues, this is a good opportunity to talk about the key differences between stacks and queues since they have similar operations. In fact, you can implement a stack using queues, and you can implement a queue using stacks. Let’s walk through this in more detail.
To summarize the differences between stacks and queues:
Queues are data structures that follow the same principle as joining a line, which is “First-in, First-out,” or FIFO. Just like waiting in line, the first item in the queue is the first to leave the queue. It is the data structure that ensures fairness. We have the same three operations for queues that we use for stacks but what’s different are the locations of these operations:
So far, in my previous posts on stacks, I have been discussing array-based stacks. Array-based stacks use a fixed size of memory. They are simple to create, but you can run into memory problems. One example is stack overflow. Max for Live is a platform to build your own instruments and effects in Ableton Live, a digital audio workstation (DAW). Max for Live is based on Max, a visual programming language used by musicians, artists, and designers to create interactive installations and performance tools. With Max, you connect objects with patch cords to process data, audio, and video. Stack overflow happens when you overload Max with the list of things (aka a stack) that Max has to do, eventually overflowing the amount of memory space available. One way that this can happen is through an infinite loop. It causes Max to shut down its internal scheduler and stop performing operations. What we need is dynamic memory for these stacks, so that memory can expand as needed. How might we do this? Using linked lists! Check out my previous posts on linked lists to learn more about them.
While exploring stacks and their connection to music, I have learned that stacks are great data structures to parse files and can be applied to parse MusicXML files. MusicXML is a standard open format for exchanging digital sheet music. MusicXML was based primarily on two academic music formats to capture how music is formatted on the printed page. MusicXML differs from MIDI, another music notation interchange format, in that MIDI is useful for performance applications, but not musical notation. MIDI does not represent stem direction, beams, repeats, slurs, measures, and many other aspects of notation.