DEV Community

vishal.codes
vishal.codes

Posted on

Day 30/366

🚀 Today's Learning:

🌟 DSA

  • Given an array of elements, find the count of elements that are binary searchable
  • Selection sort

🌟 Dev

  • Async await

🔍 Some Key Highlights:

DSA

To find the count of elements that are binary searchable in an array, iterate through each element and check if it's greater than all elements to its left and less than all elements to its right. If so, increment the count. Finally, return the count. This process emulates the property of elements in a binary search tree where each node is greater than all nodes in its left subtree and less than all nodes in its right subtree.

Selection sort is a simple sorting algorithm where the array is iterated repeatedly. In each iteration, the smallest element from the unsorted part of the array is selected and swapped with the first unsorted element. This process continues until the entire array is sorted. It's called selection sort because it repeatedly selects the smallest (or largest, depending on the sorting order) element and places it in its final position.

DEV

Async/await is a modern approach in JavaScript for handling asynchronous operations in a more synchronous-like manner. When a function is marked as async, it means it will always return a promise. Within an async function, the await keyword is used to pause the execution of the function until a promise is resolved, allowing other code to run in the meantime. This makes asynchronous code easier to read and write, resembling synchronous code structures. Async/await simplifies asynchronous programming by avoiding the need for chaining promises or using callbacks, leading to cleaner and more maintainable code.

#100daysofcode #1percentplusplus #coding #dsa

Top comments (0)