ds-algo-study
Version:
Just experimenting with publishing a package
68 lines (67 loc) • 5.99 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="A description of the page and its contents"
/>
<link rel="stylesheet" href="styles.css" />
<title>Page Title</title>
<link rel="stylesheet" href="./../../../assets/style.css" />
<link rel="stylesheet" href="./../../../assets/prism.css" />
<script async src="./../../../assets/prism.js"></script>
</head>
<body>
<h1 id="module-3-whiteboarding-exercises">Module 3 Whiteboarding Exercises</h1>
<h2 id="problem-1-breadth-first-search-on-a-graph">Problem 1: Breadth First Search on a Graph</h2>
<p>given the adjacency list below, how many friends would Joe visit if he were trying to get to Jesse using Breadth-First Traversal?</p>
<p>NOTE: your function should return the number of friends visited, not including Joe himself</p>
<div id=">pre data-role=" codeBlock" data-info="js" class="language-javascript"><code><a title="1"><span >const</span> adjacencyList <span >=</span> <span >{</span></a>
<a title="2"> <span >'derek':</span>[<span >'selam',</span> <span >'dean'</span>]<span >,</span></a>
<a title="3"> <span >'joe':</span>[<span >'selam'</span>]<span >,</span></a>
<a title="4"> <span >'selam':</span> [<span >'derek',</span> <span >'joe',</span> <span >'dean',</span> <span >'evan'</span>]<span >,</span></a>
<a title="5"> <span >'dean':</span> [<span >'derek',</span> <span >'evan',</span> <span >'selam'</span>]<span >,</span></a>
<a id=-6" title="6"> <span >'sam':</span> [<span >'jen'</span>]<span >,</span></a>
<a title="7"> <span >'evan':</span> [<span >'selam',</span> <span >'jesse',</span> <span >'dean'</span>]<span >,</span></a>
<a title="8"> <span >'jen':</span>[<span >'sam',</span> <span >'javier'</span>]<span >,</span></a>
<a title="9"> <span >'javier':</span>[<span >'jen'</span>]<span >,</span></a>
<a id=-10" title="10"> <span >'chris':</span>[]<span >,</span></a>
<a title="11"> <span >'jesse':</span> [<span >'evan'</span>]<span >,</span></a>
<a id=-12" title="12"><span >};</span></a></code></pre></div>
<h2 id="problem-2-depth-first-search-on-a-graph">Problem 2: Depth First Search on a Graph</h2>
<p>Given the adjacency list below, which friends would Joe visit if he were trying to get to Jesse using Depth-First Traversal?</p>
<p>NOTE: your function should return a list of friends visited, not including Joe himself.</p>
<div id=">pre data-role=" codeBlock" data-info="js" class="language-javascript"><code><a title="1"><span >const</span> adjacencyList <span >=</span> <span >{</span></a>
<a id=-2" title="2"> <span >'derek':</span>[<span >'selam',</span> <span >'dean'</span>]<span >,</span></a>
<a id=-3" title="3"> <span >'joe':</span>[<span >'selam'</span>]<span >,</span></a>
<a id=-4" title="4"> <span >'selam':</span> [<span >'derek',</span> <span >'joe',</span> <span >'dean',</span> <span >'evan'</span>]<span >,</span></a>
<a id=-5" title="5"> <span >'dean':</span> [<span >'derek',</span> <span >'evan',</span> <span >'selam'</span>]<span >,</span></a>
<a id=-6" title="6"> <span >'sam':</span> [<span >'jen'</span>]<span >,</span></a>
<a id=-7" title="7"> <span >'evan':</span> [<span >'selam',</span> <span >'jesse',</span> <span >'dean'</span>]<span >,</span></a>
<a id=-8" title="8"> <span >'jen':</span>[<span >'sam',</span> <span >'javier'</span>]<span >,</span></a>
<a id=-9" title="9"> <span >'javier':</span>[<span >'jen'</span>]<span >,</span></a>
<a id=-10" title="10"> <span >'chris':</span>[]<span >,</span></a>
<a id=-11" title="11"> <span >'jesse':</span> [<span >'evan'</span>]<span >,</span></a>
<a id=-12" title="12"><span >};</span></a></code></pre></div>
<h2 id="problem-3-path-sum-of-binary-tree">Problem 3: Path Sum of Binary Tree</h2>
<p>Given the binary tree below and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.</p>
<p>Use the following test-case: pathSum(5, 22) where 5 is the root node and 22 is the sum. Note: this function should return a boolean value indicating whether or not the sum is possible to achieve.</p>
<div id=">pre data-role=" codeBlock" data-info="js" class="language-javascript"><code><a title="1"><span >// 5</span></a>
<a title="2"><span >// / \</span></a>
<a title="3"><span >// 4 8</span></a>
<a id=-4" title="4"><span >// / / \</span></a>
<a id=-5" title="5"><span >// 11 13 4</span></a>
<a id=-6" title="6"><span >// / \ \</span></a>
<a id=-7" title="7"><span >// 7 2 1</span></a></code></pre></div>
<h2 id="problem-4-max-depth-of-binary-tree">Problem 4: Max Depth of Binary Tree</h2>
<p>Given a binary tree, find its maximum depth.</p>
<p>The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.</p>
<p>Note: the depth at the root is 0.</p>
<div id=">pre data-role=" codeBlock" data-info="js" class="language-javascript"><code><a title="1"> <span >// 3</span></a>
<a id=-2" title="2"> <span >// / \</span></a>
<a id=-3" title="3"> <span >// 9 20</span></a>
<a id=-4" title="4"> <span >// / \</span></a>
<a id=-5" title="5"> <span >// 15 7</span></a></code></pre></div>
<h2 id="now-go-ahead-and-start-the-problems-that-are-in-aao">Now go ahead and start the problems that are in AAO</h2>