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
an electrical student designed a circuit in which the impedence in one part of a series circuit is 2+j8 ohms and the impedent is another part of the circuit is 4-j60 ohm mm program

The space-complexity of the algorithm is a constant. It just needs space of three integers m, n and t. Thus, the space complexity is O(1). The time complexity based on the loop

Explain CAM software CAD/CAM software has been recognized as an essential tool in the designing and manufacturing of a product due to its ability to depict the designs and tool

Example 1:  Following are Simple sequence of statements Statement 1;  Statement 2; ... ... Statement k; The entire time can be found out through adding the times for

I need a person who has a good background in using R. Studio? In adition, a person who is good in using algorithms.

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

Q. Sort the sequence written below of keys using merge sort. 66, 77, 11, 88, 99, 22, 33, 44, 55                                                                      Ans:

a) Run your program for α = 0.05, 0.5, and 0.95. You can use n = 30, and W = 10. What is impact of increasing value of α on connectivity of G'? To answer this question, for each v

Explain what are circular queues? Write down routines required for inserting and deleting elements from a circular queue implemented using arrays.           Circular queue:

Write an algorithm in the form of a flowchart that: inputs top speeds (in km/hr.) of 5000 cars Outputs fastest speed and the slowest speed Outputs average (mean) s