Linked implementations of Stacks and Queues

26/11/01


Click here to start


Table of Contents

Linked implementations of Stacks and Queues

New

Delete

Stacks: Inserting & Deleting

push x on the stack

Pop the stack

Stacks:Top, IsEmpty, Size

Queues

Queue Operations

#include <stdio.h>

Initialise Queue

Insert in Queue

if (queue == NULL)

Remove from Queue

Other Queue Methods

// external definiton of Clear follows:

void main()

Priority Queues as Linked Lists

Circular Lists

This convention allows us to add / remove an element from either the front or the rear of the list.

Stacks as Circular Lists

Queues as a circular list

The Josephus Problem

Beginning with the soldier whose name was picked they begin counting clockwise around the circle.

The problem!

Doubly Linked Lists

Author: Computer Science Dept.