Byte-Sized-Chunks: Graph Algorithms and Problems in Java

Djisktra, Prim, Kruskal, Bellman-Ford, the topological sort - all will make sense now!
4.7 (5 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
65 students enrolled
$19
$20
5% off
Take This Course
  • Lectures 28
  • Length 5 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 3/2016 English

Course Description

Note: This course is a subset of our much longer course 'From 0 to 1: Data Structures & Algorithms' so please don't sign up for both:-)

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

Taught by a Stanford-educated ex-Googler.

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.

  • Directed and undirected graphs
  • Adjacency matrices, lists and sets
  • Breadth and Depth-First traversal
  • Topological sort
  • Djikstra's algorithm
  • Bellman-Ford algorithm
  • Prim's algorithm
  • Kruskal's algorithm

Mail us about anything and we will always reply :-)

What are the requirements?

  • Basic knowledge of programming is assumed, preferably in Java

What am I going to get from this course?

  • Design and implement software using canonical graph algorithms - Djikstra, Prim, Kruskal, Bellman Ford and topological sort
  • Understand the use-cases for the common graph algorithm

What is the target audience?

  • Nope! Please don't enroll for this class if you have already enrolled for our 15-hour course 'From 0 to 1: Data Structures and Algorithms'
  • 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
  • Yep! MBA graduates or business professionals who are looking to move to a heavily quantitative role

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Its A Connected World!
You, This Course, and Us!
Preview
01:14
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.
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.
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.
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.

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.
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.
10:08

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

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.

Section 2: Graph Algorithms
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.
06:56
Here is the code in Java to implement topological sort.
Section 3: Shortest Path Algorithms
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.
14:15
Visualize the shortest path algorithm using the distance table, step by step.
06:19
Shortest path implementation in Java.
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).

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.

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

The implementation of Dijkstra's algorithm in Java.

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.

11:22
Visualize how the Bellman Ford works to find the shortest path in a graph with negative weighted edges.
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
06:54
Section 4: Spanning Tree Algorithms
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.
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.

08:43
Kruskal's algorithm is another greedy algorithm to find a minimal spanning tree.
Implementation Of Kruskal's Algorithm
07:34
Section 5: Graph Problems
13:01
Given a course list and pre-reqs for every course design a course schedule so pre-reqs are done before the courses.
14:31
Find the shortest path in a weighted graph where the number of edges also determine which path is shorter.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Loony Corn, A 4-person team;ex-Google; Stanford, IIM Ahmedabad, IIT

Loonycorn is us, Janani Ravi, Vitthal Srinivasan, Swetha Kolalapudi and Navdeep Singh. Between the four of us, we have studied at Stanford, IIM Ahmedabad, the IITs and have spent years (decades, actually) working in tech, in the Bay Area, New York, Singapore and Bangalore.

Janani: 7 years at Google (New York, Singapore); Studied at Stanford; also worked at Flipkart and Microsoft

Vitthal: Also Google (Singapore) and studied at Stanford; Flipkart, Credit Suisse and INSEAD too

Swetha: Early Flipkart employee, IIM Ahmedabad and IIT Madras alum

Navdeep: longtime Flipkart employee too, and IIT Guwahati alum

We think we might have hit upon a neat way of teaching complicated tech courses in a funny, practical, engaging way, which is why we are so excited to be here on Udemy!

We hope you will try our offerings, and think you'll like them :-)

Ready to start learning?
Take This Course