Circularly linked lists implementation, Data Structure & Algorithms

Assignment Help:

CIRCULARLY LINKED LISTS IMPLEMENTATION

A linked list wherein the last element points to the first element is called as CIRCULAR linked list. The chains do not specified first or last element; last element does not have the NULL pointer. The external pointer provides reference to starting element.

The possible operations on a circular linked list are following:

Ø  Insertion,

Ø  Deletion, and

Ø  Traversing

Figure indicates a Circular linked list.

1176_CIRCULARLY LINKED LISTS IMPLEMENTATION.png

Figure: A Circular Linked List

Program indicates the creation of a Circular linked list.

#include

#include

#define NULL 0

structlinked_list

{

int data;

structlinked_list *next;

};

typedefstructlinked_listclist;

clist *head, *s;

void main()

{

voidcreate_clist(clist *);

int count(clist *);

void traverse(clist *);

head=(clist *)malloc(sizeof(clist));

s=head;

create_clist(head);

printf(" \n traversing the created clist and the starting address is %u \n", head);

traverse(head);

printf("\n number of elements in the clist   %d \n", count(head));

}

voidcreate_clist(clist *start)

{

printf("input the element -1111 for coming out of the loop\n");

scanf("%d", &start->data);

if(start->data == -1111)

start->next=s;

else

{

start->next=(clist*)malloc(sizeof(clist));

create_clist(start->next);

}

}

void traverse(clist *start)

{

if(start->next!=s)

{

printf("data is %d \t next element address is %u\n", start->data, start->next);

traverse(start->next);

}

}

if(start->next == s)

printf("data is %d \t next element address is %u\n",start->data, start->next);

 

int count(clist *start)

{

if(start->next == s)

return 0;

else

}

return(1+count(start->next));


Related Discussions:- Circularly linked lists implementation

Sorting, Sort the following array of elements using quick sort: 3, 1, 4, 1,...

Sort the following array of elements using quick sort: 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8.

Kruskals algorithm, Krushkal's algorithm uses the concept of forest of tree...

Krushkal's algorithm uses the concept of forest of trees. At first the forest contains n single node trees (and no edges). At each of the step, we add on one (the cheapest one) edg

Fifo, give any example of page replacement using fifo and use your own refe...

give any example of page replacement using fifo and use your own reference string

Algorithm, what algorithms can i use for the above title in my project desi...

what algorithms can i use for the above title in my project desing and implmentation of road transport booking system

Calculate the k-th power and recursive algorithem, 1. The following is a r...

1. The following is a recursive algorithm to calculate the k -th power of 2. Input k a natural number Output kth power of 2 Algorithem: If k =0then return 1 Else return 2* po

State the symbols of abstract data type operation, Symbols of ADT oepration...

Symbols of ADT oeprations All Symbol ADT operations are implemented in Symbol class, except toSymbol(), which is implemented in classes (like String) which can generate a Symb

Multiple stacks, how multiple stacks can be implemented using one dimension...

how multiple stacks can be implemented using one dimensional array

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

What is Oscillating Sort?, For the Oscillating sort to be applied, it is ne...

For the Oscillating sort to be applied, it is necessary for the tapes to be readable in both directions and able to be quickly reversed. The oscillating sort is superior to the po

Homework, Write a recursive function the computes the number of digits in a...

Write a recursive function the computes the number of digits in a positive integer n. For example if n = 6598, the function should return 4. Find a variant expression and a thresho

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd