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

Find the shortest paths from bellman-ford algorithm, a) Find the shortest p...

a) Find the shortest paths from r to all other nodes in the digraph G=(V,E) shown below using the Bellman-Ford algorithm (as taught in class). Please show your work, and draw the f

Avl tree rotations, AVL trees and the nodes it contains must meet strict ba...

AVL trees and the nodes it contains must meet strict balance requirements to maintain O(log n) search time. These balance restrictions are kept maintained via various rotation func

Algorithsm, What are the properties of an algorithsm?

What are the properties of an algorithsm?

Recursion, differences between direct and indirect recursion

differences between direct and indirect recursion

Assignment, How do I submit a three page assignment

How do I submit a three page assignment

Pipelining., How branching takes place in Instruction pipeline. Explain wit...

How branching takes place in Instruction pipeline. Explain with suitable examples

Multiple queue, What is multiple queue and explain them

What is multiple queue and explain them

Sequential files, Data records are stored in some particular sequence e.g.,...

Data records are stored in some particular sequence e.g., order of arrival value of key field etc. Records of sequential file cannot be randomly accessed i.e., to access the n th

Write an algorithm insert, Q. Write an algorithm INSERT which takes a point...

Q. Write an algorithm INSERT which takes a pointer to a sorted list and a pointer to a node and inserts the node into its correct position or place in the list.  Ans: /* s

LINKED LIST, HOW LINKED LIST HEADER WORKS? HOW TO INSERT AND DELETE ELEMENT...

HOW LINKED LIST HEADER WORKS? HOW TO INSERT AND DELETE ELEMENTS IN LINKED LIST?

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