Tag Archives: C++

Implementation of Distance Vector Routing (DVR) Algorithm in C++

Distance Vector Routing (DVR) is a fundamental algorithm in computer networking used for finding the shortest path between nodes in a network. This blog post explores a C++ implementation of the DVR algorithm, demonstrating how it calculates and updates routing tables dynamically.

What is Distance Vector Routing?

DVR is a decentralized routing protocol where each router maintains a table containing the shortest distance to every other router in the network. Periodically, routers exchange this information with their neighbors, updating their tables accordingly.

C++ Implementation

The following C++ code demonstrates the DVR algorithm by:

  1. Initializing a network graph with user-defined distances.
  2. Sharing distance vectors between nodes.
  3. Iteratively updating routing tables until convergence.
Continue reading Implementation of Distance Vector Routing (DVR) Algorithm in C++

C++ Implementation of Substitution Cipher

This simple C++ implementation of a substitution cipher—specifically the Caesar cipher—demonstrates how basic cryptographic techniques can be used with file handling.

The Caesar cipher is one of the oldest and simplest substitution cipher techniques. It works by shifting the letters in a message by a fixed number of positions in the alphabet. Unlike transposition ciphers, which rearrange character positions, substitution ciphers replace characters with others based on a defined scheme.

This blog post demonstrates a C++ implementation that reads a message from a file, performs Caesar cipher encryption or decryption, and writes the result to another file.


How It Works

  1. Input and Output Files:
    • Input is read from a file named anip.txt.
    • Output is written to a file named anop.txt.
  2. User Choices:
    • You can choose between encryption and decryption.
    • Provide a key (shift amount), e.g., 2.
  3. Caesar Cipher Logic:
    • For encryption, each letter is shifted forward in the alphabet by the key.
    • For decryption, each letter is shifted backward by the key.
    • Non-alphabet characters are left unchanged.
Continue reading C++ Implementation of Substitution Cipher

Implementation of Bottom-Up (Shift-Reduce) Parsing in C++

This program implements a basic shift-reduce parser for parsing expressions based on given grammar rules. It reads a set of production rules and an input string, then attempts to reduce the input to the start symbol.

The process follows these steps:

  1. Shift input symbols onto a stack.
  2. Attempt to reduce the top of the stack based on the given production rules.
  3. Continue until the entire input is processed and reduced to the start symbol.
Continue reading Implementation of Bottom-Up (Shift-Reduce) Parsing in C++