# Imports from copy import deepcopy     class _Set_Node:       def __init__(self, value, next_):         """         -------------------------------------------------------         Initializes a Set node that contains a copy of value         and a link to another Set node.         Use: node = _Set_Node(value, next_)         -------------------------------------------------------         Parameters:             value - value for node (?)             next_ - another Set node (_Set_Node)         Returns​​​‌​​‌‌:             a new _Set_Node object (_Set_Node)         -------------------------------------------------------         """         self._value = deepcopy(value)         self._next = next_     class Set:       def __init__(self):         """         -------------------------------------------------------         Initializes an empty Set.         Use: target = Set()         -------------------------------------------------------         """         self._front = None         self._count = 0       def is_empty(self):         """         -------------------------------------------------------         Determines if Set is empty.         Use: empty = source.is_empty()         -------------------------------------------------------         Returns​​​‌​​‌‌:             True if Set is empty, False otherwise.         -------------------------------------------------------         """         # your code here         return       def __len__(self):         """         -------------------------------------------------------         Returns the number of values in Set.         Use: n = len(source)         -------------------------------------------------------         Returns​​​‌​​‌‌:             the number of values in Set.         -------------------------------------------------------         """         # your code here         return       def _linear_search(self, key):         """         -------------------------------------------------------         Searches for key in Set.         (Private helper method)         Use: prev, curr = self._linear_search(key)         -------------------------------------------------------         Parameters:             key - a partial data element (?)         Returns​​​‌​​‌‌:             prev - pointer to node prev to the node containing key (_Set_Node)             curr - pointer to node containing key, None if not found (_Set_Node)         -------------------------------------------------------         """         # your code here         return       def add(self, value):         """         -------------------------------------------------------         Adds value to end of Set. Values may appear only once in the Set.         Use: added = source.add(value)         -------------------------------------------------------         Parameters:             value - a comparable data element (?)         Returns​​​‌​​‌‌:             added - True if value is added to Set, False otherwise (boolean)         -------------------------------------------------------         """         # your code here         return       def remove(self, key):         """         -------------------------------------------------------         Finds, removes, and returns value in Set that matches key.         Returns None if no matching value.         Use: value = source.remove(key)         -------------------------------------------------------         Parameters:             key - a partial data element (?)         Returns​​​‌​​‌‌:             value - the value matching key, otherwise None (?)         -------------------------------------------------------         """         # your code here         return       def remove_front(self):         """         -------------------------------------------------------         Removes and returns first value in Set.         Use: value = source.remove_front()         -------------------------------------------------------         Returns​​​‌​​‌‌:             value - first value in Set (?)         -------------------------------------------------------         """         assert self._front is not None, "Cannot remove from an empty set"           # your code here         return       def find(self, key):         """         -------------------------------------------------------         Returns a copy of value in Set that matches key, None         if key is not found.         Use: value = source.find(key)         -------------------------------------------------------         Parameters:             key - a partial data element (?)         Returns​​​‌​​‌‌:             value - a copy of value matching key, otherwise None (?)         -------------------------------------------------------         """         # your code here         return

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

# Imports

from copy import deepcopy

 

 

class _Set_Node:

 

    def __init__(self, value, next_):

        """

        -------------------------------------------------------

        Initializes a Set node that contains a copy of value

        and a link to another Set node.

        Use: node = _Set_Node(value, next_)

        -------------------------------------------------------

        Parameters:

            value - value for node (?)

            next_ - another Set node (_Set_Node)

        Returns​​​‌​​‌‌:

            a new _Set_Node object (_Set_Node)

        -------------------------------------------------------

        """

        self._value = deepcopy(value)

        self._next = next_

 

 

class Set:

 

    def __init__(self):

        """

        -------------------------------------------------------

        Initializes an empty Set.

        Use: target = Set()

        -------------------------------------------------------

        """

        self._front = None

        self._count = 0

 

    def is_empty(self):

        """

        -------------------------------------------------------

        Determines if Set is empty.

        Use: empty = source.is_empty()

        -------------------------------------------------------

        Returns​​​‌​​‌‌:

            True if Set is empty, False otherwise.

        -------------------------------------------------------

        """

        # your code here

        return

 

    def __len__(self):

        """

        -------------------------------------------------------

        Returns the number of values in Set.

        Use: n = len(source)

        -------------------------------------------------------

        Returns​​​‌​​‌‌:

            the number of values in Set.

        -------------------------------------------------------

        """

        # your code here

        return

 

    def _linear_search(self, key):

        """

        -------------------------------------------------------

        Searches for key in Set.

        (Private helper method)

        Use: prev, curr = self._linear_search(key)

        -------------------------------------------------------

        Parameters:

            key - a partial data element (?)

        Returns​​​‌​​‌‌:

            prev - pointer to node prev to the node containing key (_Set_Node)

            curr - pointer to node containing key, None if not found (_Set_Node)

        -------------------------------------------------------

        """

        # your code here

        return

 

    def add(self, value):

        """

        -------------------------------------------------------

        Adds value to end of Set. Values may appear only once in the Set.

        Use: added = source.add(value)

        -------------------------------------------------------

        Parameters:

            value - a comparable data element (?)

        Returns​​​‌​​‌‌:

            added - True if value is added to Set, False otherwise (boolean)

        -------------------------------------------------------

        """

        # your code here

        return

 

    def remove(self, key):

        """

        -------------------------------------------------------

        Finds, removes, and returns value in Set that matches key.

        Returns None if no matching value.

        Use: value = source.remove(key)

        -------------------------------------------------------

        Parameters:

            key - a partial data element (?)

        Returns​​​‌​​‌‌:

            value - the value matching key, otherwise None (?)

        -------------------------------------------------------

        """

        # your code here

        return

 

    def remove_front(self):

        """

        -------------------------------------------------------

        Removes and returns first value in Set.

        Use: value = source.remove_front()

        -------------------------------------------------------

        Returns​​​‌​​‌‌:

            value - first value in Set (?)

        -------------------------------------------------------

        """

        assert self._front is not None, "Cannot remove from an empty set"

 

        # your code here

        return

 

    def find(self, key):

        """

        -------------------------------------------------------

        Returns a copy of value in Set that matches key, None

        if key is not found.

        Use: value = source.find(key)

        -------------------------------------------------------

        Parameters:

            key - a partial data element (?)

        Returns​​​‌​​‌‌:

            value - a copy of value matching key, otherwise None (?)

        -------------------------------------------------------

        """

        # your code here

        return

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY