diff --git a/guide/english/certifications/coding-interview-prep/data-structures/adjacency-list/index.md b/guide/english/certifications/coding-interview-prep/data-structures/adjacency-list/index.md index 5c726b1c28..d623cd0014 100644 --- a/guide/english/certifications/coding-interview-prep/data-structures/adjacency-list/index.md +++ b/guide/english/certifications/coding-interview-prep/data-structures/adjacency-list/index.md @@ -2,9 +2,49 @@ title: Adjacency List --- ## Adjacency List +![:triangular_flag_on_post:](https://forum.freecodecamp.com/images/emoji/emoji_one/triangular_flag_on_post.png?v=3 ":triangular_flag_on_post:") Remember to use **`Read-Search-Ask`** if you get stuck. Try to pair program ![:busts_in_silhouette:](https://forum.freecodecamp.com/images/emoji/emoji_one/busts_in_silhouette.png?v=3 ":busts_in_silhouette:") and write your own code ![:pencil:](https://forum.freecodecamp.com/images/emoji/emoji_one/pencil.png?v=3 ":pencil:") -This is a stub. Help our community expand it. +### ![:checkered_flag:](https://forum.freecodecamp.com/images/emoji/emoji_one/checkered_flag.png?v=3 ":checkered_flag:") Problem Explanation: -This quick style guide will help ensure your pull request gets accepted. +To solve this problem, you have to create a Javascript Object to emulate an undirected graph in the form of an adjacency list. - + +## ![:speech_balloon:](https://forum.freecodecamp.com/images/emoji/emoji_one/speech_balloon.png?v=3 ":speech_balloon:") Hint: 1 + +Create keys with the names James, Jill, Jenny and Jeff. + +> _try to solve the problem now_ + +## ![:speech_balloon:](https://forum.freecodecamp.com/images/emoji/emoji_one/speech_balloon.png?v=3 ":speech_balloon:") Hint: 2 + +Read the presentation and try to understand what it means to be an undirected graph. + +> _try to solve the problem now_ + + + +## Spoiler Alert! + +![warning sign](//discourse-user-assets.s3.amazonaws.com/original/2X/2/2d6c412a50797771301e7ceabd554cef4edcd74d.gif) + +**Solution ahead!** + +## ![:beginner:](https://forum.freecodecamp.com/images/emoji/emoji_one/beginner.png?v=3 ":beginner:") Basic Code Solution: + + var undirectedAdjList = { + James: ["Jeff"], + Jill: ["Jenny"], + Jenny: ["Jill", "Jeff"], + Jeff: ["Jenny", "James"] + }; + + +### Code Explanation: + +* The undirected graph is created using a Javascript Object. Each unique name is a key and the each person who has a relationship with the name is in the unique name's array value. e.g. if James and Jeff have a relationship, Jeff will be in James's array value and James will be in Jeff's array value. + +## ![:clipboard:](https://forum.freecodecamp.com/images/emoji/emoji_one/clipboard.png?v=3 ":clipboard:") NOTES FOR CONTRIBUTIONS: + +* ![:warning:](https://forum.freecodecamp.com/images/emoji/emoji_one/warning.png?v=3 ":warning:") **DO NOT** add solutions that are similar to any existing solutions. If you think it is **_similar but better_**, then try to merge (or replace) the existing similar solution. +* Add an explanation of your solution. +* Categorize the solution in one of the following categories — **Basic**, **Intermediate** and **Advanced**. ![:traffic_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/traffic_light.png?v=3 ":traffic_light:")