Algorithm 5 Singly Circular Linked List

Ensure: Implementation of dictionary operations with singly circular linked list

1:procedure Insert(L,xL, x)

2:x.next=L.nil.nextx.next = L.nil.next

3:L.nil.next=LL.nil.next = L

4:end procedure

5:

6:procedure Delete(L,xL, x)

7:p=L.nilp = L.nil

8:while p.nextxp.next \ne x do

9:if p.next==L.nilp.next == L.nil then

10:error "xx doesn't exist in LL"

11:end if

12:p=p.nextp = p.next

13:end while

14:p.next=x.nextp.next = x.next

15:end procedure

16:

17:procedure Search(L,kL, k)

18:x=L.nil.nextx = L.nil.next

19:while xL.nilx \ne L.nil and x.keykx.key \ne k do

20:x=x.nextx = x.next

21:end while

22:return xx

23:end procedure