Thread: C Program

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    8

    C Program

    I'm not in this class anymore, but plan on taking a summer course for it and want to get myself as prepared as possible. I am just a bit confused and what the professor wanted this program to do, and was wondering if someone could understand what he wanted. Here are the instructions :

    Code:
    In this assignment, students will implement a common representation of sets.  In completing the assignment students will demonstrate that they can
    Code:
    • Implement a simple abstract data type
    • Design, implement, compile and execute a small software project in C using a Linux environment
    • Write, compile and run C software that includes multiple C files and a .h file
    • Make use of bitwise operators, &, |, and ^, in a C program
    • Design and implement a “driver”, in C, to test their software
    For our purposes, a set is an arbitrary collection of elements, which may be real or imaginary, physical or abstract. In mathematics, sets are usually composed of abstract things like numbers and points, but one can also talk about sets of trees, UNT students, cars, or television shows. In many applications, the elements are never defined, but are left as abstractions that could be represented in many different ways in the human brain, on a piece of paper, or in computer storage. Set notation typically uses curly braces to enclose a set specification. For small, finite sets, the specification of a set can be an exhaustive list of all its elements: {13, 87, 913, 47, 19}. This specifies a set consisting of the five integers 13, 87, 913, 47 and 19. Since the order of listing the elements is immaterial, the following specification is equivalent to the one above: {87, 47, 19, 193, 13}. Some additional definitions of set operations are useful, namely:
    • Empty Set --- the empty set is that set containing no elements, often denoted as {}
    • Set Union --- the union of two sets, s1 and s2, includes all elements included in either or both of s1 or s2. Thus the union of sets {21, 86, 43, 19} and {43, 52, 19} is the set {21, 86, 43, 19, 13, 52}. Note the lack of duplicate elements in the resultant set.
    • Set Intersection --- the intersection of two sets, s1 and s2 includes all elements that are included in both s1 and s2. Thus the intersection of sets {21, 86, 43, 19} and {43, 52, 19} is the set {19, 43}.
    To proceed we must first define an abstract data type for sets. An abstract data type consists of two things, a name of the data type and a list of operations defined for that data type. The name of our abstract data type will be set. The list of operations defined for our set abstract data type includes:
    • clear a set --- make the set an empty set.
    • add2Set --- adds an element to the set
    • deleteFromSet --- removes an element from the set
    • isMember --- returns true is a specified element is a member of the specified set
    • printSet --- prints a list of all element included in a set
    • setUnion --- performs the set union of two input sets and returns the resulting set
    • setIntersection --- performs the set intersection of two input sets and returns the resulting set.
    ASSIGNMENT SPECIFICS
    • The “universe” of elements for the sets (in this assignment) are integers 0 .. 31
    • You should represent sets as unsigned integer numbers, where each bit of an unsigned number represents one possible element of a set. Thus, we have 32 possible set elements (0, 1, … 31) and 32 bit positions in an unsigned int variable (also 0, 1, … 31). For purposes of this program it doesn’t matter whether you “name” the lowest order bit of an unsigned int as 0 (and the highest order bit as 31) or if you “name” the highest order bit 0 and lowest 31. In either case we will define a ‘1’ in bit position i to mean that element i is a member of the set represented by that unsigned int. Thus, the following bit representation would represents the set {19, 3, 31, 12, 7}.
    1 1 1 1 1
    Bit 31 … 0
    • Use the set.h file provided to represent a C “specification” of the set abstract data type. (Instructions will be provided in class as to where and how you should access set.h)
    • Write your own set.c and driver.c files, each of which include set.h. Set.c should implement the functions specified in set.h. Driver.c should provide a main function (and other functions as you feel appropriate) to test your set implementation. It is YOUR responsibility to demonstrate (by your program output) that your program is working correctly.
    • DO NOT change set.h but rather make sure that your set.c correctly implements the functions listed in set.h. This is important, because, in addition to your being graded on your program output’s demonstration that your set implementation is correct, we will replace your driver.c with our own and test your set implementation with our own example data.

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Yes I can understand what is being asked for. Where's your code?

    "Next!"...
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    I am just a bit confused and what the professor wanted this program to do, and was wondering if someone could understand what he wanted.
    If you're asking for someone to paraphrase the assignment, I don't think that's going to happen. But if you have a specific question....
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 11-03-2010, 12:45 PM
  2. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  3. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  4. Replies: 18
    Last Post: 11-13-2006, 01:11 PM
  5. Math Equation Program (I can't find the problem with my program!)
    By masked_blueberr in forum C Programming
    Replies: 14
    Last Post: 07-06-2005, 11:53 AM