From 0 To 1 Data Structures Course

Learn so you can see it with your eyes closed

Last updated 2022-01-10 | 4.5

- Visualise - really vividly imagine - the common data structures
- and the algorithms applied to them
- Pick the correct tool for the job - correctly identify which data structure or algorithm makes sense in a particular situation
- Calculate the time and space complexity of code - really understand the nuances of the performance aspects of code

What you'll learn

Visualise - really vividly imagine - the common data structures
and the algorithms applied to them
Pick the correct tool for the job - correctly identify which data structure or algorithm makes sense in a particular situation
Calculate the time and space complexity of code - really understand the nuances of the performance aspects of code

* Requirements

* Basic knowledge of programming is assumed
* preferably in Java

Description

This is an animated, visual and spatial way to learn data structures and algorithms

  • Our brains process different types of information differently - evolutionarily we are wired to absorb information best when it is visual and spatial i.e. when we can close our eyes and see it
  • More than most other concepts, Data Structures and Algorithms are best learnt visually. These are incredibly easy to learn visually, very hard to understand most other ways
  • This course has been put together by a team with tons of everyday experience in thinking about these concepts and using them at work at Google, Microsoft and Flipkart

What's Covered:

  • Big-O notation and complexity
  • Stacks
  • Queues
  • Trees
  • Heaps
  • Graphs and Graph Algorithms
  • Linked lists
  • Sorting
  • Searching

Who this course is for:

  • Yep! Computer Science and Engineering grads who are looking to really visualise data structures, and internalise how they work
  • Yep! Experienced software engineers who are looking to refresh important fundamental concepts

Course content

17 sections • 67 lectures

You, This course and Us Preview 02:00

A short intro to this course and what you can expect at the end of the course.

Why are Data Structures And Algorithms important? Preview 15:04

Data structures and Algorithms have a symbiotic relationship. The choice of data structure significantly influences the algorithms' performance and complexity and vice versa. Also learn about abstract data types and how they relate to data structures.

Performance and Complexity Preview 16:02

What is the performance of your code? How do you measure this? What is complexity and what is its relationship with performance?

The Big-O Notation Preview 15:58

The Big O notation is used to express complexity based on the size of the input specified for any algorithm. How is Big O expressed, how is it calculated and many examples to drive the concepts home!

What is the complexity of these pieces of code? Preview 19:13

The Big O notation becomes much clearer when you practice find the complexity of some sample pieces of code. Let's see how many of these you get right!

The Linked List - The Most Basic Of All Data Structures Preview 19:55

Linked lists are just one way to implement lists. Linked lists are less interesting in Java then in other programming languages such as C and C++ which require the developer to manage memory.

However lists are useful and a very core data structure so it makes sense to start off this class by understanding how we can set up a linked list in Java.

Linked List Problems Preview 10:25

A few basic problems working with lists should give you a good idea of how to traverse and linked lists, add elements to a list and count the number of elements in a list.

The source code attached to this lecture has solutions for even more linked list based problems which are not covered in this lecture.

Linked Lists vs Arrays Preview 10:27

Linked lists and arrays solve the same kind of problems, holding a list or a collection. When would you use one over the other? Learn how you can make an informed choice.

Meet The Stack - Simple But Powerful Preview 15:40

The stack is a very simple and easy to understand data structure. However it lies underneath many complicated real world problems and is incredibly useful.

Building A Stack Using Java Preview 16:53

Let's build a stack for real using Java. It'll have all the operations we're interested in - push, pop, peek, size etc. It can hold any data type, it's a generic class.

Match Parenthesis To Check A Well Formed Expression Preview 11:21

Problems which use stacks as a part of their solutions are very common in programming interviews. Matching parenthesis to check for well formed expressions is a classic interview question - let's solve this using the stack we're already implemented.

Find The Minimum Element In A Stack In Constant Time Preview 08:51

Another interview question implemented. You have space available but your processing needs to be very fast indeed. How would you keep track of the minimum element of a stack as it changes?

Meet The Queue - A Familiar Sight In Everyday Life Preview 14:11

The queue belongs to the same linear data structure family as the stack but it's behavior is very different. Queues are much more intuitive as there are plenty of real world examples where a queue is the fair and correct way of processing.

The Circular Queue - Tricky But Fast Preview 19:44

A common, fast but slightly tricky implementation of the queue is the array where the last element wraps around to the first. An interview favorite, let's see how to implement the circular queue.

Build A Queue With Two Stacks Preview 17:30

We know the stack, and we know the queue. This problem brings them together. It's possible to mimic the behavior of a queue using 2 stacks in the underlying implementation. Let's write the most efficient code possible to make this work.

Sorting Trade-Offs Preview 10:52

A sorting algorithm is not just defined by its complexity, there are a whole bunch of other characteristics which can be used to determine which sorting algorithm is the right one for a system. Let's understand what these characteristics are and what are the trade offs we might make.

