Graph Representation in Java

preview_player
Показать описание

In case you are thinking to buy courses, please check below:

---------------------------------------------------------------------------------------------------------------------------------------------------- Pr-Requisites: Previous video of Graph Series
Watch at 1.25x for best experience.

-------------------------------------------------------------------------------------------------------------------------------------------------
Java code Link:

-------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------
You can use "TAKEUFORWARD10" coupon code while checkout...

Follow them on social media for all updates:
---------------------------------------------------------------------------------------------------------------------------------------------------

#dsa​ #striversgraphchallenge​ #placements
Рекомендации по теме
Комментарии
Автор

Timestamp

00:00 Graph Input : n m weight
u v 1 (if weight is not given)
n = number of nodes
m = number of edges

01:57 Adjacency Matrix : Check whether the graph is 1 based indexing or 0 based indexing
For 1 based indexing, create a n+1 x n+1 matrix
Disadvantages : if n within range of 10^5, n x n = memory limit exceded.
03:47 Adjacency Matrix : Java Code - general representation
int adj [ ] [ ] = new int [n+1] [n+1];
adj [u] [v] = 1;
adj [v] [u] = 1;
06:45 Adjacency List : Concept
ArrayList<ArrayList<Integer>> adj = new
08:42 Space Complexity : Undirected graph - O(n + 2*e)
Directed graph - O(n + e)
n = number of nodes
e = number of edges
08:47 Adjacency List : Java Code
General representation
adj.get(u).add(v)
adj.get(v).add(u)
10:25 If edge weight given, store pair of integer

suwin
Автор

Best explanation. understood, hope this channel reaches more people

channelname
Автор

Learning java by watching your videos, after watching c++ implementation😁

tannukumari
Автор

Thank you so much, sir, if possible can you make a series with such depth for Trees as well?

ashokdurunde
Автор

Bro can you please share the notes or book from where we can revise

laveshchanchawat
Автор

what should we generally use for adjacency list in graphs?! ArrayList or LinkedList

Ryan-mrpn
Автор

Understood! Thank you very much as always!!

cinime
Автор

every lecture i visit in this channel has promotion

rohandevaki
Автор

How can we add weight, as you said pair of integers so should we have to use a map there as a key value?

priyashukla
Автор

can we use a combination of maps and list to store graphs if yes then how ?....will it be better than vectors and arrays?

devanshuanand
Автор

can somebody please explain how the space complexity is n+2e for adjacency list representation of undirected graph

tejaswigutta
Автор

you didnt take the inputs from the user in main, you just initialised it.

rohandevaki
Автор

Understood everything clearly but cat imagine the array list in arraylist 😢

anuraggoswami