Headline

Compute the nesting depth of departments

Description

The nesting depth of departments within a company is to be computed; see below for details. Let's assume that the management of the company is interested in the nesting depth as a simple indicator for the complexity of the company (or particular departments thereof) in the sense of a hierarchical organization. Nesting depth, together possibly with other metrics and information, could feed into the discussion of reorganizing business structures.

The nesting depth is computed as follows:

  • The depth of a department is 1 + the maximum of the depths of its sub-departments.
  • In particular, the depth of a department without sub-departments is 1.
  • The depth of a company is the maximum of the depths of its (immediate) departments.

Motivation

The feature may be implemented as a query, potentially making use of a suitable query language. Conceptually, the required query is non-trivial in that it needs to process company structure recursively so that nesting of departments can be properly observed. For instance, it is not straightforward to design a Language:SQL query that computes indeed nesting depth on a normalized relational schema for company data. Thus, it shall be interesting to see how different software languages, technologies, and implementations succeed in realizing the feature.

Illustration

The feature is illustrated with a Function in Language:Haskell that works on top of appropriate algebraic data types for company data; the function recurses into company data in a straightforward manner and it counts departments along the way:

depth :: Company -> Int
depth (Company   ds) = max' (map depth' ds)
  where
    max' = foldr max 0
    depth' :: Department -> Int
    depth' (Department     ds  ) = 1 + max' (map depth' ds)

The snippet originates from Contribution:haskellComposition.

Relationships

  • See Feature:Total for a simpler query scenario.
  • Indeed, the present feature should be tackled only after Feature:Total.
  • The present feature can only usefully instantiated on top of Feature:Hierarchical_company, as it assumes nesting of departments for non-trivial results.

Guidelines

  • The name of an operation for computing the nesting depth of departments should involve the term "depth".
  • A suitable demonstration of the feature's implementation should compute the depth of a sample company.
  • See Feature:Total for more detailed guidelines on a query scenario, which apply similarly to the present feature.

There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.