Warmup

Write A function that finds the maximum allowable size of an array in your javascript runtime

Data Structures

Round 2

Data Structures

Linked Lists & Graphs

Objectives

  • Discuss the spatial aspects of algorithmic complexity
  • Evaluate the trade-offs inherent in selecting data structures
  • Write the code for a simple linked list class

Vocabulary

  • Node - An Item in a data structure
  • Edge - A connection between nodes
  • Pointer - Numeric reference to a memory address

Spatial Complexity

How Big is my Data?

=

How many memory "cells"

How big is the world

let size = Number.MAX_SAFE_INTEGER;
900719925474099

let hugeData = Array(size);

//Error - invalid array length

let maxArrayLength =  4294967295;

Linked Lists

Linked Lists

type Tree<T> = {
    value: T;
    left: Tree<T>;
    right: Tree<T>;
}


type LinkedList<T> = T & { next: LinkedList<T> };

Linked Lists

type LinkedList<T> = T & { next: LinkedList<T> };

interface Person {
    name: string;
}

var people: LinkedList<Person>;
var s = people.name;
var s = people.next.name;
var s = people.next.next.name;
var s = people.next.next.next.name;

deck

By Matt Sprague