Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Comprehensive Guide to Graph Algorithms

1. Graph Basics A graph is a collection of vertices (nodes) connected by edges (links). Graphs can be: Graph Representation: 2. Depth-First Search (DFS) Description: DFS explores as far as possible along each branch before backtracking. It can be implemented using recursion or a stack. Steps: Given Graph: Starting from Node 1: 1 → 2 → 4 → 5 → 3 Time Complexity: Space Complexity: Applications: 3. Breadth-First Search (BFS)…

Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Comprehensive Guide to Searching Algorithms

1. Linear Search Description: Linear Search is the simplest searching algorithm. It sequentially checks each element in the list until the target value is found or the end of the list is reached. Steps: Given: [5, 3, 8, 4, 2], Target: 4 Time Complexity: Space Complexity: 2. Binary Search Description: Binary Search works on sorted arrays. It repeatedly divides the search interval in half until the target value is found.…

Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Comprehensive Guide to Sorting Algorithms

1. Bubble Sort Description: Bubble Sort is a simple comparison-based algorithm where adjacent elements are compared and swapped if they are in the wrong order. This process repeats until the entire array is sorted. Steps: Given: [5, 3, 8, 4, 2] Repeat until the list is sorted: [2, 3, 4, 5, 8] Time Complexity: Space Complexity: 2. Selection Sort Description: Selection Sort selects the smallest element from an unsorted portion…

Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Password Security: Hashing vs Encryption

When storing passwords in a database, hashing is the preferred method over encryption due to its security advantages. Let’s dive into the differences and see examples of both approaches. 1. Hashing the Password Hashing is a one-way function that converts input (password) into a fixed-length string. It is irreversible, meaning you cannot derive the original password from the hash. What is BCrypt? BCrypt stands for Blowfish Crypt. It is a…

Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Approaches for finding pairs with a sum of 5

Finding Pairs with a Given Sum using HashSet in Java 1. Approach Overview Given an array of integers, the goal is to find all unique pairs where the sum equals 5. We will use a HashSet to efficiently track the elements and their complements. 2. HashSet Approach for Unsorted Input Algorithm Java Code Output Time Complexity Space Complexity 3. Optimized Approach for Sorted Input If the array is already sorted,…

Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Normalization and Denormalization

1. Normalization Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. Objectives of Normalization: Forms of Normalization: Example: Before 1NF: StudentID Name Subjects 1 John Doe Math, Science What We Did: After 1NF: StudentID Name Subject 1 John Doe Math 1 John Doe Science Example: Before 2NF: OrderID ProductID ProductName 1 101 Laptop What We Did: After 2NF: Orders Table: OrderID ProductID…

Posted on: March 12, 2025 Posted by: rahulgite Comments: 0

Database Design for Parking

Design a database system for a multi-floor car parking building where: The system should support both a normalized design for maintaining data integrity and a denormalized design for faster access and scalability. 1. Normalized Database Design In a normalized design, we follow 3NF (Third Normal Form) to minimize data redundancy and ensure data integrity. Schema (Normalized Design) Key Queries (Normalized Design) Trade-offs (Normalized Design) ✅ Pros: ❌ Cons: 2. Denormalized…

Posted on: March 8, 2025 Posted by: rahulgite Comments: 0

API Gateway, Service Discovery, Circuit Breaker , and Load Balancer in Microservices

Microservices architecture requires efficient communication and traffic management. API Gateways, Service Discovery, and Load Balancers play key roles in managing traffic, ensuring scalability, and maintaining service availability. 1. API Gateway What is an API Gateway? An API Gateway acts as a single entry point for client requests, managing authentication, routing, load balancing, caching, and monitoring. It simplifies microservices communication by providing a unified interface for multiple services. Features of API…

Posted on: March 8, 2025 Posted by: rahulgite Comments: 0

Ways to Communicate Between Microservices

Microservices communicate using different mechanisms based on their architecture and use cases. Below are the primary communication patterns: 1. Synchronous Communication a. REST APIs (HTTP Communication) Pros: Simple, widely used, language-independent. Cons: Tight coupling, request/response delay, network overhead. b. Feign Client (Declarative REST Communication) Pros: Reduces boilerplate, built-in load balancing (with Spring Cloud LoadBalancer), integrates well with Spring Boot. Cons: Requires service discovery, introduces additional dependencies. c. HTTP Client (Spring…