Merge K sorted Array

Please tell how root.j (i. e the index for the next element in the array ) is getting updated itself in this code

(where root.i – is index of the array from // which the element is taken)

Hey @Yuvraj_Luhach
If you are writing code yourself.You should know everything about your code.
there is MinHeapNode class
it has 3 property
int element; // The element to be stored
// index of the array from
// which the element is taken
int i; // index of the next element // to be picked from array int j; `
The Heap Space contains all objects are created, but Stack contains any reference to those objects.
changes persist in heap memory

I took some help from gfg for this code.

You mean that if I write (root.j++) somewhere else as well then j in the heap for that node will increment one more time :thinking:

yes root.j++ // increment by 1