Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hi all ? could anyone help me to find ( algorithm for inserting an item into sor

ID: 3625424 • Letter: H

Question

hi all ?

could anyone help me to find

( algorithm for inserting an item into sorted linked list )!!

Explanation / Answer

Hi Lora Here is the solution to your problem!!! Insert Sorted ( ): Description: Here START is a pointer variable which contains the address of first node. PREV is a pointer variable which contains address of previous node. ITEM is the value to be inserted. 1. If (START == NULL) Then [Check whether list is empty] 2. START = New Node [Create a new node] 3. START->INFO = ITEM [Assign ITEM to INFO field] 4. START->LINK = NULL [Assign NULL to LINK field] 5. Else 6. If (ITEM INFO) Then [Check whether ITEM is less then value in first node] 7. PTR = START 8. START = New Node 9. START->INFO = ITEM 10. START->LINK = PTR 11. Else 12. Set PTR = START, PREV = START 13. Repeat While (PTR != NULL) 14. If (ITEM INFO) Then 15. PREV->LINK = New Node 16. PREV = PREV->LINK 17. PREV->INFO = ITEM 18. PREV->LINK = PTR 19. Return 20. Else If (PTR->LINK == NULL) Then [Check whether PTR reaches last node] 21. PTR->LINK = New Node 22. PTR = PTR->LINK 23. PTR->INFO = ITEM 24. PTR->LINK = NULL 25. Return 26. Else 27. PREV = PTR 28. PTR = PTR->LINK [End of Step 14 If] [End of While Loop] [End of Step 6 If] [End of Step 1 If] 29. Exit Hope this helps!!!