Follow

Translate

Tuesday, March 22, 2016

COPY(INFO, LINK, NAME1, NAME2, AVAIL)



1.     Set NAME2 : = NULL.   [Forms empty  list]

2.   [NAME1 empty?]  If NAME1 = NULL, then: Exit.

3.    [Insert first node of NAME1 into NAME2]
       Call INSLOC(INFO, LINK, NAME2, AVAIL, NULL, INFO[NAME1]) or :
(a)  If AVAIL = NULL, then : Write : OVERFLOW, and Exit.

(b) Set NEW :  = AVAIL and AVAIL : = LINK[AVAIL].   [Removes first node from AVAIL list.]

(c)  Set INFO[NEW] : = INFO[NAME].  [Copies data into new node]

(d)    [Insert new node as first node in NAME2.]

4.    [Initializes pointer PTR and LOC]
         Set  PTR : = LINK[NEW]  and LOC : = NAME2.

5.   Repeat Steps 6 and 7 while PTR != NULL.

6.  Call INSLOC(INFO, LINK, NAME2, AVAIL, LOC, INFO[PTR]) or:

(a)  If AVAIL = NULL, then : Write : OVERFLOW, and Exit.
(b) Set NEW :  = AVAIL and AVAIL : = LINK[AVAIL]. 
(c)  Set INFO[NEW] : = INFO[PTR].    [Copies data into new node]
(d)  [Insert new node into NAME2 after the node with location LOC]
         Set   LINK [NEW] : = LINK[LOC], and LINK[LOC] : = NEW.

7. Set PTR : = LINK[PTR] and LOC : = LINK[LOC].    [Updates PTR and LOC]
[End of Step 5 loop]

8.  Exit.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

0 comments:

Post a Comment