Selection Sort Preview 15:24

The simplest and most naive sorting algorithm.

Bubble Sort Preview 14:39

Closely allied with selection sort is bubble sort. Its an adaptive sort with the same time complexity as selection sort.

Insertion Sort Preview 14:32

Insertion sort is an improvement over both bubble sort and selection sort. Let's see how exactly it works and why it's preferred in many cases.

Shell Sort Preview 14:17

Shell sort builds on top of insertion sort, it improves the complexity of it's running time by partitioning the list in a clever way.

Merge Sort Preview 19:23

This belongs to a class of algorithms which uses divide and conquer to break the problem set into smaller pieces. This also makes a time-space trade off to get a faster running time.

Quick Sort Preview 15:30

Quick sort is the sort of choice for developers of programming libraries. Let's see what makes it so attractive.

Binary Search - search quickly through a sorted list Preview 11:10

Binary search is a pretty nifty way to search through a sorted list in O(Log N) time. It's also an interview favorite so make sure you understand it well!

Meet The Binary Tree - A Hierarchical Data Structure Preview 13:03

The binary tree is an incredibly useful hierarchical data structure. Many other, more complex data structures, use the binary tree as the foundation. Let's see what a binary tree looks like and learn some simple terminology associated with the tree.

Breadth First Traversal Preview 18:43

Traversing a binary tree can be done in variety of ways. The breadth first traversal visits and processes nodes at every level before moving on to the next. Let's visualize breadth first traversal and see how it's implemented.

Depth First - Pre-OrderTraversal Preview 14:35

Depth first traversal can be of 3 types based on the order in which the node is processed relative to it's left and right sub-trees. Pre-order traversal processes the node before processing the left and then the right sub trees.

Depth First - In-Order and Post-Order Traversal Preview 13:51

Depth first traversal can be of 3 types based on the order in which the node is processed relative to it's left and right sub-trees.

In-order traversal processes the left subtree, then the node itself and then it's right sub trees. Post-order traversal processes the node *after* it's left and right subtrees.

The algorithms are all remarkably similar and very easy once you use recursion.

The Binary Search Tree - an introduction Preview 09:49

A Binary Search Tree is a binary tree with specific constraints which make it very useful in certain operations. Learn what a BST is and how we can use it

Insertion and Lookup in a Binary Search Tree Preview 17:00

Insertion and Lookup are operations which are very fast in a Binary Search Tree. See how they work and understand their performance and complexity.

Minimum Value, Maximum Depth And Mirror Preview 12:14

Find the minimum value in a binary search tree, find the maximum depth of a binary tree and mirror a binary tree. Learn to solve these problems recursively and see implementation details.

Count Trees, Print Range and Is BST Preview 14:38

Count the number of structurally unique binary trees that can be built with N nodes, print the nodes within a certain range in a binary search tree and check whether a certain binary tree is a binary *search* tree. Learn to solve these problems and understand the implementation details.

The Heap Is Just The Best Way to Implement a Priority Queue Preview 17:15

Priority Queues allow us to make decisions about which task or job has the highest priority and has to be processed first. Common operations on a Priority Queue are insertion, accessing the highest priority element and removing the highest priority element.

The Binary Heap is the best implementation of the Priority Queue.

Meet The Binary Heap - It's A Tree At Heart Preview 12:39

The Binary Heap is logically a Binary Tree with specific constraints. Constraints exist on the value of a node with respect to it's children and on the shape of the tree. The heap property and the shape property determine whether a Binary Tree is really a Heap.

The Binary Heap - Logically A Tree Really An Array Preview 17:13

The Binary Heap may logically be a tree, however the most efficient way to implement it is using an array. Real pointers from parent to child and from child to parent become implicit relationships on the indices of the array.

The Binary Heap - Making It Real With Code Preview 07:38

Let's build a real heap in Java!

Heapify! Preview 19:32

How do we ensure that when we add an element or remove an element from an existing heap, that the heap property and shape property is maintained? This operation is called Heapify.

Insert And Remove From A Heap Preview 16:34

Once we understand heapify, adding and removing elements from a heap become very simple.

Heap Sort Phase I - Heapify Preview 19:31

Back to sorting. The Heap Sort uses a heap to transform an unsorted array into a sorted array. Phase I is converting the unsorted array into a heap.

Heap Sort Phase II - The Actual Sort Preview 17:42

Phase II actually outputs the final sorted array. It involves removing the elements from the heap and placing it in a sorted array. The cool thing is that all of this can be done in-place.

Maximum Element In A Minimum Heap and K Largest Elements In A Stream Preview 15:54

Let's practice heap problems! Use the heap property to find the largest element in a minimum heap and the K largest elements in a stream.

Introducing The Graph Preview 15:40

