Function CREATE(X, FIRST)
[Given X, a new element, and FISRT, a pointer to the first element of a Linked linear list whose typical node contains INFO and LINK fields as in above fig, this function inserts X.]
1. [Repeat thru step 5]
Repeat while Choice! = ‘n’
2. [Allocate the New node]
NEW NODE
3. [Initialize the fields of new node]
INFO (NEW) = X
LINK (FIRST) = NEW
4. [Want to insert another node]
Read (Choice)
5. [Set the LINK field of Last inserted element]
LINK (FIRST) = NULL
6. [Finished]
Return
No comments:
Post a Comment