Part (a) Write an algorithm for sorting with consideration that n data is stored in linked list. Don't make any assumption just stick to the following instructions: Each node contains an INFO field...


Part (a)<br>Write an algorithm for sorting with consideration that n<br>data is stored in linked list. Don't make any assumption<br>just stick to the following instructions:<br>Each node contains an INFO field and a NEXT<br>pointer.<br>Start contains the address of the header node.<br>Don't change any values in the INFO.<br>Part (b) โ€“<br>Consider the given algorithm for insertion of a data at<br>after the given location in linked list.<br>INSLOC(INFO, LINK, START, AVAIL, LOC,<br>ITEM)<br>1. [OVERFLOW?] If AVAIL = NULL, then Write:<br>OVERFLOW, and Exit<br>// [Remove first node from AVAIL list]<br>2. Set NEW := AVAIL and<br>3. AVAIL := LINK[AVAIL]<br>4. Set INFO[NEW] := ITEM. [Copies new data into<br>node]<br>5. If LOC = NULL, then: [Insert as first node]<br>Set LINK[NEW]:= START and<br>START : = NEW<br>6.<br>7.<br>8. else: [Insert after node with location LOC]<br>9.<br>Set LINK[NEW]:= LINK[LOC] and<br>10.<br>LINK[LOC] := NEW<br>[End of If structure]<br>11. Exit<br>Answer the following questions:<br>(i)<br>Draw the diagram for the simulation of the<br>above algorithm such that your diagram reflects<br>the updated link with different colors. Also,<br>show the correspondence in the diagram<br>between updated links and line number of<br>algorithms<br>(ii) Calculate the running time of given algorithm.<br>

Extracted text: Part (a) Write an algorithm for sorting with consideration that n data is stored in linked list. Don't make any assumption just stick to the following instructions: Each node contains an INFO field and a NEXT pointer. Start contains the address of the header node. Don't change any values in the INFO. Part (b) โ€“ Consider the given algorithm for insertion of a data at after the given location in linked list. INSLOC(INFO, LINK, START, AVAIL, LOC, ITEM) 1. [OVERFLOW?] If AVAIL = NULL, then Write: OVERFLOW, and Exit // [Remove first node from AVAIL list] 2. Set NEW := AVAIL and 3. AVAIL := LINK[AVAIL] 4. Set INFO[NEW] := ITEM. [Copies new data into node] 5. If LOC = NULL, then: [Insert as first node] Set LINK[NEW]:= START and START : = NEW 6. 7. 8. else: [Insert after node with location LOC] 9. Set LINK[NEW]:= LINK[LOC] and 10. LINK[LOC] := NEW [End of If structure] 11. Exit Answer the following questions: (i) Draw the diagram for the simulation of the above algorithm such that your diagram reflects the updated link with different colors. Also, show the correspondence in the diagram between updated links and line number of algorithms (ii) Calculate the running time of given algorithm.

Jun 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here