I have been having hard time understanding this problem, a huge thanks!, I got it understand pretty well, please continue making such, your style of teaching not only provides info, but also answers the questions that we have while listening,, keep going!🙌.
This was a massive help to me, thank you so much! Got through a bunch of videos before I found this one, and it explains it perfectly. Nicely broken down and taught! Thank you c:
@@ai-powered-coder Every subscriber of yours appreciate your efforts very much. Keep posting content and we are here to learn and support. Thanks again
Thank you for the video! One question regarding the time complexity. Are you sure that it's "n!"? n! is only for the case when left == right, but that condition is not always true. Before left == right, a lot of "calculate" execution takes place, actually n*n! times. Also, swap operation and printing operation also time consuming, it's around O(n), so for each n*n! there is additional O(n). So wouldn't we have O(n^2*n!) complexity?
how can we get permutations of certain sub set in set i.e {1,2,3,4,5,6,7} i want only to get 3 numbers permutation set from this set, (i tryed to use the right index but it didnot work)
I have one question: When I ran the solution, I logged the for loop running a total of 9 times. Would this still be considered O(N!)? If I'm understanding correctly, the algorithm should run for 6 times if N = 3.
@@ai-powered-coder I used the example you coded out in Java translated into Python. Recursive, if I'm not mistaken. I'm fairly new to the time complexity stuff, so I just want to make sure I understand.
in case of the recursive algorithm, if n=3, then the complexity will be O(2^n) which is 8. That extra time (difference between 9 and 8) is a constant and hence is not that impotrant when it comes to calculating complexity.
Using an array of numbers should not make a difference. Assuming that you include single digit numbers only in the array. (To have all combinations). Would be great if you post the code to have a look to be able to better help.
I adjusted the example that was explained in the video to work with an array of numbers. Here you go: import java.util.Arrays; public class PermutationsNumbers { public static void main (String[] args) { int[] s = {1, 2, 3}; int n = s.length; PermutationsNumbers permutations = new PermutationsNumbers(); permutations.calculate(s, 0, n-1); } private void calculate(int[] nums, int left, int right) { if (left == right) { System.out.println(Arrays.toString(nums)); } else { for (int i=left; i
Two things I couldn't follow from the video. May be someone could shed some light on this. Here is how I envision the stack: first call calculate ('ABC' , left = 0, right = 2) for loop: i = 0 swapped ( 'ABC' , left = 0, i =0) => 'ABC' recursive call- calculate('ABC', left+1, right) => calculate('ABC', 1, 2) for loop: i = 1 swapped('ABC' , left =1 , i = 1) =>'ABC' ( since again left and i are same) recursive call -calculate ('ABC' , left + 1, right) => calculate('ABC' , 2, 2) if condition true: print('ABC') * What happens next ? * When is i == left not true ? It seems i is always equal to left
package basicalgos; public class Permutations { public static void main(String[] args) { String s="ABC"; int n=s.length(); Permutations p= new Permutations(); p.calculate(s, 0, n); //System.out.println("hello");
Hi Sunil! Here is the code shown in the video: public class Permutations { public static void main (String[] args) { String s = "ABC"; int n = s.length(); Permutations permutations = new Permutations(); permutations.calculate(s, 0, n-1); } private void calculate(String str, int left, int right) { if (left == right) { System.out.println(str); } else { for (int i=left; i
package basicalgos; public class Permutations { public static void main(String[] args) { String s="ABC"; int n=s.length(); Permutations p= new Permutations(); p.calculate(s, 0, n-1); //System.out.println("hello");
I have been having hard time understanding this problem, a huge thanks!, I got it understand pretty well, please continue making such, your style of teaching not only provides info, but also answers the questions that we have while listening,, keep going!🙌.
Trying to understand it for so long and now it is crystal clear,
thanks a lot.
This was a massive help to me, thank you so much! Got through a bunch of videos before I found this one, and it explains it perfectly. Nicely broken down and taught! Thank you c:
Thanks for the step-by-step code-tracing using a graph. Very helpful.
I went through 5 videos to understand this concept.... And now i am satisfied 😊
I’m very glad it helped! Thanks for your positive feedback and stay tuned for more videos :)
This is the best explanation for this problem i have seen on the internet.
Thank you for your beautiful feedback! I’m very happy you liked it :)
WOW Thank you!!! This is the best explanation I’ve found for this problem!!!
Wow, you are the best Bro. THANKS
This is brilliant Sir, please upload more content. Thank You.
Holy shit man!!! U made me understand this so quickly!! Subscribed
this really a great explanation.
Best explanation ever! Thank you so much!
Amazing explanation. Looking forward to see more of your videos.
Thanks Gurpreet! More videos are on their way :)
clean explanation , Great work
Keep doing , you are a great teacher.
superb.......... waiting for more videos
Great Explanation - Thanks
Great video.
this is gold, thank you!
that elephant poping up concept was really innovative.keep it up
Thank you very much. Glad that you like Phanto :)
Great explained 🙏
good explanation. Love it
Thank u so much....make more videos ...u explain so well!!
Man, the elephant is awesome!
Thanks man :)
Hey Dear Phanto, That was literally the easiest to understand if someone will try logic on pen and paper. Well Explained
Very glad you found it useful. Thank you for sharing your positive feedback :)
@@ai-powered-coder Every subscriber of yours appreciate your efforts very much. Keep posting content and we are here to learn and support. Thanks again
Thanks you very much Bitq! :) we (me and phanto) will continue posting for sure. Stay tuned! :)
thanks this was a great video!!!
Best! Thank you DevBox
Good explanation...
Keep going😄
This was really a great video!!! Helped me a lot
I wish u could make more videos!!!!!!
Glad to hear it helped you :)
great explanation.
very very clear explanation.
GREAT EXPLANATION. THANK YOU!!!!
Thanks for your positive feedback. Glad that you liked it :)
Really helpful!!!
oh my my....thankyou! saved my day! thankyou thankyou man!💓
You are welcome! Happy to know it helped :)
Yes where is your next video!! We would love to see it.
finally, I understood!!
Saksham Sangal happy that it helped :)
Great keep going
best explanation and elephant's questions helps to clear my doubts
Glad you loved it :)
Thanks a million :).
i hope u get million subs , now word to explain about explanation and doubts and one thing is asking question is excelent
Thanks for your positive feedback Uday :)
@@ai-powered-coder But
If I look into ur channel, no content 🙄
Please continue to upload daily
You will get viewers ❤️
Quality content takes time to create. I will ramp things up in the coming weeks :)
Very great
Thank you man
Amazing Explanation!
Glad you liked it :)
Amazing explanation!!!
Thank you very much! Glad you liked it!
helped me a lot,thank you.
Glad to hear that :)
Thank you for the video! One question regarding the time complexity. Are you sure that it's "n!"? n! is only for the case when left == right, but that condition is not always true. Before left == right, a lot of "calculate" execution takes place, actually n*n! times. Also, swap operation and printing operation also time consuming, it's around O(n), so for each n*n! there is additional O(n). So wouldn't we have O(n^2*n!) complexity?
best video on this topic!!
Glad it helped. Thanks :)
What an Egyptian accent
This was a great video . Finaaly I understood and plz make more videos 👌🏻👌🏻👍
Great to hear it was helpful for you. more videos are on the way, stay tuned. :)
Plz make some more videos
Thank you ..
Amazing explanation
Glad it was helpful!
This is brilliant
Thank you Kenneth :)
تحياتي لك يا معلم
amazing
please make more videos , your videos are awesome
a new video is coming in a week or so. Glad you like them :)
would be awesome if you could have shown the dry run beside the code.
recursive backtracking is much more suitable for this kind of problem
Respect.
Please make more videos soon
This will happen very soon 🙂
how can we get permutations of certain sub set in set i.e {1,2,3,4,5,6,7} i want only to get 3 numbers permutation set from this set, (i tryed to use the right index but it didnot work)
Hi, your accent is Egyptian lol, let me know if I am correct. Great video
I have one question:
When I ran the solution, I logged the for loop running a total of 9 times.
Would this still be considered O(N!)?
If I'm understanding correctly, the algorithm should run for 6 times if N = 3.
Which variation of the algorithm did you run? (Recursive, memorization, or tabulation)
@@ai-powered-coder I used the example you coded out in Java translated into Python. Recursive, if I'm not mistaken. I'm fairly new to the time complexity stuff, so I just want to make sure I understand.
in case of the recursive algorithm, if n=3, then the complexity will be O(2^n) which is 8. That extra time (difference between 9 and 8) is a constant and hence is not that impotrant when it comes to calculating complexity.
10/10 vid
Could you please upload more videos.... it is really helpful...
Glad you found them helpful. A new video is coming already on the way. ;)
@@ai-powered-coder Thank you 😊👍👍
Can anyone explain why the backtracking swap was not used here??
more video plssss
WHY DON'T YOU MAKE MORE VIDS :(
I am finalizing a project in hand and will focus back on the channel very soon (in 1-2 months). So if you like the content, subscribe and stay tuned 😊
Hey I have a doubt
When I use an array of numbers instead of string I am getting incorrect order
Using an array of numbers should not make a difference. Assuming that you include single digit numbers only in the array. (To have all combinations). Would be great if you post the code to have a look to be able to better help.
@@ai-powered-coder
import java.util.*; public class stringper {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in); int nums[]={1,2,3}; perm(nums,0,nums.length); } static void perm(int[] nums,int left,int right) {
for(int k=0;k
I am using two swaps If use one swap I am getting wrong answer
I adjusted the example that was explained in the video to work with an array of numbers. Here you go:
import java.util.Arrays;
public class PermutationsNumbers {
public static void main (String[] args) {
int[] s = {1, 2, 3};
int n = s.length;
PermutationsNumbers permutations = new PermutationsNumbers();
permutations.calculate(s, 0, n-1);
}
private void calculate(int[] nums, int left, int right)
{
if (left == right) {
System.out.println(Arrays.toString(nums));
}
else {
for (int i=left; i
@@ai-powered-coder why are you using swap function two times
Two things I couldn't follow from the video. May be someone could shed some light on this.
Here is how I envision the stack:
first call
calculate ('ABC' , left = 0, right = 2)
for loop:
i = 0
swapped ( 'ABC' , left = 0, i =0) => 'ABC'
recursive call- calculate('ABC', left+1, right) => calculate('ABC', 1, 2)
for loop:
i = 1
swapped('ABC' , left =1 , i = 1) =>'ABC' ( since again left and i are same)
recursive call -calculate ('ABC' , left + 1, right) => calculate('ABC' , 2, 2)
if condition true:
print('ABC')
* What happens next ?
* When is i == left not true ? It seems i is always equal to left
Exactly, I feel the same way. The code doesn't work when I envision it. it just swaps itself all through
I'm getting thread exception while executing
package basicalgos;
public class Permutations {
public static void main(String[] args) {
String s="ABC";
int n=s.length();
Permutations p= new Permutations();
p.calculate(s, 0, n);
//System.out.println("hello");
}
private void calculate(String str,int left,int right)
{
if(left==right-1)
{
System.out.println(str);
}
else
{
for(int i=left;i
Hi Sunil!
Here is the code shown in the video:
public class Permutations {
public static void main (String[] args) {
String s = "ABC";
int n = s.length();
Permutations permutations = new Permutations();
permutations.calculate(s, 0, n-1);
}
private void calculate(String str, int left, int right)
{
if (left == right) {
System.out.println(str);
}
else {
for (int i=left; i
my code is not working in eclipse
What is this algorithm called?
Not really sure if it has a specific name. It is the string permutation algorithm :)
Is this Heap's algorithm?
No the heap’s algorithm is a little different. But both of them get the permutations if a string.
Please return to make videos
I will do that for sure! :)
package basicalgos;
public class Permutations {
public static void main(String[] args) {
String s="ABC";
int n=s.length();
Permutations p= new Permutations();
p.calculate(s, 0, n-1);
//System.out.println("hello");
}
private void calculate(String str,int left,int right)
{
if(left==right)
{
System.out.println(str);
}
else
{
for(int i=left;i