Chapter 4. Stacks and Queues
This chapter will extend the linked list implementation to stacks and queues. Stacks and queues are special cases of linked lists with less flexibility in performing operations than linked lists. However, these data structures are easy to implement and have higher efficiency where such structures are needed. For example, Figure 1.4, in Chapter 1, Getting Started shows the implementation of an array with integer data type using stacks and queues. An item can be added (PUSH) or deleted (POP) from a stack from one side only, whereas a queue is an implementation of linear data structure, which allows two sides for insertion (enqueue) and deletion (dequeue). The current chapter will cover array-based and linked list-based implementation of stacks and queues in R. This chapter will cover below topics in detail:
- Stacks
- Array-based stacks
- Linked stacks
- Comparison of array-based and linked stacks
- Implementing recursion
- Queues
- Array-based queues
- Linked queues
- Comparison...