1 / 12

Program to find equivalence classes

This program allows users to input pairs of numbers and find equivalence classes. It follows the concepts from the textbook "Fundamentals of Data Structures in C".

Download Presentation

Program to find equivalence classes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Program to find equivalence classes Instructor : Prof. Jyh-Shing Roger Jang Designer:Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures in C “ .

  2. Program to find equivalence classes First, we input many pair of numbers and (0,4) (3,1) (6,10) (8,9) 4 3 1 0 10 9 8 6

  3. Program to find equivalence classes First, we input many pair of numbers and (0,4) (3,1) (6,10) (8,9) And add the number from the bottom if the space isn’t empty (7,4) (6,8) (3,5) (2,11) (11,0) 5 4 4 11 11 3 3 2 1 7 0 0 10 9 8 8 6 6

  4. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 And from its link to find another number, if the linked number also link another number, push the linked number to stack. 5 Then, from the top of stack to find the same class number. 4 4 11 11 3 3 2 1 7 0 0 10 9 8 8 6 6

  5. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 And from its link to find another number, if the linked number also link another number, push the linked number to stack. 5 Then, from the top of stack to find the same class number. If the number is already used, skip it. 4 4 11 11 2 3 3 1 7 0 0 10 9 8 8 6 6

  6. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 2 And from its link to find another number, if the linked number also link another number, push the linked number to stack. 5 Then, from the top of stack to find the same class number. If the number is already used, skip it. 4 11 11 3 3 2 1 7 0 10 9 8 8 6 6

  7. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 2 New class: 1 3 And from its link to find another number, if the linked number also link another number, push the linked number to stack. 5 Then, from the top of stack to find the same class number. If the number is already used, skip it. 11 2 3 3 1 10 9 8 8 6 6

  8. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 2 New class: 1 3 5 And from its link to find another number, if the linked number also link another number, push the linked number to stack. 5 Then, from the top of stack to find the same class number. If the number is already used, skip it. 3 3 1 10 9 8 8 6 6

  9. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 2 New class: 1 3 5 And from its link to find another number, if the linked number also link another number, push the linked number to stack. New class: 6 5 Then, from the top of stack to find the same class number. If the number is already used, skip it. 3 10 9 8 8 6 6

  10. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 2 New class: 1 3 5 And from its link to find another number, if the linked number also link another number, push the linked number to stack. New class: 6 8 10 Then, from the top of stack to find the same class number. If the number is already used, skip it. 10 9 8 8 6 6

  11. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 2 New class: 1 3 5 And from its link to find another number, if the linked number also link another number, push the linked number to stack. New class: 6 8 10 9 Then, from the top of stack to find the same class number. If the number is already used, skip it. 10 9 8 8 6 6

  12. Program to find equivalence classes Print: From 0 to 11 if the number is unused, print “New class”, print and mark the number become used. New class: 0 11 4 7 2 New class: 1 3 5 And from its link to find another number, if the linked number also link another number, push the linked number to stack. New class: 6 8 10 9 Then, from the top of stack to find the same class number. If the number is already used, skip it. 9 8

More Related