Binary Trees, Graphs, and Network Knowledge (Week 8) - Learning Objectives

Assessment Structure

Binary Trees (W8D2) - Learning Objectives

Binary Trees

  1. Explain and implement a Binary Tree.
  1. Identify the three types of tree traversals: pre-order, in-order, and post-order.
  1. Explain and implement a Binary Search Tree.

Graphs (W8D3) - Learning Objectives

Graphs

  1. Explain and implement a Graph.
  1. Traverse a graph.
// If you are unfamiliar, a Set is a data structure that does not allow for repeated values
// It makes sense to use here because it has constant lookup time with its `has` method
// and our visited nodes should never have repeats.
// We could have accomplished the same thing with a different data structure
// (object, array, etc.), but a Set makes sense with what we are tracking.
function depthFirstRecur(node, visited=new Set()) {
    // if this node has already been visited, then return early
    if (visited.has(node.val)) return;

    // otherwise it hasn't yet been visited,
    // so print it's val and mark it as visited.
    console.log(node.val);
    visited.add(node.val);

    // then explore each of its neighbors
    node.neighbors.forEach(neighbor => {
        depthFirstRecur(neighbor, visited);
    });
}

depthFirstRecur(f);
// This is easy to swap to a breadth-first approach by using a queue instead of a stack!
// Instead of popping from the top, we can shift from the front
function depthFirstIter(node) {
    let visited = new Set();
    let stack = [ node ];

    while (stack.length) {
        let node = stack.pop();

        // if this node has already been visited, then skip this node
        if (visited.has(node.val)) continue;

        // otherwise it hasn't yet been visited,
        // so print it's val and mark it as visited.
        console.log(node.val);
        visited.add(node.val);

        // then add its neighbors to the stack to be explored
        stack.push(...node.neighbors);
    }
}

depthFirstIter(f);
function depthFirst(graph) {
    let visited = new Set();

    // This loop allows us to access every node/vertex, even if it wasn't connected
    // to where we started.
    // If we only wanted to reach points from a starting location, we could take in
    // that value as an argument and use it as the node directly with our helper
    // function, no need to loop.
    for (let node in graph) {
        _depthFirstRecur(node, graph, visited);
    }
}

function _depthFirstRecur(node, graph, visited) {
    if (visited.has(node)) return;

    console.log(node);
    visited.add(node);

    graph[node].forEach(neighbor => {
        _depthFirstRecur(neighbor, graph, visited);
    });
}

depthFirst(graph);
// With starting node, not exploring all nodes, only the connected ones
function depthFirstIter(graph, startNode) {
  // Just like our node implementation, if we want to operate breadth-first, we
  // can utilize a queue instead of a stack, shifting instead of popping
  let stack = [startNode];
  let visited = new Set();

  while (stack.length > 0) {
    let node = stack.pop();
    if (visited.has(node)) continue;
    console.log(node)
    visited.add(node);
    stack.push(...graph[node]);
  }
}

NOTE: The breadth-first solution to the Adjacency List problem to consider can be found from refactoring the above function. How?

Network Knowledge (W8D4) - Learning Objectives

Network Models

NOTE: USE THE ANKI FLASHCARDS TO STUDY FOR THIS PORTION OF THE ASSESSMENT

  1. Describe the structure and function of network models from the perspective of a developer.

IP Suite

  1. Identify the correct fields of an IPv6 header.
  1. Distinguish an IPv4 packet from an IPv6.
  1. Describe the following subjects and how they relate to one another: IP Addresses, Domain Names, and DNS.
  1. Identify use cases for the TCP and UDP protocols.
  1. Describe the following subjects and how they relate to one another: MAC Address, IP Address, and a port.
  1. (Optional) Identify the fields of a TCP segment.
  1. (Optional) Describe how a TCP connection is negotiated.
  1. Explaining the difference between network devices like a router and a switch.

Network Tools

These will not be on your assessment

  1. Use traceroute to show routes between your computer and other computers.
traceroute to appacademy.io (104.28.30.159), 30 hops max, 60 byte packets
 1  _gateway (10.0.0.1)  0.828 ms  0.990 ms  1.163 ms
 2  96.120.14.37 (96.120.14.37)  18.138 ms  26.191 ms  24.144 ms
 3  96.110.159.217 (96.110.159.217)  27.812 ms  27.976 ms  27.969 ms
 4  ae-2-ar01.sacramento.ca.ccal.comcast.net (162.151.18.133)  27.957 ms  27.735 ms  27.472 ms
 5  be-36441-cs04.sunnyvale.ca.ibone.comcast.net (96.110.41.109)  28.062 ms be-36421-cs02.sunnyvale.ca.ibone.comcast.net (96.110.41.101)  29.186 ms be-36431-cs03.sunnyvale.ca.ibone.comcast.net (96.110.41.105)  28.958 ms
 6  * * *
 7  be-301-cr01.9greatoaks.ca.ibone.comcast.net (96.110.37.170)  25.456 ms be-304-cr01.9greatoaks.ca.ibone.comcast.net (96.110.37.182)  25.619 ms be-303-cr01.9greatoaks.ca.ibone.comcast.net (96.110.37.178)  25.428 ms
 8  be-12578-pe04.9greatoaks.ca.ibone.comcast.net (68.86.88.18)  25.207 ms  23.485 ms  25.393 ms
 9  66.208.228.6 (66.208.228.6)  28.015 ms  26.484 ms  26.271 ms
10  104.28.30.159 (104.28.30.159)  23.235 ms  21.448 ms  21.641 ms
  1. Use Wireshark to show/inspect network traffic.