# SICP Solutions

### Chapter 3, Modularity, Objects, and State

#### Exercise 3.23

To do it in constant time, double linked list is required. Similar to queue, here also we use front and rear pointers.

Used a structure which I referred as ptr that contains 3 items next which points to next ptr, prev which points to previous ptr and data which contains the actual data/item.

After establishing the above concepts, implementation is straighforward, just managing the pointers carefully(having some background in C helped me). Lets first see the output/examples:

Note that display-deque is a procedure to display contents of deque. It prints ~ to mark the end of the list.

Now here goes the code: