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

Addressing modes, Compare zero-address, one-address, two-address, and three...

Compare zero-address, one-address, two-address, and three-address machines by writing programs to compute: Y = (A – B X C) / (D + E X F) for each of the four machines. The inst

Recursive function , Q. Write down the recursive function to count the numb...

Q. Write down the recursive function to count the number of the nodes in the binary tree.    A n s . R ecursive Function to count no. of Nodes in Binary Tree is writt

Explain the arrays in ruby, Explain the Arrays in Ruby Ruby arrays are ...

Explain the Arrays in Ruby Ruby arrays are dynamic arrays which expand automatically whenever a value is stored in a location beyond current end of the array. To the programmer

Chaining Method as Method of Collision Resolution , Q. The given values are...

Q. The given values are to be stored in a hash table 25, 42, 96, 101, 102, 162, 197 Explain how the values are hashed by using division technique of hashing with a table

Design and implement a software system, In this assignment, you are invited...

In this assignment, you are invited to design and implement a software system for catalogue sale. A catalogue is organised in a tree structure. Each node of the catalogue tree repr

Diophantine Equations, Implement algorithm to solve 5-1 fifth order equati...

Implement algorithm to solve 5-1 fifth order equation given.

Program on radix sort., Write a program that uses the radix sort to sort 10...

Write a program that uses the radix sort to sort 1000 random digits. Print the data before and after the sort. Each sort bucket should be a linked list. At the end of the sort, the

Process of analysis, The objective analysis of an algorithm is to determine...

The objective analysis of an algorithm is to determine its efficiency. Efficiency is based on the resources which are used by the algorithm. For instance, CPU utilization (Ti

Graph, explain the prims''s algorithm with suitable example?

explain the prims''s algorithm with suitable example?

Files structures, The structures of files vary from operating system to ope...

The structures of files vary from operating system to operating system. In this unit, we will discuss the fundamentals of file structures with the generic file organisations. A

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