The graph is a data structure that is used to model a very large number of real world problems. It's also an programming interview favorite. The study of graphs and algorithms associated with graphs forms an entire field of study called graph theory.

Types Of Graphs Preview 07:21

Edges in a graph can be directed or undirected. A graph with directed edges forms a Directed Graph and those with undirected edges forms an Undirected Graph. These edges can be likened to one-way and two-way streets.

The Directed And Undirected Graph Preview 14:29

Different relationships can be modeled using either Directed or Undirected graphs. When a graph has no cycles it's called an acyclic graph. A graph with no cycles is basically a tree.

Representing A Graph In Code Preview 08:09

There are a number of different ways in which graphs can be implemented. However they all follow they same basic graph interface. The graph interface allows building up a graph by adding edges and traversing a graph by giving access to all adjacent vertices of any vertex.

Graph Using An Adjacency Matrix Preview 15:25

An adjacency matrix is one way in which a graph can be represented. The graph vertices are rows and columns of the matrix and the cell value shows the relationship between the vertices of a graph.

Graph Using An Adjacency List And Adjacency Set Preview 17:53

The adjacency list and the adjacency set are alternate ways to represent a graph. Here the connection between the vertices is represented using either a linked list or a set.

Comparison Of Graph Representations Preview 10:08

Compare the adjacency matrix, adjacency list and the adjacency set in terms of space and time complexity of common operations

Graph Traversal - Depth First And Breadth First Preview 14:56

Common traversal methods of trees apply to graphs as well. There is an additional wrinkle with graphs, dealing with cycles and with unconnected graphs. Otherwise the algorithms are exactly the same as those we use to traverse trees.

Topological Sort In A Graph Preview 17:30

Topological sort is an ordering of vertices in a graph where a vertex comes before every other vertex to which it has outgoing edges? A mouthful? This lecture will make things easy to follow. Topological sort is widely used in real world problems.

Implementation Of Topological Sort Preview 06:56

Here is the code in Java to implement topological sort.

Introduction To Shortest Path In An Unweighted Graph - The Distance Table Preview 12:38

Graphs with simple edges (directed or undirected) are unweighted graphs. The distance table is an important data structure used to find the shortest path between any two vertices on a graph. This is used in almost every shortest path algorithm.

The Shortest Path Algorithm Visualized Preview 14:15

Visualize the shortest path algorithm using the distance table, step by step.

Implementation Of The Shortest Path In An Unweighted Graph Preview 06:19

Shortest path implementation in Java.

Introduction To The Weighted Graph Preview 03:29

So far we only deal with unweighted graphs. Graphs whose edges have a weight associated are widely used to model real world problems (traffic, length of path etc).

Shortest Path In A Weighted Graph - A Greedy Algorithm Preview 18:47

A greedy algorithm is one which tries to find the local optimum by looking at what is the next best step at every iteration. It does not look at the overall picture. It's best used for optimization problems where the solution is very hard and we want an approximate answer.

Finding the shortest path in a weighted graph is a greedy algorithm.

Dijkstra's Algorithm Visualized Preview 14:14

Dijkstra's algorithm is a greedy algorithm to find the shortest path in a weighted graph.

Implementation Of Dijkstra's Algorithm Preview 08:14

The implementation of Dijkstra's algorithm in Java.

Introduction To The Bellman Ford Algorithm Preview 08:40

A weighted graph can have edge weights which are negative. Dealing with negative weights have some quirks which are dealt with using the Bellman Ford algorithm.

The Bellman Ford Algorithm Visualized Preview 11:22

Visualize how the Bellman Ford works to find the shortest path in a graph with negative weighted edges.

Dealing With Negative Cycles In The Bellman Ford Algorithm Preview 07:36

If a graph has a negative cycle then it's impossible to find a shortest path as every round of the cycle makes the path shorter!

Implementation Of The Bellman Ford Algorithm Preview 06:54

Prim's Algorithm For a Minimal Spanning Tree Preview 17:27

A minimal spanning tree is a tree which covers all the vertices of of the graph and has the lowest cost. Prim's algorithm is very similar to Dijkstra's shortest path algorithm with a few differences.

Use Cases And Implementation Of Prim's Algorithm Preview 09:52

The minimal spanning tree is used when we want to connect all vertices at the lowest cost, it's not the shortest path from source to destination.

Let's see how we implement Prim's algorithm in Java.

Kruskal's Algorithm For a Minimal Spanning Tree Preview 08:43

Kruskal's algorithm is another greedy algorithm to find a minimal spanning tree.

Implementation Of Kruskal's Algorithm Preview 07:33

Design A Course Schedule Considering Pre-reqs For Courses Preview 13:01

Given a course list and pre-reqs for every course design a course schedule so pre-reqs are done before the courses.

Find The Shortest Path In A Weighted Graphs - Fewer Edges Better Preview 14:31

Find the shortest path in a weighted graph where the number of edges also determine which path is shorter.