|
69 | 69 | - [Math.floor](#mathfloor)
|
70 | 70 | - [Math.round](#mathround)
|
71 | 71 | - [JavaScript Integer Max Min](#javascript-integer-max-min)
|
| 72 | +- [Difference between i++ and ++i](#difference-between-i-and-i) |
72 | 73 | - [Bitwise operation in JavaScript](#bitwise-operation-in-javascript)
|
73 | 74 | - [Right Shift x>>y](#right-shift-xy)
|
74 | 75 | - [Left Shift x<<y](#left-shift-xy)
|
@@ -665,32 +666,29 @@ When Browser's are not using Merge sort they most of the time use Quick sort var
|
665 | 666 |
|
666 | 667 | In Quick sort we do not create auxiliary arrays. Therefore, it is good choice for Array to use quick sort. However in merge sort we create 2 auxiliary arrays. Therefore, linked list is a good choice.
|
667 | 668 |
|
668 |
| - |
669 |
| - |
670 | 669 | ## Mathematics & Stats You should know
|
671 | 670 |
|
672 |
| - |
673 | 671 | ### XOR operator
|
674 | 672 |
|
675 | 673 | XOR represents the inequality function, i.e., the output is true if the inputs are not alike otherwise the output is false. A way to remember XOR is "must have one or the other but not both". XOR can also be viewed as addition modulo 2.
|
676 | 674 |
|
677 | 675 | #### Different Numbers can be solved by XOR
|
678 | 676 |
|
679 |
| -Find how many different numbers in the array. |
| 677 | +Find how many different numbers in the array. |
680 | 678 |
|
681 |
| -Input =[3, 5, 6, 3, 3 , 9, 5] |
| 679 | +Input =[3, 5, 6, 3, 3 , 9, 5] |
682 | 680 |
|
683 |
| -answer = 4 |
| 681 | +answer = 4 |
684 | 682 |
|
685 |
| -There are 4 values 3,5, 6,9. |
| 683 | +There are 4 values 3,5, 6,9. |
686 | 684 |
|
687 | 685 | ```js
|
688 |
| -x =0; |
689 |
| -array.forEach(num=> x ^= num); |
| 686 | +x = 0; |
| 687 | +array.forEach((num) => (x ^= num)); |
690 | 688 | return x;
|
691 | 689 | ```
|
692 | 690 |
|
693 |
| -`^=` [XOR assignment operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). |
| 691 | +`^=` [XOR assignment operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). |
694 | 692 |
|
695 | 693 | ### How to initialize array of size n?
|
696 | 694 |
|
@@ -858,20 +856,29 @@ It is 16 digit number.
|
858 | 856 | - `Number.MIN_SAFE_INTEGER` = -9007199254740992
|
859 | 857 | - `Number.MAX_SAFE_INTEGER` = 9007199254740991
|
860 | 858 |
|
| 859 | +## Difference between i++ and ++i |
| 860 | + |
| 861 | +So basically ++i returns the value after it is incremented, while i++ return the value before it is incremented. |
| 862 | + |
| 863 | + |
| 864 | + |
| 865 | + |
| 866 | + |
| 867 | +## Bitwise operation in JavaScript |
861 | 868 |
|
862 |
| -## Bitwise operation in JavaScript |
| 869 | +### Right Shift x>>y |
863 | 870 |
|
864 |
| -### Right Shift x>>y |
| 871 | +Moving bit/s towards the right side in binary number. |
865 | 872 |
|
866 |
| -Moving bit/s towards the right side in binary number. |
| 873 | +`4>>2 = 16` |
867 | 874 |
|
868 | 875 | `x>>y` means `x/2^y` divide x by 2 to the power of y.
|
869 | 876 |
|
870 | 877 | ### Left Shift x<<y
|
871 | 878 |
|
872 |
| -Moving bit/s towards the left side in binary number. |
| 879 | +Moving bit/s towards the left side in binary number. |
873 | 880 |
|
874 |
| -`4<<2 == 0` |
| 881 | +`4<<2 = 0` |
875 | 882 |
|
876 | 883 | `x<<y` means `x*2^y` multiply x by 2 to the power of y.
|
877 | 884 |
|
|
0 commit comments