Posts

Showing posts from June, 2022

Sorting in Java || Java + DSA course || Blog 9

Image
I n this Blog we will be learning about Bubble sort , Selection sort and Insertion sort. We just sort arrays in ascending or descending order. The main thing we are going to from sorting is the logic behind it. Bubble Sort In this sort we push the heaviest element at the end during each loop. It checks itself with its front one to check if it is bigger than it, if it is , it swaps places with that particular number. If not then it doesn't change. Lets start solving: array  = 21, 16, 13, 5, 54 1st Loop : 21> 16 == True .It swaps places with 16.Array now is {16,21,13,5,54} 21>13 == True. It swaps with 13. Array now is {16,13, 21,5,54} 21> 5 == True. It  swaps with 5. Array now is {16,13,5, 21,54} 21>54 == False.Keep it as it is   Now, array is {16,13,5, 21,54} in first Loop Here 54 is already sorted so you don't need to sort it in another loops Lets run 2nd loop   2nd Loop: 16> 13 == True. swaps with 13. {13,16,5, 21,54} 16> 5 == True. swaps with 5. ...

Bit Manipulation || Java + DSA course || Blog 8

Image
W hat is Binary Language / Binary Number System? Why is it used in computational programming? C ircuit flows through our Laptops and mobile phones. When the current is on the higher state, it represents it as 1 while 0 for lower state. This is Binary Number system.It converts numbers, characters, strings to Binary language consisting of only 0s and 1s. A bit (short for binary digit) is the smallest unit of data in a computer . A bit has a single binary value, either 0 or 1. Bit Manipulation is used  to overcome time complexity of algorithms . So it is used for computational programming. We learned left shift and right shift operators in our last blog. For quick recap: You ask user how much bits you want to shift. If user says 1, you shift the binary number left side by 1 space. At the end the space is 0 by default. Exactly opposite for right shift operator For a quick Overview: Get Bit-to know if it is 0 or 1 at a certain index. Set Bit- to change index from 0 to 1. if 1 then kee...