« first day (2013 days earlier)      last day (906 days later) » 

04:37
@JohnRennie hi sir :-) good morning
how are you ?
@ronakjain Hi :-)
I'm good thanks, how are you?
I'm also good
Sir... Is there any advantage of using linked lists over simple arrays ? My prof told that linked lists can be used to dynamically allocate the space ... But that's even possible in arrays !!
And whenever someone says the advantage of dynamically allocation .. I always think why it's even important now.. That's possible without using those functions
In C and C++ arrays can't simply be dynamically grown. You need to call realloc() to change the array size so it isn't completely trivial. With a linked list you just insert the new node into the list.
But the real advantage of linked lists is how efficient they are at inserting and removing elements.
Suppose you have an array with a thousand elements and you want to delete the first element.
You need to loop over the remaining 999 elements and copy them one place to the left in the array. Yes?
With a linked list you just unlink the first node so it takes only a single line of code.
04:47
@JohnRennie But can't realloc() be used to increase the size of array ?
Yes it can, but realloc() actually works by creating a new bigger array and copying all the data from the original array to the new array, so it's quite slow.
ok.. And in linked lists we simply declare a new node and then link it to the remaining
I got it sir... Thanks
04:53
@JohnRennie Hi !
@KavinIshwaran Hi :-)
in P-P covalent bond formation, why Pz orbital first form the bond ?
and why Pz and other orbital cant form bond ? (like Pz - Px or Px - Py)
There isn't any difference between the pz, py and px orbitals. We just choose a direction to call z, y and x. So if we choose our z axis to be along the bond then by definition the p orbitals that lie along this axis are the pz bonds.
Does this help?
So any orbital can form the bond first ?
Well we could choose our x axis to lie along the bond. Yes?
05:01
Yes
Then the bond would form between the two px orbitals. Yes?
That's all there is to it.
@JohnRennie If covalent bond is formed by overlap of two orbitals
You mean could pz and px form a bond?
Or do you mean like a double or triple bond?
05:06
Long back in a discussion you said as long as two orbitals have opposite spin they can overlap, so how do we know if two bonds have electrons of opposite spin ?
I'll have to get back to you in a bit. I'm currently answering another question and this is shaping to be a long discussion.
@JohnRennie Hi! :)
How do you rank these composites from highest to lowest strength in the longitudinal direction?
Is there a comprehensive equation to this?
@KevinN That isn't something I have ever done so I don't know the answer ...
@KavinIshwaran I'm free now if you want to pick this up
05:22
@JohnRennie yes we can continue
Suppose we have two boron atoms forming a bond. I chose boron because it's 1s²2s²2p¹ so it's the single 2p electron forming the σ bond between the two atoms.
If the 2p electrons in the B atoms have the same spin then they cannot bond because you cannot put two same spin electrons in a σ bond. One of the electrons would have to go into a higher energy molecular orbital i.e. it would have to form the B₂ molecule in an excited state.
That probably wouldn't happen, so the atoms simply wouldn't bond to each other.
OK so far?
But if we have a gas of boron atoms the atoms are continually colliding and in a collision they can exchange spin angular momentum.
05:28
Oh
So if two boron atoms can't bond because their electron spins are the same that doesn't matter as collisions are continually rearranging the spins.
On average 50% of collisions have the wrong spin and can't bond, but the collisions are continually happening so this doesn't prevent the reaction, it only reduces the rate of reaction.
This tempts me to ask a question. can a electron change its spin ?
Spin has an associated angular momentum, and angular momentum is a conserved quantity.
So an isolated atom cannot change its spin because that would change its angular momentum, which isn't allowed.
Yes, but angular momentum in QM is different from that pf CM right ?
True, but it's still a conserved quantity.
05:33
OK then
But suppose you have two atoms and the total spin of the pair is zero.
You could start with atom 1 up and atom 2 down, and they could collide and exchange spins so now atom 1 was down and atom 2 up.
So the spin of any one atom is not conserved, but the total spin must still be conserved.
Oh
@JohnRennie Thank you for some clarification :-)
You're welcome :-)
05:42
#include<stdio.h>
#include<stdlib.h>
typedef struct first{
    int a;
    struct first *next;
}first;
int main(){
    struct first *head = NULL, *p, *prev;
    int n;
    printf("Enter Number of Nodes : \n");
    scanf("%d ", &n);
    int total = 0;
    for(int i = 0;i<n;i++){
        p = (first *)malloc(sizeof(first));
        printf("Enter %d th number : ", i+1);
        scanf("%d", &p->a);
        total += (*p).a;
        if(head == NULL){
            head = p;
            prev = p;
        }
@JohnRennie sir.. I tried making a linked list to find sum of numbers.. it's neither giving any error not working properly :( Can you plz help me figure it out
It's giving correct output but I find the similar kind of problem that I faced while learning input buffer
Hi :-)
hi sir
Give me a moment to try running your code ...
yes sir
    printf("Enter Number of Nodes : \n");
    scanf("%d ", &n);
             ^ you put a space here
05:51
Does that also matter ?
So the scanf is expecting a number then a space. Remove the space and it will work fine.
@JohnRennie Sir .. Can you plz elaborate it a bit more...
What do you want me to discuss? Why having the extra space in the scanf() string is causing a problem?
yes sir
Actually I'm not sure what the space is doing. I found that when I remove it the code works as expected and when I put it back the code doesn't run properly. But I'm not sure why. I would have to go off and research it.
05:56
ok sir
It happens with both GNU C and Microsoft C so it's obviously a feature of the language not a quirk of the C compiler.
ok sir
@ronakjain Aha, this is described here.
And I didn't think there was anything left for me to learn about C! :-)
haha
So it will just wait until I enter a non whitespace character
Yes. So when you type e.g. "3" for three nodes the scanf does not return because it's waiting for the next non space character.
Then when you type "1" for the first node scanf() returns, stores 3 in n and leaves the "1" in the input buffer for the next scanf() to read.
06:12
Sir what happens to those \n characters which are left in the input buffer ?
scanf() treats \n as white space so it reads past it.
scanf() or scanf("%d) ?
scanf() with any format string.
but sir it does assign the newline character to the char formatted string
Suppose you call scanf("%s", &s)
06:16
yes sir
First scanf will read past any whitespace characters so any spaces or \n left in the input buffer are ignored.
Then it starts reading non-whitespace characters and storing them in the buffer s.
Then stops at the next whitespace character e.g. it stops when it reads a space or \n.
@JohnRennie Sir.. I didn't get this
Can you give an example
When it doubt I always recommend trying it to see what happens. So let's write a little program to test it. Give me a moment ...
#include<stdio.h>

int main()
{
    char s[256];

    printf("Enter a string: ");
    scanf("%s", s);
    printf("You entered: %s\n", s);

    return 0;
}
Actually, lets put a character either side of the string in the printf ...
#include<stdio.h>

int main()
{
    char s[256];

    printf("Enter a string: ");
    scanf("%s", s);
    printf("You entered: >%s<\n", s);

    return 0;
}
So if I run this I get:
D:\rhs\Students\Ronak\c>test
Enter a string: abc
You entered: >abc<
Do you get the same?
yes sir
OK so now let me try type spaces then abc then more spaces:
D:\rhs\Students\Ronak\c>test
Enter a string:       abc
You entered: >abc<
06:25
I'm also getting the same
scanf skips past and ignores all the leading space and only starts reading characters into s at the first non-space character. It stops at the first space after abc so the trailing spaces also don't get read into the string.
Yes?
Now I'll press enter a few times before typing abc:
D:\rhs\Students\Ronak\c>test
Enter a string:



abc
You entered: >abc<
So it also skips past and ignores all \ns before the string. Yes?
i.e. it treats \n just like space.
yes sir
Does this make it clearer?
06:28
yes sir
OK :-)
@JohnRennie with string it make sense now.. But if I write with char format scanf.. Then it assigns the new line and space character to the respective variables
That's because a string is defined as a sequence of non-whitespace characters i.e. characters that are not space or tab or \n. So when reading a string scanf ignores any leading or trailing whitespace characters.
But a char is any character, including whitespace characters.
So when reading with %c scanf does not ignore whitespace characters.
Ok sir.. I got it.. Thanks
OK :-)
You need to be careful with scanf. It can be useful but it is also complicated and you need to be careful that you understand what it will read. I have to say I don't use scanf very much.
06:35
ok sir
 
