Docsity

CSCE 235: Determining Reflexivity, Symmetry, and Transitivity, Assignments of Computer Science

Toggle sidebar
bg1
CSCE 235: Introduction to Discrete Structures
Programming assignment 1 (50 points)
Assigned Wednesday, February 21, 2007
Due 11:59 p.m., Monday, March 5, 2007
You are to write a program that can determine whether a relation Ron a set Sis reflexive,
symmetric, and/or transitive. Use good documentation and programming style.
Description of input
The input to your program will contain several test cases, one test case per line. Each line
will be of the form
|S|n a1b1a2b2. . . anbn,
where |S|is the cardinality of the set S,nis the number of ordered pairs in the relation R,
and the following 2nnumbers specify these ordered pairs—i.e.,
R={(a1, b1),(a2, b2), . . . , (an, bn)}.
The elements of Sare consecutive positive integers, beginning with 1. Your program should
be able to handle test cases where |S|is as large as 20.
The last line of the input will consist of two zeroes.
The input will be available to your program through standard input. This means that
you can use cin to read the input in C++, scanf in C, System.in in Java, and the
corresponding functions in other programming languages.
Description of output
The output of your program should be presented one test case per line. Each line should
begin with either “reflexive” or “not reflexive”, followed by a comma and a space,
followed by either “symmetric” or “not symmetric”, followed by a comma and a space,
followed by either “transitive” or “not transitive”.
The output of your program should be sent to standard output. This means that you
should use cout to produce the output in C++, printf in C, System.out in Java, and the
corresponding functions in other programming languages.
Do not output any prompts or anything else other than the answers for each test case.
When your program is graded, a large input file will be piped to your program, and the
output your program produces for this input file will be saved to an output file. This output
file will be automatically compared with a file containing the correct answers. If your output
contains prompts or other extraneous information, this comparison step will indicate that
your program produced incorrect output.
What to hand in
Hand in all source files and a README file that explains how to compile and run your
program. It is not necessary to hand in a binary executable. Use the Web handin system
at http://cse.unl.edu/~cse235/handin to hand in your files. Instructions for using this
system are on the back of this page.
Sample input
351112212233
581325313344455254
46111322243344
0 0
In this example, the first line specifies a relation on a set of cardinality 3, so S={1,2,3}.
There are 5 ordered pairs in the relation, and these ordered pairs are (1,1), (1,2), (2,1),
(2,2), and (3,3).
Sample output
reflexive, symmetric, transitive
not reflexive, symmetric, not transitive
reflexive, not symmetric, transitive
Page 1
pf2

Partial preview of the text

Download CSCE 235: Determining Reflexivity, Symmetry, and Transitivity and more Assignments Computer Science in PDF only on Docsity!

CSCE 235: Introduction to Discrete Structures Programming assignment 1 (50 points) Assigned Wednesday, February 21, 2007 Due 11:59 p.m., Monday, March 5, 2007

You are to write a program that can determine whether a relation R on a set S is reflexive, symmetric, and/or transitive. Use good documentation and programming style.

Description of input

The input to your program will contain several test cases, one test case per line. Each line will be of the form |S| n a 1 b 1 a 2 b 2... an bn,

where |S| is the cardinality of the set S, n is the number of ordered pairs in the relation R, and the following 2n numbers specify these ordered pairs—i.e.,

R = { (a 1 , b 1 ), (a 2 , b 2 ),... , (an, bn) }.

The elements of S are consecutive positive integers, beginning with 1. Your program should be able to handle test cases where |S| is as large as 20. The last line of the input will consist of two zeroes. The input will be available to your program through standard input. This means that you can use cin to read the input in C++, scanf in C, System.in in Java, and the corresponding functions in other programming languages.

Description of output

The output of your program should be presented one test case per line. Each line should begin with either “reflexive” or “not reflexive”, followed by a comma and a space, followed by either “symmetric” or “not symmetric”, followed by a comma and a space, followed by either “transitive” or “not transitive”. The output of your program should be sent to standard output. This means that you should use cout to produce the output in C++, printf in C, System.out in Java, and the corresponding functions in other programming languages. Do not output any prompts or anything else other than the answers for each test case. When your program is graded, a large input file will be piped to your program, and the output your program produces for this input file will be saved to an output file. This output file will be automatically compared with a file containing the correct answers. If your output contains prompts or other extraneous information, this comparison step will indicate that your program produced incorrect output.

What to hand in

Hand in all source files and a README file that explains how to compile and run your program. It is not necessary to hand in a binary executable. Use the Web handin system at http://cse.unl.edu/~cse235/handin to hand in your files. Instructions for using this system are on the back of this page.

Sample input

3 5 1 1 1 2 2 1 2 2 3 3 5 8 1 3 2 5 3 1 3 3 4 4 4 5 5 2 5 4 4 6 1 1 1 3 2 2 2 4 3 3 4 4 0 0

In this example, the first line specifies a relation on a set of cardinality 3, so S = { 1 , 2 , 3 }. There are 5 ordered pairs in the relation, and these ordered pairs are (1, 1), (1, 2), (2, 1), (2, 2), and (3, 3).

Sample output

reflexive, symmetric, transitive not reflexive, symmetric, not transitive reflexive, not symmetric, transitive

Page 1

Web handin instructions

Registration

You have to register with the handin system before you use it for the first time. To register, choose the “Register” link from the menu on the left. Enter your CSE username along with a password (not your CSE password) on the registration page, and click the “Register” button at the bottom of the page to finish the process. You will then receive mail on CSE to confirm your registration.

Handing in files

To hand in an assignment, go to the class handin Web page (http://cse.unl.edu/~cse235/ handin) and fill out the form on that page. Use the your CSE username and your handin password. Be sure to choose the correct assignment under which to hand in the files, and choose the files you wish to hand in with the file choosers at the bottom. If you need to hand in more files than there are selection boxes, hand them in in two (or more) separate batches. For example, if you need to hand in the files file1.c, file2.c, file3.c, file4.c, file5.c, and file6.c, but handin only lets you hand in five files at a time, hand in file1.c through file5.c as one group and file6.c by itself. After each handin you will be shown a list of all of the files you have handed in up to that point.

Checking a previous handin

If you ever want to check the status of a previous handin (“Did I really hand in those files?”), you can go to the class handin page and choose “Check Status” from the handin choices. After making that choice, filling in your username and password, and choosing an assignment to check on, click the Submit button at the bottom of the page. You will then be presented with a list of all of the files you have handed in for that particular assignment, along with their sizes and the time and day you handed them in.

Changing your password

Changing your password on occasion can be a good idea. To change your password, choose the “Password” link from the menu on the left. Fill out the “Change user password” form with your username, current password, and the new password you would like. The change will take effect immediately after you submit it, and you will also be sent a piece of e-mail on CSE confirming the change.

Forgotten password

If you forget your password, the handin system can send it to you at your CSE e-mail address. To receive your password, choose the “Password” link from the menu on the left and fill out the “Send user password” form with your username. After you submit the form you will receive mail on CSE with your handin password.

Page 2