added assignment3 - #22
Closed
10yogi wants to merge 2 commits into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ASSIGNMENT #3
Topics Covered: Java Collections.
Design a Data Structure using Java’s Collection Framework that represents a dependency graph.
Dependency Graph is an acyclic multi root directional graph with the exception of a root node, which has no parents.
Real Life Scenario:
Family Tree
Terminology used:
Parent: For edge A->B, A is a parent of B. There may be multiple parents for a child.
Child: For edge A->B, B is a child of A. There may be multiple children of a parent.
Ancestor: parent or grand-parent or grand-grand-parent and so on
Descendant: child or grand-child or grand-grand-child and so on
Basically the data structure should allow you to store the parent child relationship and this can go to the nth level.
Design:
The node information, which we will store, is:
Node Id --- This has to be unique.
Node Name. Need not be distinct.
Additional Information --- In the form of a key value pairs and this can be different for each node.
Operations:
Get the immediate parents of a node, passing the node id as input parameter.
Get the immediate children of a node, passing the node id as input parameter.
Get the ancestors of a node, passing the node id as input parameter.
Get the descendants of a node, passing the node id as input parameter.
Delete dependency from a tree, passing parent node id and child node id.
Delete a node from a tree, passing node id as input parameter. This should delete all the dependencies of the node.
Add a new dependency to a tree, passing parent node id and child node id. This should check for cyclic dependencies.
Add a new node to tree. This node will have no parents and children. Dependency will be established by calling the 7 number API.
Key Points:
Use Java’s collection framework to implement Family Tree.
Proper validation / info messages should be thrown on console.
Do appropriate exception handling wherever required.
Where ever required please write comments in the code to make it more understandable.
TDD methodology should be used