Solve for optimal solution without changing the sequence given in 1 and 2.
For optimal, Leftmost black dot should be matched with the leftmost white dot.
Total length of wire for 1st case according to greedy will be
(1,3)=2
(2,5)=3
(4,6)=2
total length=2+3+2=7
Total Length of wire for 2nd case according to greedy will be
(1,3)=2
(2,4)=2
(5,7)=2
(6,8)=2
total length=2+2+2+2=8
So 1st gives optimal.