Location : Noida (UP) India
Education : Graduate or above in computer science / engineering from a recognized institute
A common problem in user interface involves imposing a stable order upon elements displayed upon a page. While the initial order is easy to specify, keeping it consistent with user actions is interesting.
Take for example a menu structure that looks something like this :
Apple Sour Green Red Banana Ripe Raw Fried Spicy Sweet Salted Cats Large Black White Small Grey Striped
Now imagine an operation on this structure that drag-drops an element from any position to any position in the tree.
For example, moveBelow(Apple/Red, Banana/Fried/Spicy).
The (strange) new tree after this operation looks as shown below. The Red element is now sitting under Banana/Fried/Spicy as specified.
Apple Sour Green Banana Ripe Raw Fried Spicy Red Sweet Salted Cats Large Black White Small Grey Striped
Note that it is possible to move not just leaf elements but also subtree, as in moveBelow (Banana/Fried, Cats/Small). This yields an even stranger tree as shown below. The entire Fried submenu is now placed after Cats/Small, on the path Cats/Fried.
Apple Sour Green Banana Ripe Raw Cats Large Black White Small Grey Striped Fried Spicy Red Sweet Salted
Implement a data structure to represent the menu, and the function moveBelow (fromPath, belowPath)
Use any programming language you like. The function should operate upon the data structure and leave it in a correct state after it is done; it should be possible to see the order (and path!) of each element in the datastructure.
To submit your work send your running code in text file and mail to firstname.lastname@example.org with subject "SDE Assignment - July 2020".
Candidates will be considered in the order of assignment submission. Please submit your assignment as soon as possible.