2 hours later…
08:11
@JohnRennie sir.. I made a programme which returned the pointer of a linked list... But during running it is showing a warning of Incompatible data type... but working properly
hi sir
Post the code and I'll have a look
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct stud{
    int roll;
    char *name;
    int percentage;
    int class;
    struct stud *next;
}student;
struct student *find(student *head, int n){
    student *copy = head;
    while(copy!=NULL){
        if(copy->roll == n){
            return copy;
        }
        copy = copy->next;
    }
}
int main(){
    student *head = NULL;
    student *p, *prev;
    char name[50];
    int n = 1;
    while(n){
        p = (student *)malloc(sizeof(student));
D:\rhs\Students\Ronak\c>gcc test.c -o test.exe
test.c: In function 'find':
test.c:15:20: warning: return from incompatible pointer type [-Wincompatible-pointer-types]
             return copy;
                    ^~~~
test.c: In function 'main':
test.c:56:22: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     student *alpha = find(head, roll);
                      ^~~~
08:14
yes sir
But it's working properly
It's because you have used typedef to define a new type student to mean struct student.
Are you comfortable with what this means and what typedef does?
I don't know what typedef does.. I just learnt its the syntax to define a new structure
OK, so let's briefly go into this.
yes sir
In early versions of C you would define a struct like this:
struct student
{
    int roll;
    char *name;
    int percentage;
    int class;
    struct student *next;
};
08:18
ok sir
But this is kind of a pain, because everywhere you want to use your struct you have to declare the variables like:
struct student s;
struct student *p;
yes sir
i.e. you have to write the word struct everywhere to tell C the data type is a struct. But this quickly gets to be a a pain, so later versions of C added the typedef command.
Hi @JohnRennie I have a question!
This allows you to define a new type. e.g. I could write this (though it wouldn't be very useful):
typedef int myint;
08:21
yes sir
This defines a new type myint that is defined to mean int. So if I do this I could write:
myint foo = 12;
Now in your code you have:
yes sir
typedef struct stud{
    int roll;
    char *name;
    int percentage;
    int class;
    struct stud *next;
}student;
So you are defining a struct stud and then you are defining the new type student to mean struct stud.
But look at your find() function:
struct student *find(student *head, int n){
    student *copy = head;
    while(copy!=NULL){
        if(copy->roll == n){
            return copy;
        }
        copy = copy->next;
    }
}
I had not to use struct at starting
You have specified that it returns struct student*. Yes?
08:25
yes sir
@ronakjain Yes :-) You just want it to return student*. Take out the struct and the code will compile without any errors.
Thanks sir I got it
OK :-)
@cOnnectOrTR12 Hi
Hi 👋
Question sent
To do this first I calculated the speed of big ball
6 m/s
Then I wrote the formula of total Ke and found the Ke of the small ball
And then I used the conservation of momentum and found the p of the small ball
And at last I used Ke =p^2/2m
But I am getting wrong result m=.315 kg
I'm not sure exactly what you did, but it sounds to me as if you have done the wrong calculation. You do not need to use the kinetic energy.
08:32
@JohnRennie wait let me show you
Sent
Let me go this and I'll explain how it works. Give me a moment to draw a diagram
Yes
After collision the big ball stops
On the left we have the situation immediately before the large ball hits the ground. As you say, both balls have a velocity of 6 m/s downwards.
The middle shows the situation immediately after the large ball has hit the ground and bounced back up, but before the large and small ball have collided.
08:45
Yes
So at this moment the large ball is moving up at 6 m/s while the small ball is moving down at 6 m/s.
Absolutely
Then the balls collide and bounce back from each other. We are told that at this moment the velocity of the large ball becomes zero, and we need to find the mass and velocity of the small ball.
Yes
Mass and height
Ah yes, height not velocity, though we need to find the velocity first, then we can use v² = 2gh to find the height h.
08:49
@JohnRennie we can use 1/2 mv^2=mgh
Same thing
Yes :-)
Now I normally like to analyse collisions in the centre of mass frame, but maybe in this case it is simpler to just write down the two equations for momentum and KE.
@JohnRennie yes that’s what I did
So initial momentum is (taking upwards to be positive): p = 6M - 6m
OK so far?
And final momentum is mv, so our first equation is:
6M - 6m = mv
which we can rearrange to:
v = 6(M-m)/m
08:54
Or we can use the eqn Ke=p^2 /2m after writing the second eqn for ke
And likewise using KE we get:
18M + 18m = ¹⁄₂mv²
which is:
v² = 36(M+m)/m
OK so far?
Our first equation is:
v = 6(M-m)/m
and squaring both sides gives:
v² = 36(M-m)²/m²
Yes?
And we can now equate our two expressions for v² to get:
36(M-m)²/m² = 36(M+m)/m
08:57
Yes
What is your m?
m is the unknown mass of the small ball. M is the 0.63 kg mass of the large ball. I'm writing it as M since writing 0.63 is messy. We'll put in M = 0.63 at the end.
OK so far?
Yes. What is your value of m?
Well, we can rewrite our equation as:
36(M-m)/m( (M-m)/m - 1 ) = 0
Yes?
So there are two solutions:
(M-m)/m = 0
(M-m)/m - 1 = 0
Yes?
09:02
Yes
.315 kg. Yes?
The first solution gives m = M, but I guess that isn't allowed since in that case the balls are identical and there wouldn't be a large ball and a small ball - just two equal balls.
And the second gives m = M/2
That will contradict the question itself
So yes I also get m = 0.315
What does the question give as the answer?
09:04
.21 kg
Hmm, so m = M/3 not M/2 ...
What I did is I used the simple formula KE=p^2/2m
@JohnRennie yes
Give me five mins to do something then I'll have a look at it again.
This is taking longer than I thought. I'll ping you when I'm free, but it's likely to be an hour or more.
 
