GeeksforGeeks » Linked List specific questions

Integer sets using linked lists

(1 post)
  • Started 6 months ago by Wradsoxyday

Tags:

  1. isull
    guest
    Posted 6 months ago #

    Consider the ADT set that represents a collection of integers. The ADT should support standard set operations:

    S = init();
    /* Initialize S to the empty set */

    isEmpty(S);
    /* Return true if and only if S is the empty set */

    isSingleton(S);
    /* Return true if and only if S contains only one element */

    isMember(S,a);
    /* Return true if and only if a is a member of the set S */

    S = addElement(S,a);
    /* Add the element a to the set S. If a is already in S,
    there will be no change, else a new element is to be inserted. */

    S = delElement(S,a);
    /* Remove the element a from the set S. No change if a is not
    a member of S. */

    S = union(U,V);
    /* Assign to S the union of the sets U and V */

    S = intersection(U,V);
    /* Assign to S the intersection of the sets U and V */

    S = difference(U,V);
    /* Assign to S the set difference U - V */

    S = symmDiff(U,V);
    /* Assign to S the symmetric difference (U - V) union (V - U) */

    printElements(S);
    /* Print the elements of the set S */
    Implement the set ADT using linked lists.


Reply

You must log in to post.

RSS feed for this topic