<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Santhoshi Mary A</title>
    <description>The latest articles on DEV Community by Santhoshi Mary A (@santhoshi_mary_88917c3fd9).</description>
    <link>https://dev.to/santhoshi_mary_88917c3fd9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3838329%2F5ce3b10f-8233-4929-9939-fa2f7dcee7a9.png</url>
      <title>DEV Community: Santhoshi Mary A</title>
      <link>https://dev.to/santhoshi_mary_88917c3fd9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/santhoshi_mary_88917c3fd9"/>
    <language>en</language>
    <item>
      <title>Idempotency Situation</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Wed, 25 Mar 2026 17:01:37 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/idempotency-situation-3je3</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/idempotency-situation-3je3</guid>
      <description>&lt;p&gt;Understanding Idempotency through a Simple Wallet Transfer System&lt;/p&gt;

&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;In digital payment systems, the same request can sometimes be sent multiple times due to network retries, timeouts, or users clicking the payment button more than once. If the system processes the same request repeatedly, it can lead to serious issues like duplicate deductions or incorrect balances.&lt;/p&gt;

&lt;p&gt;This is where Idempotency becomes important. Idempotency ensures that even if the same operation is executed multiple times, the result remains the same as if it were executed only once.&lt;/p&gt;

&lt;p&gt;To understand this better, I experimented with a simple wallet transfer system using PostgreSQL and simulated duplicate transaction requests.&lt;/p&gt;

&lt;p&gt;Setting up the tables&lt;/p&gt;

&lt;p&gt;I started by creating two tables: one for accounts and another to store transaction records.&lt;/p&gt;