1 hour later…
10:32
@JohnRennie Hi sir , are you there ?
@Abbas Hi :-)
Hi :) I had some questions regarding molecular orbitals.
I hope you are good :)
Go ahead, what are your questions?
Ok !
Q-1 When a taut spring is disturbed then while oscillations , if there is any point which don't move (called node) , then across that point , the two parts of strings are in opposite phase because they will move in different direction . Now for atomic orbital , is there any simple explanation like the one above which can explain what is phase of atomic orbital . I searched and got to know that phase of orbital means the sign of wavefunction .
However isn't there any intuitive explanation of what does phase mean ?
Sorry I meant string and not spring
We need to be a little careful here, because the wavefunction is a mathematical object that describes the system.
The reason I am phrasing it this way is because the wavefunction can never be physically observed i.e. there is no measurement we can make that directly measures the wavefunction.
Any property we measure is always some property derived from the wavefunction e.g. if we measure electron density we are actually measuring the value of |ψ|² not ψ.
OK so far?
10:48
Ok
Also, for reasons that are to do with the maths and a bit obscure, we can multiply the wavefunction by any quantity exp(iθ) and we do not change any of the experimentally observable quantities.
Okay
Now, consider your example of the string. Take the first harmonic with a node in the middle. We could draw this as the first half of the wave upwards, i.e. +ve, and the second half downwards, i.e. -ve.
But we could also draw it as the first half -ve and the second half +ve.
Yeah .
In fact the string oscillates all the time so the two halves change sign twice in each period anyway. So all we can say if the first and last halves have different signs.
Now lets get back to the hydrogen orbitals.
10:54
Okay . I just want to confirm that by saying sign you mean the sign of velocity .
I meant the sign of the displacement, but it would apply to velocity as well.
Okay !
Now, we say the 2p orbital has a node in the middle, and different signs either side of the node. Yes?
Yes .
But this doesn't have any physical meaning because the wave function isn't a physical object. For example we can multiply the wavefunction by exp(i 𝜋/2), which is just i, and then we'd say one side is multiplied by +i and the other by -i.
So now our wavefunctuion isn't even a real number.
10:57
Electrons are electrons and they are not wavefunction themselves. So I am interested in knowing that what happens to electrons and not to wavefunction. I mean what happens to electrons that when they are in opposite phase and when they meet other , then they cancel out themselves
In fact wavefunctions are freuquently complex or imaginary.
Hi @JohnRennie can we go back to our calculation?
@Abbas OK. The thing is that electrons, indeed all articles, are more complicated objects than we might think. It's tempting to think of an electron as a little ball, and then wonder how little balls could interfere with each other.
The electrons are, in a sense, their wavefunctions and they interfere because their wavefunctions can interfere.
When you ask what this means physically this doesn't have an answer, other than to just say "that's how electrons are".
OK?
@cOnnectOrTR12 I found the error, but let me finish Abbas' question first.
@JohnRennie okay! 🥹
Yeah , but why do they cancel out . Is it said because of the mathematics and what we observe ? Means there is no particle like explanation?
11:02
Wavefunctions add just like light waves do, so they interfere just like light waves do. With light the intensity is the wave squared, and for an electron the electron density is the wavefunction squared. So I guess you could say the electron we observe is like the intensity of a wave.
So you cannot explain interference without involving the wave nature of an electron.
Yes?
Okay
I guess this doesn't feel like a good answer ...
... but it's the only answer I know.
I don't know why I hate waves and love particles . It maybe because I haven't learn yet wave mechanics yet .
Waves are the most non-intuitive things that I have ever introduced :(
@cOnnectOrTR12
The thing about "intuition" is that it really means "what I'm used to".
11:08
But thanks for the answer . I had some other questions too . But I think it's better if you answer them after you answer connector . There's a queue for you :)
Waves seem unintuitive only because you are not used to them. As you learn more about them they will come to feel intuitive.
@Abbas Yes, let me answer @cOnnectOrTR12, then I have a question to answer in another room.
@cOnnectOrTR12 the answer m/3 is correct, if it were m/2 the big ball would recoil
Means you will go in another room after answering connection
@cOnnectOrTR12 it was a simple error in the working:
2 hours ago, by John Rennie
And we can now equate our two expressions for v² to get:
36(M-m)²/m² = 36(M+m)/m
This is correct, but then I wrote:
2 hours ago, by John Rennie
36(M-m)/m( (M-m)/m - 1 ) = 0
and that isn't correct.
OK so far?
@JohnRennie but this only takes us to M/2
11:12
Take: 36(M-m)²/m² = 36(M+m)/m
and divide both sides by 36 then multiply both sides by m². This gives:
(M-m)² = (M+m)m
Yes?
Now multiply this out:
M² - 2Mm + m² = Mm + m²
Yes?
Rewrite this as:
M² - 3Mm = 0
which is:
M(M - 3m) = 0
Yes?
11:16
And we know M is not zero, so M - 3m must be zero i.e. M = 3m
m = M/3 = 0.63/3 = 0.21 kg
I need to leave this now as I have another question waiting
Ok. I have another question. But I’ll wait
@JohnRennie thank you! I made an algebra mistake.
@cOnnectOrTR12 I won't have time today as I'm going soon, so we'll have to look at your other question tomorrow.
@JohnRennie ok! Bye
@JohnRennie And mine too please tommorow.
Thanks for letting me know :)
11:21
@Abbas OK. I'll be here the same time tomorrow.
Okay . Good day :)
 
3 hours later…
14:00
Hi there, I need the Biot-Savart law for a current in an infinitely thin cyclic loop but not as common over the centre of the loop but shifted by some distance. Can someone help me?

« first day (2013 days earlier)      last day (906 days later) »