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

Related Posts:

  • Traversing Linear Arrays Algorithm 4.1: (Traversing a Linear Array) Here LA is a linear array with lower bound LB and upper bound UB. This algorithm traverses LA applying an operation Process to each element of LA. 1. [Initialize counter.] Set K :… Read More
  • Algorithm Largest Element in Array Algorithm 2.1: (Largest Element in Array) A nonempty array DATA with N numerical values is given.This algorithm finds the location LOC and the value MAX of the largest element of DATA.The variable K is used as a counter. St… Read More
  • Arrays, Records and Pointers Arrays, Records and Pointers  The Operation one normally performs on any linear structure. (a) Traversal: Processing each element in the list. (b) Search: Finding the location of the element with a given value or the… Read More
  • Complexity Of Algorithms Complexity Of Algorithms: There are two case for describing in the complexity of algorithms: (1) Worst Case: The Maximum value of f(n) for any possible input. (2) Average Case: The expected value of f(n) Sometimes we al… Read More
  • Linear Search Algorithm 2.4 Linear Search Algorithm 2.4: (Linear Search) A Linear Array DATA with N elements and a specific ITEM of information are given. This algorithm finds the location LOC of ITEM in the array DATA or sets LOC = 0. 1.  [Ini… Read More

0 comments:

Post a Comment