Binary Search in Java

Binary Search Algorithm Binary Search works on sorted arrays and uses divide-and-conquer: Find the middle element. If it matches the target, return the index. If target < middle, search the left half. If target > middle, search the right half. Repeat until found or range is empty. Time complexity: O(log n)Space complexity: O(1) for…

0 Comments

Power Function using recursion in Java

Problem We want to compute: ab=a×a×a…  (b times)a^b = a \times a \times a \dots \; (b \text{ times}) For example: 25=322^5 = 32 34=813^4 = 81 Recursive Idea Base case: If b=0b = 0, return 1 (since a0=1a^0 = 1). Recursive case: ab=a×a(b−1)a^b = a \times a^{(b-1)}. Simple Recursive Code public class PowerRecursion { //…

0 Comments

Greatest Common Divisor (GCD)

What is GCD? The Greatest Common Divisor (GCD) of two numbers is the largest positive integer that divides both numbers without leaving a remainder. Examples: GCD(48, 18) = 6 GCD(56, 98) = 14 Recursive Idea (Euclidean Algorithm) The Euclidean algorithm is the most efficient recursive method for GCD: gcd(a,b)={aif b=0gcd(b,a%b)if b≠0\text{gcd}(a, b) = \begin{cases} a &…

0 Comments

Fibonacci using recursion in Java

What is Fibonacci? The Fibonacci sequence is defined as: F(0)=0,F(1)=1F(0) = 0, \quad F(1) = 1 F(n)=F(n−1)+F(n−2)for n≥2F(n) = F(n-1) + F(n-2) \quad \text{for } n \geq 2 So, the sequence looks like:0, 1, 1, 2, 3, 5, 8, 13, 21 … Recursive Idea Base cases: If n == 0, return 0. If n ==…

0 Comments

Factorial using recursion in Java

What is Factorial? The factorial of a number n (denoted as n!) is the product of all positive integers up to n. n!=n×(n−1)×(n−2)×⋯×1n! = n \times (n-1) \times (n-2) \times \dots \times 1 Examples: 5!=5×4×3×2×1=1205! = 5 \times 4 \times 3 \times 2 \times 1 = 120 0!=10! = 1 (by definition) Recursive Idea…

0 Comments

Sum of Digits in recursion

The "Sum of Digits in recursion" in Java refers to solving the problem of finding the sum of digits of a number using a recursive method. For example, if the number is 1234, the sum of digits is: 1+2+3+4=101 + 2 + 3 + 4 = 10 How recursion works here: Base case: If…

0 Comments

npm vs pnpm vs npx vs yarn

1. npm (Node Package Manager) Comes by default when you install Node.js. Used to install packages, manage versions, and run scripts. 🔹 Example: Install React npm install react npm install react 🔹 Install globally: npm install -g typescript npm install -g typescript 🔹 Run project scripts (from package.json): npm run build npm run build…

0 Comments

Playwright

Playwright is an open-source end-to-end testing and browser automation framework developed by Microsoft. It allows you to automate actions in web browsers like Chromium (Chrome, Edge), WebKit (Safari), and Firefox with a single API. It’s commonly used for: UI Testing – verifying that web applications work as expected. Web Scraping – extracting data from…

0 Comments

Cypress

Cypress is a modern end-to-end (E2E) testing framework for web applications. It’s mainly used to test how your app behaves in a real browser (Chrome, Edge, Firefox, etc.), simulating actual user interactions such as clicking buttons, filling forms, navigating pages, and making assertions about what should appear on the screen. Unlike older tools like…

0 Comments

What is the DOM

🌐 What is the DOM? The DOM is a programming interface for web documents. It represents the HTML or XML document as a tree structure. Each element (like <div>, <p>, <h1>, etc.) becomes a node in this tree. Example: <html> <body> <h1>Hello</h1> <p>World</p> </body> </html> <html> <body> <h1>Hello</h1> <p>World</p> </body> </html> DOM Tree Representation:…

0 Comments

End of content

No more pages to load