M320 chapter 4 tree patterns

Hi, I have spent a lot of time on the " lab : Tree patterns". Based on the lecture of chapter four-tree patterns, the Array of ancestor and Parent reference will satisfy and supply
all the three sets of operations:
1-what are the ancestors of a node.?
2- immediate reporting( parent who report to Y)
3-change all the categories under N to under p
I was shocked to see that my answer was not accepted.
Array of ancestors and child reference(to find all the reports of an employee is not accepted either.
Any hint or guidance to help me to come up with the right solution???

Hey @farideh_gorji,

You have to find a pattern that is the most efficient and straightforward approach given the requirements:

1. Issue one database request to find the direct manager of a 
   given employee.
2. Collect all direct reports of an employee with one single 
   and efficient query.
3. Issue one update operation to change the 
   reporting structure of an employee.

The update operation would not be possible with a single update operation in Array of ancestors. It would help if you try picking up from the organization chart and then see which of the given options helps you achieve the three conditions.

Try using “Jon Yullin” and his manager “Stuart Spencer” as an example and see which of the given options helps you achieve the requirements.
This is the sample document for this case:

  "_id": ObjectId("123414123"),
  "name": "Jon Yullin",
  "role": "Intern",
  "department": {
    "name": "Engineering",
    "id": ObjectId("988576342364")
  "reports_to": { "id": ObjectId("123414123") , "name": "Stuart Spencer" },

Let us know here if any doubt still persists.


1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.