Skip to content

Fix incorrect outputs for Linked List Miscellaneous : 3 MQ (Pair-wise Swap)#27

Open
bhuvitw wants to merge 1 commit intoAnuj-er:mainfrom
bhuvitw:patch-1
Open

Fix incorrect outputs for Linked List Miscellaneous : 3 MQ (Pair-wise Swap)#27
bhuvitw wants to merge 1 commit intoAnuj-er:mainfrom
bhuvitw:patch-1

Conversation

@bhuvitw
Copy link
Copy Markdown

@bhuvitw bhuvitw commented Oct 31, 2025

📌 Summary

This PR corrects the expected answers for the Linked List Miscellaneous : 3 problem.
The question code performs pair-wise value swapping, not mirroring or reversing.

Code Logic Referenced

p = head;
q = head->next;
while (q != null) {
   swap(p->value, q->value);
   p = q->next;
   q = p->next;
}

This swaps (node1,node2), (node3,node4), ...


✅ Correct Answers

Input Correct Output
1 2 3 4 5 6 2 1 4 3 6 5
1 1 2 2 3 3 1 1 2 2 3 3
1 1 1 2 2 2 1 1 2 1 2 2

❌ Previously Incorrect Answers

Input Shown Output (Wrong)
1 2 3 4 5 6 1 3 5 5 3 1
1 1 2 2 3 3 1 2 3 3 2 1
1 1 1 2 2 2 1 1 2 2 1 1

These correspond to reverse-pair or mirrored output, not the given code behavior.


📁 File Reference

Advance Data Structures_03-12-2024/8) Linked Lists/15) Linked List Miscellaneous - 1/Answer.txt


🎯 Why this fix

The current answers do not match the algorithm.
Updated results reflect the accurate pair-wise swap behavior.


Please review and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant