DEV Community

vishal.codes
vishal.codes

Posted on

Day 10/366

🚀 Today's Learning:

🌟 DSA

  • Insertion Sort
  • Quick Sort

🌟 Dev

  • Virtual DOM

🔍 Some Key Highlights:

DSA

Insertion Sort:
In insertion sort, we divide the array into two parts: sorted and unsorted. We start with the second element and compare it with the elements in the sorted part, moving elements to make space for the current element in the correct position. This process continues until the entire array is sorted. The outer loop 'i' runs from the second element to the last, and the inner loop 'j' helps in shifting elements. Average and worst-case time complexity: O(n^2), Best case: O(n) when the array is already sorted.

Quicksort:
Quicksort works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays according to whether they are less than or greater than the pivot. The process is then applied recursively to the sub-arrays. The pivot helps in dividing the array efficiently. The average and worst-case time complexity of quicksort is O(n log n), though in rare cases it can degrade to O(n^2) if the pivot selection is poor. However, it's generally very efficient for large datasets due to its divide-and-conquer approach.

DEV

DOM stands for Document Object Model. The DOM represents an HTML document with a logical tree structure. Each branch of the tree ends in a node, and each node contains objects.

React keeps a lightweight representation of the real DOM in the memory, and that is known as the virtual DOM. When the state of an object changes, virtual DOM changes only that object in the real DOM, rather than updating all the objects.
React updates only those components that have changed, rather than updating all the components at once. This results in much faster web applications.

#100daysofcode #1percentplusplus #coding #dsa

Top comments (0)