Algorithm to add element in the end of circular linked list, Data Structure & Algorithms

Q. Write down an algorithm to add an element in the end of the circular linked list.       

Ans.

Algorithm to Add the Element at the End of Circular Linked Lists written below.

IINSENDCLL( INFO, LINK, START, AVAIL, ITEM) The algorithm deletes last element from the circular linked list.

1.  [OVERFLOW?] if AVAIL = NULL, then Write:

OVERFLOW, and Exit.

2.  [Remove first node from the AVAIL: = LIN[AVAIL].

a.  Set NEW:= AVAIL and AVAIL:=LINK[AVAIL].

3.  Set INFO[NEW]:=ITEM. [copies new data into new node.]

4.  Set  PTR:= LINK[START] and SAVE:=START.[initializes popinters]

5.  Repeat while LINK[PTR]!=START: [ Traverses list seeking last node.]

a.  Set PTR:=LINK[PTR]. [Updates PTR] [ End of loop]

6.  Set LINK [PTR]:= NEW. [ Attaches new node to the last node of the list]

7.  Set LINK[NEW]:= START [ New node now points to the original first node.]

8.  Exit

Posted Date: 7/13/2012 2:12:07 AM | Location : United States







Related Discussions:- Algorithm to add element in the end of circular linked list, Assignment Help, Ask Question on Algorithm to add element in the end of circular linked list, Get Answer, Expert's Help, Algorithm to add element in the end of circular linked list Discussions

Write discussion on Algorithm to add element in the end of circular linked list
Your posts are moderated
Related Questions
This is the most extensively used internal sorting algorithm. In its fundamental form, it was invented by C.A.R. Hoare in the year of 1960. Its popularity lies in the easiness of i

Program segment for the deletion of any element from the queue delmq(i)  /* Delete any element from queue i */ { int i,x; if ( front[i] == rear[i]) printf("Queue is

algorithm and flow chart to find weather the given numbers are positive or negative or neutral

Q. Implement a stack making use of the linked list. Show the PUSH and POP operations both. A n s . Stack implemantation using linked list # include # include

A company is carrying out a survey by observing traffic at a road junction. Every time a car, bus or lorry passed by road junction it was noted down. 10 000 vehicles were counted d

1) Which graph traversal uses a queue to hold vertices which are to be processed next ? 2) Which of the graph traversal is recursive by nature? 3) For a dense graph, Prim's a

In what ways we can get the context sensitive F1 help on a field?' Data element documentation. Data element additional text in screen painter. Using the process on help r

Write an assembly program to separate the number of positive numbers and negative numbers from a given series of signed numbers.

Determine the Disjoint of division method A polygon is disjoint from the viewport if the x- and y-extents of the polygon do not overlap the viewport anywhere. In this case; reg

Your objective is to write a generic doubly linked list class called CS228LinkedList that implements the List interface and uses a type variable T. All methods except for subList a