đ Today's Learning:
đ DSA
- Is Perfect square
- Search in a rotated array
đ Dev
- Redux for state management
đ Some Key Highlights:
DSA
To determine if a given number is a perfect square, the algorithm iteratively narrows down the search range by dividing the number by 2 and checking if the square of the midpoint is equal to the target number. This process continues until the search range is sufficiently small or until the square of the midpoint matches the target number. If a match is found, the algorithm returns true; otherwise, it returns false, indicating that the number is not a perfect square.
For searching in a rotated sorted array, the algorithm follows a binary search approach. It first identifies the pivot point where the array was rotated, dividing the array into two sorted halves. Then, it applies binary search separately on each half, adjusting the search range based on whether the target value falls within the sorted range of the current half. This process continues until the target value is found or until the search range becomes empty, indicating that the target value is not present in the array.
DEV
Redux is a predictable state container for JavaScript apps, commonly used with React. It provides a centralized store to manage the state of an application and facilitates predictable state mutations through actions. The Redux pattern involves defining actions to describe state changes, reducers to specify how those actions modify the state, and a store to hold the application state. When an action is dispatched, it flows through the reducers, which update the state accordingly. Components can subscribe to the store to receive updates when the state changes, ensuring a single source of truth for the application's data and enabling efficient management of complex state logic.
#100daysofcode #1percentplusplus #coding #dsa
Top comments (0)