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

Data Structure, Ask consider the file name cars.text each line in the file ...

Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr

Best case, Best Case: If the list is sorted already then A[i] T (n) = ...

Best Case: If the list is sorted already then A[i] T (n) = c1n + c2 (n -1) + c3(n -1) + c4 (n -1)  = O (n), which indicates that the time complexity is linear. Worst Case:

Implement an algorithm to simulate car re-organizing, Design  and implement...

Design  and implement  an algorithm  to simulate car  re-organizing of the train at the railway switching junction. You can only use stacks as the data structure to represent the t

Sparse metrics, Q. Define the sparse metrics and also explain the represent...

Q. Define the sparse metrics and also explain the representation of a 4X4 matrix using linked list.         Ans: A matrix in which number of zero entries is quite h

Algorithms, Data array A has data series from 1,000,000 to 1 with step size...

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.

Row major representation, Row Major Representation In memory the primar...

Row Major Representation In memory the primary method of representing two-dimensional array is the row major representation. Under this representation, the primary row of the a

Algorithm, write an algorithm given each students name and grade points for...

write an algorithm given each students name and grade points for six courses.find his grade point average and group students into the gpa groups 3.5

Define spanning tree, Define Spanning Tree A Spanning Tree of a connect...

Define Spanning Tree A Spanning Tree of a connected graph is its linked acyclic sub graph (i.e., a tree) that having all the vertices of the graph.

Insertion of element into a linked list, ALGORITHM (Insertion of element in...

ALGORITHM (Insertion of element into a linked list) Step 1 Begin the program Step 2 if the list is empty or any new element comes before the start (head) element, then add t

Define big theta notation, Define Big Theta notation Big Theta notati...

Define Big Theta notation Big Theta notation (θ) : The upper and lower bound for the function 'f' is given by the big oh notation (θ). Considering 'g' to be a function from t

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