JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
Jul 14, 2022 21:21
Does anyone here uses Vscode? I am trying to get this extension called 'live server' to work but it doesn't work as expected ( it doesn't auto reload the page and i have to manually do it myself). If this isn't the right place to ask it, can you suggest me the appropriate room to do so? Thanks!
Jul 14, 2022 21:20
Hi guys
 

C++ Questions and Answers

Solve problems and approach solutions. Just ask and lurkers wi...
Mar 28, 2022 07:40
also, this code won't work for disconnected graphs, right ? github.com/striver79/StriversGraphSeries/blob/main/BfsCpp#L26
Mar 28, 2022 07:25
thanks
Mar 28, 2022 07:25
can someone please let me know how to get the ans vector from the function properly ?
Mar 28, 2022 07:24
i do not get the bfs sequence as desired ( there are duplicates and stuff )
Mar 28, 2022 07:24
and if i then try to print the ans vector
Mar 28, 2022 07:24
ans being the separate vector used to receive the bfs vector
Mar 28, 2022 07:23
for(int i=1;i<=v;i++)
{
if(!vis[i])
{
ans= bfs(i,vis,adj);
}
}
Mar 28, 2022 07:23
since i implemented the bfs for connected/disconnected graphs , if i simply do the changes inside the for loop of the main function as :
Mar 28, 2022 07:22
but what i am facing difficulty with is understanding how do I receive that vector which i returned from my bfs function
Mar 28, 2022 07:21
but now i want to be able to not just print out the vertices as i visit them , but instead i want to store them in a separate vector as i visit them and then finally return the whole vector from the bfs function at last
Mar 28, 2022 07:19
I implemented the bfs algorithm for any connectec/disconnected graph like this
Mar 28, 2022 07:19
hi
Feb 28, 2022 07:31
Thanks, I'll take a look at it in a bit
Feb 28, 2022 06:37
Sorry I still do not understand fully what's happening
Feb 28, 2022 06:33
this is the complete code : wtools.io/paste-code/b9HK
Feb 28, 2022 06:24
I understand that 'i' is an iterator for the vector of the nodes ( representing adjacency list ). But how is that then being used as an index to a different vector 'v'?
Feb 28, 2022 06:13
so I guess my question is, why a pointer ?
Feb 28, 2022 06:12
I mean I get how the algorithm works, I'm just confused about that part of the code in which I'm required to use a pointer of i to in the v vector
Feb 28, 2022 06:12
@JerryCoffin yes
Feb 28, 2022 06:10
my question is, why do I need to use v[*i] , that is why do I need to use a pointer of i ? And why would it not work if i do not use it and instead just use v[i]
Feb 28, 2022 06:09
here, v is the bool vector used to maintain the info about whether a vertex has been visited or not and g is a vector of vectors used to represent the adjacency list.
Feb 28, 2022 06:08
// Enqueue all adjacent of f and mark them visited
for (auto i = g[f].begin(); i != g[f].end(); i++) {
if (!v[*i]) {
q.push(*i);
v[*i] = true;
}
}
Feb 28, 2022 06:08
Hello, I'm learning how to implement BFS using C++ STL and I don't get this part :
 

Lounge<C++>

Today we're daydreaming about C++26 reflection
Jun 3, 2020 17:16
@EtiennedeMartel Ah , right , thank you (:
Jun 3, 2020 17:00
Any help would be greatly appreciated .
Jun 3, 2020 16:59
Why am I not getting the desired output ?
Jun 3, 2020 16:59
Jun 3, 2020 16:57
this is my attempt
Jun 3, 2020 16:57
and I was looking to solve the following problem using sets
Jun 3, 2020 16:56
I've recently started learning about containers
Jun 3, 2020 16:56
Hi
 

Java

Dedicated to the discussion of the Java programming language a...
Nov 22, 2019 19:35
@fredoverflow Thanks for helping , I have a test tomorrow
Nov 22, 2019 19:34
@fredoverflow Ah I see, it goes over the array size limit at the last iteration.How do I overcome this ?
Nov 22, 2019 17:56
Could anyone please look into it ?
Nov 22, 2019 17:48
I'm getting arrayindexoutofbounds exception at lines 7 and 18 , can someone please let me know why and how I can possibly get the desired output (i.e. the sorted array)
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Oct 20, 2019 21:01
2nd
Oct 20, 2019 21:00
I'm just starting learning python in class , can't tell the prof what to teach either
Oct 20, 2019 21:00
@AndrasDeak exactly lol
Oct 20, 2019 20:57
I didn't use the object of the class to call the function :/
Oct 20, 2019 20:56
Ah I think I've got it
Oct 20, 2019 20:55
I was just doing that as an analogy to C++ and JAVA programs
Oct 20, 2019 20:54
what are they for ?
Oct 20, 2019 20:53
I've got a practical tomorrow and I was just looking to make a basic class that had a function to add two numbers
Oct 20, 2019 20:53
uhm