Python programming

posted by .

Consider the following class definition:
class Frob(object):
def __init__(self, name): = name
self.before = None
self.after = None
def setBefore(self, before):
self.before = before
def setAfter(self, after):
self.after = after
def getBefore(self):
return self.before
def getAfter(self):
return self.after
def myName(self):

A Frob is an object that has a name, and two connections or links: a "before" and an "after" link that are intended to point to other instances of objects.

We can use Frobs to form a data structure called a doubly linked list. In a doubly linked list, each element has the property that if element A has a "before" link to element B, then element B has an "after" link to element A. We want to create a doubly linked collection of Frob instances with the property that all Frobs with names that are alphabetically before a specific Frob's name appear ordered along the "before" link, and all Frobs with names that are alphabetically after a specific Frob's name appear ordered along the "after" link.

Note that if a Frob is inserted with the same name as a pre-existing Frob, both names should be inserted in the final data structure (the exact ordering of the two identical Frobs does not matter). So in the above example, if we were to next execute the line insert(eric, Frob('martha')), we would expect the doubly linked list to have the elements in the following order: andrew - eric - fred - martha - martha - ruth.

Provide a definition for an insert function that will create an ordered doubly linked list. This function is defined outside of the class Frob, and takes two arguments: a Frob that is currently part of a doubly linked list, and a new Frob. The new Frob will not initially have any "before" or "after" links to other Frobs. The function should mutate the list to place the new Frob in the correct location, with the resulting doubly linked list having appropriate "before" and "after" links. Complete the following function definition:

def insert(atMe, newFrob):
atMe: a Frob that is part of a doubly linked list
newFrob: a Frob with no links 
This procedure appropriately inserts newFrob into the linked list that atMe is a part of.

  • Python programming -

    i don't want the answer. just help me visualize the problem and how to go for the solution. i am in class 9th and i don't know anything about integrals, yet. coding is not the problem. i am able to do that

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. health

    some sdvice on an essay I have to do on child development.How social skills are developed in children.What is self-esteem and self-concept and how are these concepts developed in children?
  2. psychology please revise

    Question How accurately do you think these exercises evaluate self-concept and self-esteem?
  3. psychology revised

    How accurately do you think these exercises evaluate self-concept and self-esteem?
  4. Psychology

    How do self-concept, self-esteem and self-identity differ?
  5. eth125

    How accurately do you think self assessment exercises evaluate self-concept and self-esteem?
  6. self-reflection essay

    am writeing self-relection essay abt the theme self perceiving society,society perceiving self, i dontknow how to start my outline to starte the thesis
  7. Human service

    I have to explain why human service worker's uses the Rosenberg self esteem scale. This is what I have so far. Can you tell me where to find more information on why they use the scale and how my part sounds so far. Morris Rosenberg’s …
  8. psychology of personality

    The way you see and define your self is known as your a) self-esteem b)self concept c)social identity d)self-esteem variability is a correct answer?
  9. Human Behavior

    Define self and the importance of identity of self for individual. Describe the cognitive structural, self psychology, and symbolic influences of self to the individual. What is the importance of self perspective in human behaviors?
  10. statistic

    A company sent seven of its employees to attend a course in building self-confidence. These employees were evaluated for their self-confidence before and after attending this course. The following table gives the scores (on a scale …

More Similar Questions