| Input: Number of nodes. | | Output: Pairs | | BEGIN | | (2) pair() | | (3) Open one.doc, two.doc, three.doc, four.doc file to write output; | | (4) Input four nodes from user; | | (5) k, c, d, e, l, g = 0; | | (6) FOR i = 0 to 3 | | (7) FOR j = 0 to 3 | | (8) arrk0 = nodei; | | (9) arrk1 = nodej; | | (10) k++; | | (11) END FOR | | (12) END FOR | | (13) FOR i = 0 to 12 | | (14) Print (arri0, arri1) to one.doc | | (15) FOR j = 0 to 12 | | (16) IF (i ! = j), THEN | | (17) Print 2-2 pairs (arr2i0, arr2i1, arr2j0, arr2j1) to two.doc; | | (18) c++; | | (19) FOR d = 0 to 12 | | (20) IF (j ! = d and i ! = d), THEN | | (21) Print 3-3 pairs (arr2i0, arr2i1, arr2j]0, arr2j1, arr2d0, arr2d1) to three.doc; | | (22) e++; | | (23) FOR l = 0 to 12 | | (24) IF (l ! = j && l ! = d && l ! = i), THEN | | (25) Print 4-4 pairs | | (26) (arr2i0, arr2i1, arr2j[0, arr2j1, arr2d0, arr2d1, arr2l0, arr2l1) to four.doc; | | (27) g++; | | (28) END FOR | | (29) END FOR | | (30) END FOR | | (31) END FOR | | (32) Print number of 1-1 pairs = k to one.doc; | | (33) Print number of 2-2 pairs = c to two.doc; | | (34) Print number of 3-3 pairs = e to three.doc; | | (35) Print number of 4-4 pairs = g to four.doc; | | (36) END pair() | | (37) END | | The run time complexity of the Algorithm: Test cases is |
|