&lt;p&gt;CREATE TABLE accounts (&lt;br&gt;
id SERIAL PRIMARY KEY,&lt;br&gt;
name TEXT NOT NULL,&lt;br&gt;
balance INT NOT NULL CHECK (balance &amp;gt;= 0),&lt;br&gt;
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;CREATE TABLE transactions (&lt;br&gt;
transaction_id TEXT PRIMARY KEY,&lt;br&gt;
sender_id INT,&lt;br&gt;
receiver_id INT,&lt;br&gt;
amount INT,&lt;br&gt;
status TEXT,&lt;br&gt;
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Then I inserted two users:&lt;/p&gt;

&lt;p&gt;INSERT INTO accounts (name, balance)&lt;br&gt;
VALUES&lt;br&gt;
('Alice', 1000),&lt;br&gt;
('Bob', 500);&lt;/p&gt;

&lt;p&gt;Checking the table:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;At this point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice has 1000&lt;/li&gt;
&lt;li&gt;Bob has 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performing a normal transfer&lt;/p&gt;

&lt;p&gt;First, I performed a transfer of 200 from Alice to Bob using a unique transaction ID.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;INSERT INTO transactions (transaction_id, sender_id, receiver_id, amount, status)&lt;br&gt;
VALUES ('txn_001', 1, 2, 200, 'SUCCESS');&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance + 200&lt;br&gt;
WHERE id = 2;&lt;/p&gt;

&lt;p&gt;COMMIT;&lt;/p&gt;

&lt;p&gt;After checking:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 800&lt;/li&gt;
&lt;li&gt;Bob = 700&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the transaction was recorded in the transactions table.&lt;/p&gt;

&lt;p&gt;Simulating duplicate request&lt;/p&gt;

&lt;p&gt;Now I simulated a duplicate request by executing the same transfer again with the same transaction ID.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;INSERT INTO transactions (transaction_id, sender_id, receiver_id, amount, status)&lt;br&gt;
VALUES ('txn_001', 1, 2, 200, 'SUCCESS');&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance + 200&lt;br&gt;
WHERE id = 2;&lt;/p&gt;

&lt;p&gt;COMMIT;&lt;/p&gt;

&lt;p&gt;This resulted in an error because the transaction_id already exists.&lt;/p&gt;

&lt;p&gt;Observing the result&lt;/p&gt;

&lt;p&gt;After the error, I ran:&lt;/p&gt;

&lt;p&gt;ROLLBACK;&lt;/p&gt;

&lt;p&gt;Then checked the balances:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;The balances remained:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 800&lt;/li&gt;
&lt;li&gt;Bob = 700&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The duplicate transaction was not applied.&lt;/p&gt;

&lt;p&gt;Why this works&lt;/p&gt;

&lt;p&gt;The transactions table uses a PRIMARY KEY on transaction_id.&lt;/p&gt;

&lt;p&gt;This ensures that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;each transaction is unique&lt;/li&gt;
&lt;li&gt;duplicate requests are rejected&lt;/li&gt;
&lt;li&gt;repeated execution does not change the result&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because the insert fails, the entire transaction is rolled back, preventing duplicate updates.&lt;/p&gt;

&lt;p&gt;Improving with conflict handling&lt;/p&gt;

&lt;p&gt;Instead of throwing an error, we can also handle duplicates gracefully using:&lt;/p&gt;

&lt;p&gt;INSERT INTO transactions (transaction_id, sender_id, receiver_id, amount, status)&lt;br&gt;
VALUES ('txn_002', 1, 2, 200, 'SUCCESS')&lt;br&gt;
ON CONFLICT (transaction_id) DO NOTHING;&lt;/p&gt;

&lt;p&gt;This prevents duplicate inserts without crashing the system.&lt;/p&gt;

&lt;p&gt;What I learned&lt;/p&gt;

&lt;p&gt;From this experiment, I understood that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repeating the same SQL operations can cause duplicate updates&lt;/li&gt;
&lt;li&gt;The database does not automatically prevent duplicate business actions&lt;/li&gt;
&lt;li&gt;Idempotency must be implemented explicitly&lt;/li&gt;
&lt;li&gt;Using a transaction table with a unique transaction ID prevents duplicate processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;This experiment showed how duplicate requests can affect a wallet system and how idempotency helps prevent such issues.&lt;/p&gt;

&lt;p&gt;By introducing a transaction table with a unique transaction ID, we can ensure that even if the same request is repeated, it is processed only once.&lt;/p&gt;

&lt;p&gt;In simple terms, idempotency ensures that performing the same action multiple times does not change the result after the first successful execution.&lt;/p&gt;

&lt;p&gt;This is a critical concept in building reliable financial systems where duplicate processing can lead to serious problems.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>postgres</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>Durability</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Wed, 25 Mar 2026 16:33:53 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/durability-1168</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/durability-1168</guid>
      <description>&lt;p&gt;Understanding Durability through a Simple Wallet Transfer System&lt;/p&gt;

&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;While using payment apps, we expect that once a transaction is completed, it should remain saved permanently. Even if the system crashes or restarts, the updated balance should not disappear.&lt;/p&gt;

&lt;p&gt;This behavior is ensured by Durability, one of the ACID properties of a database. Durability guarantees that once a transaction is committed, its changes are permanently stored and will not be lost.&lt;/p&gt;

&lt;p&gt;To understand this better, I experimented with a simple wallet transfer system using PostgreSQL and observed how committed data behaves after reconnecting to the database.&lt;/p&gt;

&lt;p&gt;Setting up the table&lt;/p&gt;

&lt;p&gt;I started by creating a basic table to store account details.&lt;/p&gt;

&lt;p&gt;CREATE TABLE accounts (&lt;br&gt;
id SERIAL PRIMARY KEY,&lt;br&gt;
name TEXT NOT NULL,&lt;br&gt;
balance INT NOT NULL CHECK (balance &amp;gt;= 0),&lt;br&gt;
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Then I inserted two users:&lt;/p&gt;

&lt;p&gt;INSERT INTO accounts (name, balance)&lt;br&gt;
VALUES&lt;br&gt;
('Alice', 1000),&lt;br&gt;
('Bob', 500);&lt;/p&gt;

&lt;p&gt;Checking the table:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;At this point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice has 1000&lt;/li&gt;
&lt;li&gt;Bob has 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performing a successful transfer&lt;/p&gt;

&lt;p&gt;First, I performed a transfer of 200 from Alice to Bob inside a transaction.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200,&lt;br&gt;
last_updated = CURRENT_TIMESTAMP&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance + 200,&lt;br&gt;
last_updated = CURRENT_TIMESTAMP&lt;br&gt;
WHERE id = 2;&lt;/p&gt;

&lt;p&gt;COMMIT;&lt;/p&gt;

&lt;p&gt;After running this, I checked the table again:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 800&lt;/li&gt;
&lt;li&gt;Bob = 700&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This confirms that the transaction was successfully committed.&lt;/p&gt;

&lt;p&gt;Simulating a restart or reconnect&lt;/p&gt;

&lt;p&gt;To test durability, I disconnected from the database and reconnected again (or restarted the session).&lt;/p&gt;

&lt;p&gt;After reconnecting, I ran:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;The balances were still:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 800&lt;/li&gt;
&lt;li&gt;Bob = 700&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This shows that the committed changes were permanently saved and not lost after reconnecting.&lt;/p&gt;

&lt;p&gt;What happens if failure occurs before commit&lt;/p&gt;

&lt;p&gt;Next, I considered what happens if the system fails before the transaction is committed.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance + 200&lt;br&gt;
WHERE id = 2;&lt;/p&gt;

&lt;p&gt;If the system crashes at this point before COMMIT, the transaction is incomplete.&lt;/p&gt;

&lt;p&gt;After reconnecting, the balances will remain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 1000&lt;/li&gt;
&lt;li&gt;Bob = 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means uncommitted changes are not saved.&lt;/p&gt;

&lt;p&gt;What happens if failure occurs after commit&lt;/p&gt;

&lt;p&gt;Now consider a failure happening immediately after COMMIT.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance + 200&lt;br&gt;
WHERE id = 2;&lt;/p&gt;

&lt;p&gt;COMMIT;&lt;/p&gt;

&lt;p&gt;If the system crashes after this, once we reconnect and check:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;The balances will still be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 800&lt;/li&gt;
&lt;li&gt;Bob = 700&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This proves that committed data is not lost.&lt;/p&gt;

&lt;p&gt;How PostgreSQL ensures durability&lt;/p&gt;

&lt;p&gt;PostgreSQL ensures durability using a mechanism called Write-Ahead Logging (WAL).&lt;/p&gt;

&lt;p&gt;Before permanently updating the actual data, PostgreSQL first records the changes in a log. Once the transaction is committed, this log ensures that even if the system crashes, the database can recover and restore the committed data.&lt;/p&gt;

&lt;p&gt;Because of this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;committed transactions are always preserved&lt;/li&gt;
&lt;li&gt;uncommitted transactions are discarded&lt;/li&gt;
&lt;li&gt;the database can recover correctly after failure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I learned&lt;/p&gt;

&lt;p&gt;From this experiment, I understood that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once a transaction is committed, the data is permanently saved&lt;/li&gt;
&lt;li&gt;Reconnecting or restarting does not remove committed changes&lt;/li&gt;
&lt;li&gt;If failure occurs before commit, changes are not saved&lt;/li&gt;
&lt;li&gt;Durability applies only to committed transactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;This experiment helped me understand how durability works in a database system.&lt;/p&gt;

&lt;p&gt;Durability ensures that once a transaction is committed, its changes remain saved even after crashes or restarts. This is very important in financial systems like wallet applications, where losing committed transactions could lead to serious issues such as money loss or incorrect balances.&lt;/p&gt;

&lt;p&gt;In simple terms, durability guarantees that once a payment is successful, it will always remain successful.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>postgres</category>
      <category>sql</category>
    </item>
    <item>
      <title>Consistency</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Wed, 25 Mar 2026 16:08:03 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/consistency-58e</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/consistency-58e</guid>
      <description>&lt;p&gt;Understanding Consistency through a Simple Wallet System&lt;/p&gt;

&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;When we use payment apps, we always expect our balance to be correct. We never imagine seeing a negative balance or invalid data in our account.&lt;/p&gt;

&lt;p&gt;Behind the scenes, the database ensures that all data always follows certain rules. This is called Consistency in ACID properties.&lt;/p&gt;

&lt;p&gt;Consistency ensures that the database always remains in a valid state. If any operation tries to break the rules, the database rejects it.&lt;/p&gt;

&lt;p&gt;To understand this better, I experimented with a simple wallet system using PostgreSQL and tried performing operations that violate these rules.&lt;/p&gt;

&lt;p&gt;Setting up the table&lt;/p&gt;

&lt;p&gt;I started by creating a basic table to store account details.&lt;/p&gt;

&lt;p&gt;CREATE TABLE accounts (&lt;br&gt;
id SERIAL PRIMARY KEY,&lt;br&gt;
name TEXT NOT NULL,&lt;br&gt;
balance INT NOT NULL CHECK (balance &amp;gt;= 0),&lt;br&gt;
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Then I inserted two users:&lt;/p&gt;

&lt;p&gt;INSERT INTO accounts (name, balance)&lt;br&gt;
VALUES&lt;br&gt;
('Alice', 1000),&lt;br&gt;
('Bob', 500);&lt;/p&gt;

&lt;p&gt;Checking the table:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;At this point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice has 1000&lt;/li&gt;
&lt;li&gt;Bob has 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important rule here is:&lt;/p&gt;

&lt;p&gt;CHECK (balance &amp;gt;= 0)&lt;/p&gt;

&lt;p&gt;This ensures that no account can have a negative balance.&lt;/p&gt;

&lt;p&gt;Trying a valid update&lt;/p&gt;

&lt;p&gt;First, I performed a normal valid operation.&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;Checking the table:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice has 800&lt;/li&gt;
&lt;li&gt;Bob has 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This works because the balance is still valid (not negative).&lt;/p&gt;

&lt;p&gt;Resetting the data&lt;/p&gt;

&lt;p&gt;Before testing invalid cases, I reset the balances.&lt;/p&gt;

&lt;p&gt;UPDATE accounts SET balance = 1000 WHERE id = 1;&lt;br&gt;
UPDATE accounts SET balance = 500 WHERE id = 2;&lt;/p&gt;

&lt;p&gt;Trying to break consistency (negative balance)&lt;/p&gt;

&lt;p&gt;Now I tried to directly assign a negative balance.&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = -100&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;This resulted in an error because the database does not allow values that violate the constraint.&lt;/p&gt;

&lt;p&gt;After checking the table:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice still has 1000&lt;/li&gt;
&lt;li&gt;Bob still has 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The update was rejected completely.&lt;/p&gt;

&lt;p&gt;Trying to deduct more than available balance&lt;/p&gt;

&lt;p&gt;Next, I tried to deduct more money than Alice actually has.&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 1500&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;This again resulted in an error.&lt;/p&gt;

&lt;p&gt;Checking the table:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 1000&lt;/li&gt;
&lt;li&gt;Bob = 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The database did not allow the balance to go negative.&lt;/p&gt;

&lt;p&gt;Trying the same inside a transaction&lt;/p&gt;

&lt;p&gt;I also tested the same scenario inside a transaction.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 1500&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;This failed immediately.&lt;/p&gt;

&lt;p&gt;Then I ran:&lt;/p&gt;

&lt;p&gt;ROLLBACK;&lt;/p&gt;

&lt;p&gt;Checking the table again:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 1000&lt;/li&gt;
&lt;li&gt;Bob = 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even inside a transaction, the constraint prevented invalid data.&lt;/p&gt;

&lt;p&gt;What I observed&lt;/p&gt;

&lt;p&gt;From these tests, I understood that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The database enforces rules defined in the schema&lt;/li&gt;
&lt;li&gt;Invalid updates are rejected immediately&lt;/li&gt;
&lt;li&gt;The balance never becomes negative&lt;/li&gt;
&lt;li&gt;The database always maintains a valid state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, I also noticed that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The database only checks constraints like balance &amp;gt;= 0&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It does not automatically handle business rules like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;validating transfer amount&lt;/li&gt;
&lt;li&gt;ensuring sender and receiver exist&lt;/li&gt;
&lt;li&gt;preventing incorrect transfers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;These must be handled using application logic or transactions.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;This experiment helped me understand how consistency is maintained in a database system.&lt;/p&gt;

&lt;p&gt;Consistency ensures that the database always remains in a valid state by enforcing rules like constraints. Even if an invalid operation is attempted, the database prevents it from being applied.&lt;/p&gt;

&lt;p&gt;In real-world systems like digital wallets, this plays a crucial role in preventing incorrect balances and maintaining data integrity.&lt;/p&gt;

&lt;p&gt;While constraints ensure data validity, additional logic is required to enforce complete business correctness.&lt;/p&gt;

&lt;p&gt;Consistency, along with other ACID properties, forms the foundation for building reliable financial systems.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>postgres</category>
      <category>sql</category>
    </item>
    <item>
      <title>Atomicity - Design a Reliable Wallet Transfer System with ACID Guarantees</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Wed, 25 Mar 2026 14:17:20 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/atomicity-design-a-reliable-wallet-transfer-system-with-acid-guarantees-5gm7</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/atomicity-design-a-reliable-wallet-transfer-system-with-acid-guarantees-5gm7</guid>
      <description>&lt;p&gt;Understanding Atomicity through a Simple Wallet Transfer System&lt;/p&gt;

&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;While using payment apps, we usually don’t think about what happens behind the scenes. When we send money, we simply expect that if it leaves our account, it should reach the other person. There should never be a situation where money is deducted but not received.&lt;/p&gt;

&lt;p&gt;This behavior is handled by the database using something called Atomicity. It ensures that a transaction either completes fully or does not happen at all.&lt;/p&gt;

&lt;p&gt;To understand this better, I tried building a simple wallet transfer system using PostgreSQL and tested different cases to see how the database behaves.&lt;/p&gt;

&lt;p&gt;Setting up the table&lt;/p&gt;

&lt;p&gt;I started by creating a basic table to store account details.&lt;/p&gt;

&lt;p&gt;CREATE TABLE accounts (&lt;br&gt;
    id SERIAL PRIMARY KEY,&lt;br&gt;
    name TEXT NOT NULL,&lt;br&gt;
    balance INT NOT NULL CHECK (balance &amp;gt;= 0),&lt;br&gt;
    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Then I inserted two users:&lt;/p&gt;

&lt;p&gt;INSERT INTO accounts (name, balance)&lt;br&gt;
VALUES&lt;br&gt;
('Alice', 1000),&lt;br&gt;
('Bob', 500);&lt;/p&gt;

&lt;p&gt;Checking the table:&lt;/p&gt;

&lt;p&gt;SELECT * FROM accounts ORDER BY id;&lt;/p&gt;

&lt;p&gt;At this point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice has 1000&lt;/li&gt;
&lt;li&gt;Bob has 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Trying a normal transfer&lt;/p&gt;

&lt;p&gt;First, I wanted to see how a proper transfer works.&lt;/p&gt;

&lt;p&gt;I made Alice send 200 to Bob inside a transaction.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200,&lt;br&gt;
    last_updated = CURRENT_TIMESTAMP&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance + 200,&lt;br&gt;
    last_updated = CURRENT_TIMESTAMP&lt;br&gt;
WHERE id = 2;&lt;/p&gt;

&lt;p&gt;COMMIT;&lt;/p&gt;

&lt;p&gt;After running this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice’s balance became 800&lt;/li&gt;
&lt;li&gt;Bob’s balance became 700&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly what we expect. Both operations happened together.&lt;/p&gt;

&lt;p&gt;Resetting the data&lt;/p&gt;

&lt;p&gt;Before testing failures, I reset the balances.&lt;/p&gt;

&lt;p&gt;UPDATE accounts SET balance = 1000 WHERE id = 1;&lt;br&gt;
UPDATE accounts SET balance = 500 WHERE id = 2;&lt;/p&gt;

&lt;p&gt;What if something breaks in the middle&lt;/p&gt;

&lt;p&gt;Now comes the interesting part.&lt;/p&gt;

&lt;p&gt;I started a transaction, deducted money from Alice, but intentionally made a mistake in the next query.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 200&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balanc = balance + 200&lt;br&gt;
WHERE id = 2;&lt;/p&gt;

&lt;p&gt;This gave an error because of the wrong column name.&lt;/p&gt;

&lt;p&gt;Then I ran:&lt;/p&gt;

&lt;p&gt;ROLLBACK;&lt;/p&gt;

&lt;p&gt;After checking the table, I noticed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice still had 1000&lt;/li&gt;
&lt;li&gt;Bob still had 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even though the first update ran, it was not saved. The database completely ignored it because the transaction failed later.&lt;/p&gt;

&lt;p&gt;Another failure after a valid query&lt;/p&gt;

&lt;p&gt;Next, I tried a different approach.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 300&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;SELECT * FROM non_existing_table;&lt;/p&gt;

&lt;p&gt;The second query failed because the table does not exist.&lt;/p&gt;

&lt;p&gt;After rollback, the balances were still:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alice = 1000&lt;/li&gt;
&lt;li&gt;Bob = 500&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Again, nothing changed.&lt;/p&gt;

&lt;p&gt;Trying to break it using constraints&lt;/p&gt;

&lt;p&gt;I then tried to transfer more money than Alice actually had.&lt;/p&gt;

&lt;p&gt;BEGIN;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance - 1500&lt;br&gt;
WHERE id = 1;&lt;/p&gt;

&lt;p&gt;UPDATE accounts&lt;br&gt;
SET balance = balance + 1500&lt;br&gt;
WHERE id = 2;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


This failed because the balance cannot go below zero.

After rollback:

* Alice = 1000
* Bob = 500

No changes were made.



 What happens without a transaction

To really understand why transactions matter, I tried the same thing without using BEGIN and COMMIT.


UPDATE accounts
SET balance = balance - 200
WHERE id = 1;

UPDATE accounts
SET balanc = balance + 200
WHERE id = 2;


The first query succeeded, but the second failed.

After checking:

* Alice had 800
* Bob still had 500

This is a partial update. Money was deducted but not credited.


 What I learned

From all these tests, a few things became very clear:

* A transaction ensures that all steps are treated as a single unit
* If any step fails, the entire transaction is rolled back
* The database does not allow partial updates inside a transaction
* Without transactions, inconsistent data can occur very easily

This is why atomicity is critical for systems that handle money.



 Conclusion

This simple experiment helped me understand how databases protect data integrity during operations like money transfers.

Atomicity ensures that either everything happens or nothing happens. In real-world applications, this is what prevents issues like money loss or incorrect balances.

Even though the example was simple, the concept is very powerful and is used in all reliable financial systems.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>backend</category>
      <category>database</category>
      <category>postgres</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>how DNS resolver is happening.</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Mon, 23 Mar 2026 18:36:35 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/how-dns-resolver-is-happening-32c2</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/how-dns-resolver-is-happening-32c2</guid>
      <description>&lt;p&gt;When you enter a webpage such as:&lt;/p&gt;

&lt;p&gt;Google.com&lt;/p&gt;

&lt;p&gt;This name is not understood by your computer.&lt;/p&gt;

&lt;p&gt;Only IP addresses such as these are understood by computers:&lt;/p&gt;

&lt;p&gt;142.250.190.78&lt;/p&gt;

&lt;p&gt;How, then, does your system translate a website name into an IP address?&lt;/p&gt;

&lt;p&gt;DNS resolution is the term for that procedure.&lt;/p&gt;

&lt;p&gt;Let's take a step-by-step look at it in very basic terms&lt;br&gt;
DNS: What is it?&lt;/p&gt;

&lt;p&gt;DNS is an acronym for Domain Name System.&lt;/p&gt;

&lt;p&gt;It functions similarly to an online phone book.&lt;/p&gt;

&lt;p&gt;👉 You look for a name&lt;br&gt;
👉 DNS provides the IP address (phone number).&lt;/p&gt;

&lt;p&gt;For instance:&lt;/p&gt;

&lt;p&gt;You enter &lt;a href="http://www.google.com" rel="noopener noreferrer"&gt;www.google.com&lt;/a&gt;.&lt;br&gt;
DNS provides the Google servers' IP address.&lt;br&gt;
 Step-by-Step: DNS Resolution Process&lt;br&gt;
 Step 1: Enter a Website&lt;/p&gt;

&lt;p&gt;For instance:&lt;/p&gt;

&lt;p&gt;Amazon.com&lt;/p&gt;

&lt;p&gt;Amazon's IP address is now required by your browser.&lt;/p&gt;

&lt;p&gt;Step 2: Check the Browser Cache&lt;/p&gt;

&lt;p&gt;Your browser first verifies:&lt;/p&gt;

&lt;p&gt;Am I familiar with this IP already?&lt;/p&gt;

&lt;p&gt;It might already be stored in memory if you visited recently.&lt;/p&gt;

&lt;p&gt;If discovered -&amp;gt;Done &lt;br&gt;
If not, proceed to the following step.&lt;/p&gt;

&lt;p&gt; Operating System Cache in Step Three&lt;/p&gt;

&lt;p&gt;Your computer’s OS also keeps a small DNS cache.&lt;/p&gt;

&lt;p&gt;If IP is located -&amp;gt;Completed &lt;br&gt;
If not, proceed.&lt;br&gt;
Step 4: Send the DNS Resolver a Request&lt;/p&gt;

&lt;p&gt;Your request is now sent to a DNS resolver.&lt;/p&gt;

&lt;p&gt;Typically, this is supplied by:&lt;/p&gt;

&lt;p&gt;Your Internet service provider, or ISP&lt;br&gt;
or a public DNS such as:&lt;br&gt;
Google Public DNS&lt;br&gt;
Cloudflare (1.1.1.1)&lt;/p&gt;

&lt;p&gt;The role of the resolver:&lt;/p&gt;

&lt;p&gt;Determine this domain's correct IP address.&lt;/p&gt;

&lt;p&gt;Resolver Requests Root DNS Server in Step Five&lt;/p&gt;

&lt;p&gt;A Root DNS Server is asked by the resolver:&lt;/p&gt;

&lt;p&gt;Where can I locate domains ending in.com?&lt;/p&gt;

&lt;p&gt;The root server responds:&lt;/p&gt;

&lt;p&gt;Ask the TLD server for.com.&lt;/p&gt;

&lt;p&gt;Step 6: Request TLD Server&lt;/p&gt;

&lt;p&gt;Top Level Domain, or TLD&lt;br&gt;
For instance,.com,.org, and.net&lt;/p&gt;

&lt;p&gt;The resolver queries:&lt;/p&gt;

&lt;p&gt;Where is Amazon.com located?&lt;/p&gt;

&lt;p&gt;The TLD server responds:&lt;/p&gt;

&lt;p&gt;Ask the reputable name server at Amazon.&lt;br&gt;
Step 7: Consult the Authoritative Name Server&lt;/p&gt;

&lt;p&gt;The resolver now queries:&lt;/p&gt;

&lt;p&gt;What is &lt;a href="http://www.amazon.com's" rel="noopener noreferrer"&gt;www.amazon.com's&lt;/a&gt; IP address?&lt;/p&gt;

&lt;p&gt;The authoritative server responds:&lt;/p&gt;

&lt;p&gt;54.xx.xx&lt;/p&gt;

&lt;p&gt;Step 8: You Receive Your IP Address Back&lt;/p&gt;

&lt;p&gt;The resolver&lt;/p&gt;

&lt;p&gt;returns IP to your computer.&lt;br&gt;
stores it in the cache for later use.&lt;/p&gt;

&lt;p&gt;Your browser is now aware of the connection location.&lt;/p&gt;

&lt;p&gt; Step 9: Website Loads&lt;/p&gt;

&lt;p&gt;Your current browser:&lt;/p&gt;

&lt;p&gt;uses IP to connect to the server.&lt;br&gt;
transmits an HTTP request&lt;br&gt;
The website loads&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How a request originates from cllient and reaches the server</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Mon, 23 Mar 2026 17:38:54 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/how-a-request-originates-from-cllient-and-reaches-the-server-37lp</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/how-a-request-originates-from-cllient-and-reaches-the-server-37lp</guid>
      <description>&lt;p&gt;A precise series of events is triggered in milliseconds each time you hit Enter on a URL. This is the entire journey, reduced to what really counts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Parsing URLs&lt;br&gt;
The browser starts determining where to send the request after breaking down &lt;a href="https://www.example.com/products" rel="noopener noreferrer"&gt;https://www.example.com/products&lt;/a&gt; into three parts: protocol (https), domain (&lt;a href="http://www.example.com" rel="noopener noreferrer"&gt;www.example.com&lt;/a&gt;), and path (/products).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DNS Resolution&lt;br&gt;
Instead of a domain name, the browser requires an IP address. After checking its cache and the OS cache, it queries a DNS Recursive Resolver, which returns the IP after tracing the response up through Root, TLD, and Authoritative name servers.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Browser -&amp;gt; Resolver -&amp;gt; Root NS -&amp;gt; TLD NS -&amp;gt; Authoritative NS&lt;br&gt;
                                                 |&lt;br&gt;
                             93.184.216.34 &amp;lt;-----+&lt;br&gt;
3.TLS Handshake (HTTPS only)&lt;br&gt;
For secure connections, both sides negotiate encryption. The server presents its SSL certificate, they agree on a cipher, and a shared session key is derived. All further communication is encrypted.&lt;/p&gt;

&lt;p&gt;4.HTTP Request and Methods&lt;br&gt;
The browser sends the actual request:&lt;br&gt;
The HTTP method tells the server what action to perform on the resource.&lt;br&gt;
HTTP Methods Explained&lt;br&gt;
Method&lt;/p&gt;

&lt;p&gt;GET                  Retrieve a resource&lt;/p&gt;

&lt;p&gt;POST                 Create a new resource&lt;/p&gt;

&lt;p&gt;PUT                  Replace a resource entirely&lt;/p&gt;

&lt;p&gt;PATCH                Partially update a resource&lt;/p&gt;

&lt;p&gt;DELETE               Remove a resource&lt;br&gt;
5.Idempotency: An Essential Idea in API Design&lt;br&gt;
Idempotency is the ability of the server to produce the same result when the same request is made once or several times. In distributed systems, this is crucial because servers need to behave consistently, networks fail, and clients retry.&lt;/p&gt;

&lt;p&gt;If making a request ten times has the same impact on the server state as making it just once, then it is idempotent.&lt;br&gt;
Idempotency by Method&lt;br&gt;
Idempotent Methods:&lt;br&gt;
GET&lt;br&gt;
PUT&lt;br&gt;
DELETE&lt;br&gt;
Non-Idempotent Methods:&lt;br&gt;
POST (usually)&lt;br&gt;
PATCH (depends)&lt;/p&gt;

&lt;p&gt;6.The request is processed by the server&lt;/p&gt;

&lt;p&gt;The server&lt;/p&gt;

&lt;p&gt;gets the request&lt;br&gt;
Verifies authenticity&lt;br&gt;
executes backend logic&lt;br&gt;
database queries when necessary&lt;br&gt;
gets ready to respond&lt;br&gt;
7.Server Sends HTTP Response&lt;br&gt;
With:&lt;/p&gt;

&lt;p&gt;Status code&lt;br&gt;
Headers&lt;br&gt;
Body (HTML/JSON/etc.)&lt;br&gt;
8.The response is rendered by the browser.&lt;/p&gt;

&lt;p&gt;The web browser&lt;/p&gt;

&lt;p&gt;Parses HTML&lt;br&gt;
uses CSS&lt;br&gt;
JavaScript is executed&lt;br&gt;
makes more API requests&lt;br&gt;
shows the user the page&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>networking</category>
      <category>webdev</category>
    </item>
    <item>
      <title>IP address and Subnet</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Mon, 23 Mar 2026 16:22:30 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/ip-address-and-subnet-3ge</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/ip-address-and-subnet-3ge</guid>
      <description>&lt;p&gt;What does an IP address mean?&lt;br&gt;
Every device that is connected to a computer network has a unique number called an IP address (Internet Protocol address). An IP address is like a home address in that it tells the internet exactly where to send data, just like a postal address tells the delivery person exactly where to drop off your package.&lt;br&gt;
There are two versions that people use today:&lt;/p&gt;

&lt;p&gt;IPv4 is the older and most common format. Written as four groups of numbers with dots between them, like 192.168.1.1. There are about 4.3 billion possible addresses because each number can be between 0 and 255.&lt;br&gt;
IPv6 is the newer format that was made to fix the problem of IPv4 running out. Written in hexadecimal, like this: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. It can handle an almost infinite number of addresses.&lt;br&gt;
Public IP Address vs. Private IP Address&lt;br&gt;
IP Address&lt;br&gt;
Given by the Internet Service Provider (ISP)&lt;br&gt;
Used online&lt;br&gt;
One of a kind around the world&lt;br&gt;
IP for private use&lt;br&gt;
Used in networks that are close by&lt;br&gt;
Not directly reachable from the web&lt;/p&gt;

&lt;p&gt;Private IP ranges:&lt;/p&gt;

&lt;p&gt;10.0.0.0 to 10.255.255.255&lt;br&gt;
172.16.0.0 to 172.31.255.255&lt;br&gt;
192.168.0.0 to 192.168.255.255&lt;br&gt;
The Parts of an IPv4 Address&lt;br&gt;
There are 32 bits in an IPv4 address, and they are grouped into four octets, each with 8 bits.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;  168.   1.   10
11000000 10101000 00000001 00001010
There are two parts to every IP address:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Network part: This tells you which network the device is on.&lt;br&gt;
Host part: Identifies the exact device on that network&lt;br&gt;
What is a Subnet?&lt;/p&gt;

&lt;p&gt;A Subnet (Subnetwork) is a smaller division of a large network.&lt;/p&gt;

&lt;p&gt;Instead of having one large network with thousands of devices, we divide it into smaller networks&lt;/p&gt;

&lt;p&gt;The Mask for the Subnet&lt;br&gt;
A subnet mask is a 32-bit number that tells devices which part of an IP address belongs to the network and which part belongs to the host.&lt;br&gt;
For example:&lt;br&gt;
192.168.1.10 is the IP address.&lt;br&gt;
255.255.255.0 is the subnet mask.&lt;br&gt;
In binary:&lt;br&gt;
IP:  11000000.10101000.00000001.00001010&lt;br&gt;
Mask:11111111.11111111.11111111.00000000&lt;br&gt;
The 1s in the mask are the network part.&lt;br&gt;
The mask's 0s stand for the host part.&lt;br&gt;
The first three octets (192.168.1) tell you which network you're on, and the last octet (.10) tells you which host you're on.&lt;/p&gt;

&lt;p&gt;CIDR Notation&lt;br&gt;
CIDR (Classless Inter-Domain Routing) notation is a way to write the subnet mask in a short way by counting the number of 1-bits.&lt;br&gt;
192.168.1.0/24 → 255.255.255.0 (the mask has 24 ones)&lt;br&gt;
10.0.0.0/8 → 255.0.0.0 (the mask has 8 ones in it)&lt;br&gt;
172.16.0.0/16 → 255.255.0.0 (the mask has 16 ones in it)&lt;/p&gt;

&lt;p&gt;Note: Two addresses in every subnet are always reserved — one for the network address and one for the broadcast address — which is why usable hosts = total addresses minus 2.&lt;/p&gt;

&lt;p&gt;Network Address — First address of a subnet (not assignable to a host)&lt;br&gt;
Broadcast Address — Last address of a subnet (sends data to all hosts in the subnet)&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>learning</category>
      <category>networking</category>
    </item>
    <item>
      <title>Sort a Linked List using Merge Sort</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Sun, 22 Mar 2026 14:05:42 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/sort-a-linked-list-using-merge-sort-2joh</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/sort-a-linked-list-using-merge-sort-2joh</guid>
      <description>&lt;p&gt;Problem Statement&lt;/p&gt;

&lt;p&gt;Given the head of a singly linked list, sort the linked list using Merge Sort.&lt;/p&gt;

&lt;p&gt;Constraints:&lt;/p&gt;

&lt;p&gt;1 ≤ number of nodes ≤ 10⁵&lt;br&gt;
0 ≤ node.data ≤ 10⁶&lt;br&gt;
Example 1&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;40 -&amp;gt; 20 -&amp;gt; 60 -&amp;gt; 10 -&amp;gt; 50 -&amp;gt; 30&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;10 -&amp;gt; 20 -&amp;gt; 30 -&amp;gt; 40 -&amp;gt; 50 -&amp;gt; 60&lt;br&gt;
Example 2&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;9 -&amp;gt; 5 -&amp;gt; 2 -&amp;gt; 8&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 5 -&amp;gt; 8 -&amp;gt; 9&lt;br&gt;
Why Merge Sort for Linked List?&lt;/p&gt;

&lt;p&gt;Merge Sort is preferred for linked lists because:&lt;/p&gt;

&lt;p&gt;It does not require random access.&lt;br&gt;
It works efficiently with pointers.&lt;br&gt;
Time Complexity is O(n log n).&lt;br&gt;
Space Complexity is O(1) (excluding recursion stack).&lt;/p&gt;

&lt;p&gt;Unlike arrays, quick sort is not efficient for linked lists due to lack of indexing.&lt;/p&gt;

&lt;p&gt;Approach Overview&lt;/p&gt;

&lt;p&gt;Merge Sort works in three main steps:&lt;/p&gt;

&lt;p&gt;Find the middle of the linked list.&lt;br&gt;
Divide the list into two halves.&lt;br&gt;
Recursively sort both halves.&lt;br&gt;
Merge the two sorted halves.&lt;br&gt;
Step 1 – Finding the Middle&lt;/p&gt;

&lt;p&gt;We use the slow and fast pointer method.&lt;/p&gt;

&lt;p&gt;Slow moves 1 step.&lt;br&gt;
Fast moves 2 steps.&lt;br&gt;
When fast reaches end, slow will be at middle.&lt;br&gt;
Step 2 – Divide the List&lt;/p&gt;

&lt;p&gt;After finding middle:&lt;/p&gt;

&lt;p&gt;Break the list into two halves.&lt;br&gt;
Call mergeSort recursively on both halves.&lt;br&gt;
Step 3 – Merge Two Sorted Lists&lt;/p&gt;

&lt;p&gt;Compare nodes from both lists.&lt;br&gt;
Attach the smaller node to result.&lt;br&gt;
Repeat until one list finishes.&lt;/p&gt;

&lt;p&gt;Python Implementation&lt;br&gt;
class Solution:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def mergeSort(self, head):
    # Base case
    if not head or not head.next:
        return head

    # Step 1: Find middle
    middle = self.getMiddle(head)
    next_to_middle = middle.next
    middle.next = None

    # Step 2: Divide and sort
    left = self.mergeSort(head)
    right = self.mergeSort(next_to_middle)

    # Step 3: Merge sorted halves
    sorted_list = self.sortedMerge(left, right)

    return sorted_list


def getMiddle(self, head):
    if not head:
        return head

    slow = head
    fast = head.next

    while fast and fast.next:
        slow = slow.next
        fast = fast.next.next

    return slow


def sortedMerge(self, left, right):
    if not left:
        return right
    if not right:
        return left

    if left.data &amp;lt;= right.data:
        result = left
        result.next = self.sortedMerge(left.next, right)
    else:
        result = right
        result.next = self.sortedMerge(left, right.next)

    return result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Dry Run Example&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;9 -&amp;gt; 5 -&amp;gt; 2 -&amp;gt; 8&lt;/p&gt;

&lt;p&gt;Step 1:&lt;br&gt;
Split into:&lt;/p&gt;

&lt;p&gt;9 -&amp;gt; 5&lt;br&gt;
2 -&amp;gt; 8&lt;/p&gt;

&lt;p&gt;Step 2:&lt;br&gt;
Split again:&lt;/p&gt;

&lt;p&gt;9 | 5&lt;br&gt;
2 | 8&lt;/p&gt;

&lt;p&gt;Step 3:&lt;br&gt;
Merge:&lt;/p&gt;

&lt;p&gt;5 -&amp;gt; 9&lt;br&gt;
2 -&amp;gt; 8&lt;/p&gt;

&lt;p&gt;Final Merge:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 5 -&amp;gt; 8 -&amp;gt; 9&lt;br&gt;
Time and Space Complexity&lt;/p&gt;

&lt;p&gt;Time Complexity: O(n log n)&lt;/p&gt;

&lt;p&gt;Each level divides list into halves.&lt;br&gt;
Merging takes O(n).&lt;/p&gt;

&lt;p&gt;Space Complexity: O(log n)&lt;/p&gt;

&lt;p&gt;Due to recursion stack.&lt;br&gt;
Why This Works Efficiently&lt;/p&gt;

&lt;p&gt;Linked lists allow easy splitting and merging using pointer manipulation.&lt;/p&gt;

&lt;p&gt;No extra array is needed.&lt;br&gt;
No shifting of elements.&lt;br&gt;
Only pointer adjustments.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Remove Duplicates in Sorted Linked List</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Sun, 22 Mar 2026 14:01:59 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/remove-duplicates-in-sorted-linked-list-4kng</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/remove-duplicates-in-sorted-linked-list-4kng</guid>
      <description>&lt;p&gt;Problem Statement&lt;/p&gt;

&lt;p&gt;Given a sorted singly linked list, remove duplicate nodes so that each element appears only once.&lt;/p&gt;

&lt;p&gt;Important:&lt;/p&gt;

&lt;p&gt;The list is already sorted.&lt;br&gt;
Do not use extra space.&lt;br&gt;
Modify the list in-place.&lt;br&gt;
Return the head of the updated list.&lt;br&gt;
Example 1&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; 5&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 4 -&amp;gt; 5&lt;/p&gt;

&lt;p&gt;Explanation:&lt;br&gt;
The value 2 appears twice. Since the list is sorted, duplicates are adjacent. We remove one occurrence.&lt;/p&gt;

&lt;p&gt;Example 2&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 2 -&amp;gt; 2 -&amp;gt; 2 -&amp;gt; 2&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;2&lt;/p&gt;

&lt;p&gt;Explanation:&lt;br&gt;
All elements are the same. We keep only one node and remove the rest.&lt;/p&gt;

&lt;p&gt;Key Observation&lt;/p&gt;

&lt;p&gt;Because the linked list is sorted, duplicate values will always appear next to each other.&lt;/p&gt;

&lt;p&gt;That means we don’t need:&lt;/p&gt;

&lt;p&gt;Extra data structures&lt;br&gt;
Nested loops&lt;br&gt;
Hashing&lt;/p&gt;

&lt;p&gt;We can solve it using a single traversal.&lt;/p&gt;

&lt;p&gt;Approach (Single Traversal)&lt;br&gt;
Idea&lt;br&gt;
Start from the head.&lt;br&gt;
Compare the current node with its next node.&lt;br&gt;
If both values are equal:&lt;br&gt;
Skip the next node.&lt;br&gt;
Otherwise:&lt;br&gt;
Move forward.&lt;br&gt;
Python Implementation&lt;br&gt;
def removeDuplicates(head):&lt;br&gt;
    curr = head&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while curr and curr.next:
    if curr.data == curr.next.data:
        curr.next = curr.next.next
    else:
        curr = curr.next

return head
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;How It Works (Step-by-Step)&lt;/p&gt;

&lt;p&gt;Let’s take:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; 5&lt;br&gt;
Step 1:&lt;br&gt;
curr = first 2&lt;br&gt;
curr.data == curr.next.data → duplicate found&lt;br&gt;
Skip next node&lt;/p&gt;

&lt;p&gt;List becomes:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 4 -&amp;gt; 5&lt;br&gt;
Step 2:&lt;br&gt;
curr moves to 4&lt;br&gt;
4 != 5 → move forward&lt;br&gt;
Step 3:&lt;br&gt;
curr moves to 5&lt;br&gt;
End of list&lt;/p&gt;

&lt;p&gt;Final Result:&lt;/p&gt;

&lt;p&gt;2 -&amp;gt; 4 -&amp;gt; 5&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>coding</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Reverse a Linked List</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Sun, 22 Mar 2026 13:57:23 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/reverse-a-linked-list-1k1j</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/reverse-a-linked-list-1k1j</guid>
      <description>&lt;p&gt;Problem Statement&lt;/p&gt;

&lt;p&gt;Given the head of a linked list, reverse the list and return the new head.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;1 → 2 → 3 → 4 → 5 → NULL&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;5 → 4 → 3 → 2 → 1 → NULL&lt;br&gt;
Table of Contents&lt;br&gt;
Approach – Iterative Method (O(n) Time | O(1) Space)&lt;br&gt;
Alternate Approach 1 – Recursion (O(n) Time | O(n) Space)&lt;br&gt;
Alternate Approach 2 – Using Stack (O(n) Time | O(n) Space)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Approach – Iterative Method (Most Optimal)
Idea&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We reverse the linked list by changing the direction of links using three pointers:&lt;/p&gt;

&lt;p&gt;prev&lt;br&gt;
curr&lt;br&gt;
next_node&lt;/p&gt;

&lt;p&gt;At each step:&lt;/p&gt;

&lt;p&gt;Store next node.&lt;br&gt;
Reverse current node’s pointer.&lt;br&gt;
Move all pointers one step forward.&lt;/p&gt;

&lt;p&gt;We repeat this until the list becomes NULL.&lt;/p&gt;

&lt;p&gt;Step-by-Step Logic&lt;/p&gt;

&lt;p&gt;Initial state:&lt;/p&gt;

&lt;p&gt;prev = NULL&lt;br&gt;
curr = head&lt;/p&gt;

&lt;p&gt;While curr is not NULL:&lt;/p&gt;

&lt;p&gt;Save next node → next_node = curr.next&lt;br&gt;
Reverse link → curr.next = prev&lt;br&gt;
Move prev forward → prev = curr&lt;br&gt;
Move curr forward → curr = next_node&lt;/p&gt;

&lt;p&gt;At the end:&lt;/p&gt;

&lt;p&gt;prev becomes the new head.&lt;br&gt;
Python Code (Iterative – O(1) Space)&lt;br&gt;
class Solution:&lt;br&gt;
    def reverseList(self, head):&lt;br&gt;
        prev = None&lt;br&gt;
        curr = head&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    while curr:
        next_node = curr.next   # Store next node
        curr.next = prev        # Reverse the link
        prev = curr             # Move prev forward
        curr = next_node        # Move curr forward

    return prev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Time and Space Complexity&lt;/p&gt;

&lt;p&gt;Time Complexity: O(n)&lt;br&gt;
Space Complexity: O(1)&lt;/p&gt;

&lt;p&gt;Why O(1)?&lt;br&gt;
Because we are only using three pointers.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Find the Majority Element</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Sun, 22 Mar 2026 13:53:35 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/find-the-majority-element-2lkc</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/find-the-majority-element-2lkc</guid>
      <description>&lt;p&gt;Problem Statement&lt;/p&gt;

&lt;p&gt;Given an array arr[], find the majority element.&lt;/p&gt;

&lt;p&gt;A majority element is defined as an element that appears strictly more than n/2 times in the array.&lt;/p&gt;

&lt;p&gt;If no such element exists, return -1.&lt;/p&gt;

&lt;p&gt;Example 1&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;arr = [1, 1, 2, 1, 3, 5, 1]&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;1&lt;/p&gt;

&lt;p&gt;Explanation:&lt;br&gt;
Array size = 7&lt;br&gt;
n/2 = 3.5&lt;br&gt;
Element 1 appears 4 times → 4 &amp;gt; 3.5 → Majority element&lt;/p&gt;

&lt;p&gt;Example 2&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;arr = [7]&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;7&lt;/p&gt;

&lt;p&gt;Explanation:&lt;br&gt;
Array size = 1&lt;br&gt;
7 appears once → 1 &amp;gt; 0.5 → Majority element&lt;/p&gt;

&lt;p&gt;Example 3&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;arr = [2, 13]&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;-1&lt;/p&gt;

&lt;p&gt;Explanation:&lt;br&gt;
Array size = 2&lt;br&gt;
n/2 = 1&lt;br&gt;
No element appears more than 1 time&lt;/p&gt;

&lt;p&gt;Efficient Approach – Moore’s Voting Algorithm&lt;/p&gt;

&lt;p&gt;Instead of counting frequencies using a dictionary (O(n) space),&lt;br&gt;
we use Moore’s Voting Algorithm which works in:&lt;/p&gt;

&lt;p&gt;Time Complexity: O(n)&lt;br&gt;
Space Complexity: O(1)&lt;/p&gt;

&lt;p&gt;Why Moore’s Voting Works&lt;/p&gt;

&lt;p&gt;If a majority element exists:&lt;/p&gt;

&lt;p&gt;It will survive pairwise cancellation.&lt;br&gt;
Other elements cancel each other out.&lt;br&gt;
The majority element remains as candidate.&lt;/p&gt;

&lt;p&gt;The algorithm works in two phases:&lt;/p&gt;

&lt;p&gt;Find a candidate&lt;br&gt;
Verify the candidate&lt;br&gt;
Step 1 – Find Candidate&lt;/p&gt;

&lt;p&gt;We maintain:&lt;/p&gt;

&lt;p&gt;candidate&lt;br&gt;
count&lt;/p&gt;

&lt;p&gt;Traverse the array:&lt;/p&gt;

&lt;p&gt;If count == 0 → choose new candidate&lt;br&gt;
If element == candidate → increase count&lt;br&gt;
Else → decrease count&lt;br&gt;
Step 2 – Verify Candidate&lt;/p&gt;

&lt;p&gt;Count how many times the candidate appears.&lt;br&gt;
If it appears more than n/2 times → return it.&lt;br&gt;
Otherwise → return -1.&lt;/p&gt;

&lt;p&gt;Python Code (Optimized O(n) Solution)&lt;br&gt;
class Solution:&lt;br&gt;
    def majorityElement(self, arr):&lt;br&gt;
        count = 0&lt;br&gt;
        candidate = None&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Step 1: Find potential candidate
    for num in arr:
        if count == 0:
            candidate = num
            count = 1
        elif num == candidate:
            count += 1
        else:
            count -= 1

    # Step 2: Verify candidate
    if arr.count(candidate) &amp;gt; len(arr) // 2:
        return candidate

    return -1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Dry Run Example&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;[1, 1, 2, 1, 3, 5, 1]&lt;/p&gt;

&lt;p&gt;Iteration process:&lt;/p&gt;

&lt;p&gt;candidate = 1, count = 1&lt;br&gt;
candidate = 1, count = 2&lt;br&gt;
count decreases (2 encountered)&lt;br&gt;
candidate = 1, count = 2&lt;br&gt;
count decreases (3 encountered)&lt;br&gt;
count decreases (5 encountered)&lt;br&gt;
candidate = 1, count = 1&lt;/p&gt;

&lt;p&gt;Final candidate = 1&lt;br&gt;
Verify → appears 4 times&lt;br&gt;
4 &amp;gt; 7//2 → return 1&lt;/p&gt;

&lt;p&gt;Why This Is Optimal&lt;/p&gt;

&lt;p&gt;Brute Force → O(n²)&lt;br&gt;
Using dictionary → O(n) time + O(n) space&lt;br&gt;
Moore’s Voting → O(n) time + O(1) space &lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>dsa</category>
      <category>interview</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>Search in Rotated Sorted Array</title>
      <dc:creator>Santhoshi Mary A</dc:creator>
      <pubDate>Sun, 22 Mar 2026 13:50:44 +0000</pubDate>
      <link>https://dev.to/santhoshi_mary_88917c3fd9/search-in-rotated-sorted-array-57a8</link>
      <guid>https://dev.to/santhoshi_mary_88917c3fd9/search-in-rotated-sorted-array-57a8</guid>
      <description>&lt;p&gt;Problem Statement&lt;/p&gt;

&lt;p&gt;You are given a sorted array that has been rotated at some unknown index.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Original sorted array:&lt;/p&gt;

&lt;p&gt;[0,1,2,4,5,6,7]&lt;/p&gt;

&lt;p&gt;After rotating left by 3:&lt;/p&gt;

&lt;p&gt;[4,5,6,7,0,1,2]&lt;/p&gt;

&lt;p&gt;Given:&lt;/p&gt;

&lt;p&gt;Rotated sorted array nums&lt;br&gt;
A target value target&lt;/p&gt;

&lt;p&gt;Return:&lt;/p&gt;

&lt;p&gt;The index of target if found&lt;br&gt;
-1 if not found&lt;/p&gt;

&lt;p&gt;⚡ Required Time Complexity: O(log n)&lt;/p&gt;

&lt;p&gt;Example 1&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;nums = [4,5,6,7,0,1,2]&lt;br&gt;
target = 0&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;4&lt;br&gt;
Example 2&lt;/p&gt;

&lt;p&gt;Input:&lt;/p&gt;

&lt;p&gt;nums = [4,5,6,7,0,1,2]&lt;br&gt;
target = 3&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;-1&lt;br&gt;
Important Observation&lt;/p&gt;

&lt;p&gt;Even though the array is rotated:&lt;/p&gt;

&lt;p&gt;At least one half of the array is always sorted.&lt;br&gt;
We can use Binary Search logic cleverly.&lt;br&gt;
Key Idea&lt;/p&gt;

&lt;p&gt;At every step:&lt;/p&gt;

&lt;p&gt;Find mid&lt;br&gt;
Check which half is sorted:&lt;br&gt;
Left half sorted?&lt;br&gt;
Right half sorted?&lt;br&gt;
Check if target lies inside the sorted half.&lt;br&gt;
Narrow the search space accordingly.&lt;/p&gt;

&lt;p&gt;This ensures O(log n) complexity.&lt;/p&gt;

&lt;p&gt;Step-by-Step Logic&lt;/p&gt;

&lt;p&gt;Inside while loop:&lt;/p&gt;

&lt;p&gt;Case 1: Left Half is Sorted&lt;/p&gt;

&lt;p&gt;If:&lt;/p&gt;

&lt;p&gt;nums[left] &amp;lt;= nums[mid]&lt;/p&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;p&gt;If target lies between nums[left] and nums[mid]&lt;br&gt;
→ Search left half&lt;br&gt;
Else&lt;br&gt;
→ Search right half&lt;br&gt;
Case 2: Right Half is Sorted&lt;/p&gt;

&lt;p&gt;Else:&lt;/p&gt;

&lt;p&gt;If target lies between nums[mid] and nums[right]&lt;br&gt;
→ Search right half&lt;br&gt;
Else&lt;br&gt;
→ Search left half&lt;br&gt;
Python Implementation (O(log n))&lt;br&gt;
class Solution:&lt;br&gt;
    def search(self, nums, target):&lt;br&gt;
        left = 0&lt;br&gt;
        right = len(nums) - 1&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    while left &amp;lt;= right:
        mid = (left + right) // 2

        # If target found
        if nums[mid] == target:
            return mid

        # Check if left half is sorted
        if nums[left] &amp;lt;= nums[mid]:

            # Target lies in left sorted half
            if nums[left] &amp;lt;= target &amp;lt; nums[mid]:
                right = mid - 1
            else:
                left = mid + 1

        # Otherwise right half is sorted
        else:

            # Target lies in right sorted half
            if nums[mid] &amp;lt; target &amp;lt;= nums[right]:
                left = mid + 1
            else:
                right = mid - 1

    return -1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Time and Space Complexity&lt;/p&gt;

&lt;p&gt;Time Complexity: O(log n)&lt;br&gt;
Space Complexity: O(1)&lt;/p&gt;

&lt;p&gt;Why This Works&lt;/p&gt;

&lt;p&gt;Even after rotation:&lt;/p&gt;

&lt;p&gt;The array is divided into two halves.&lt;br&gt;
One half will always remain sorted.&lt;br&gt;
Binary search reduces search space by half each iteration.&lt;br&gt;
Edge Cases Covered&lt;/p&gt;

&lt;p&gt;Array size = 1&lt;br&gt;
 Target not present&lt;br&gt;
 No rotation (normal sorted array)&lt;br&gt;
 Rotation at last index&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>coding</category>
      <category>computerscience</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
