Java Code Snippets: BSTNode and Graph Algorithms

private BSTNode removeLeaves (BSTNode curr){

if (curr == null)

return null;

if (curr.left == null && curr.right == null){

treeSize–;

return null;

}

curr.left = removeLeaves (curr.left);

curr.right = removeLeaves(curr.right);

return curr;

}

public String getEdges (boolean asc){

TreeMap ,>> m = null;

if (asc == true)

m = new TreeMap ,>> (new Less <><>());

else

m = new TreeMap ,>> (new Greater ());

for (Entry e1: adjacencyMap.entrySet())

Read More

WAN Technology: Circuit, Message & Frame Relay

WAN Technology: Understanding the Basics

WANs (Wide Area Networks) can cover distances from approximately 100 km to over 1000 km, providing service to a country or continent. Many WANs, such as RedIRIS or those used by Internet providers, are built by private companies for private use, offering high-speed connectivity.

Typically, a WAN is a point-to-point network. WANs may use satellite communication systems or radio technology. Their primary function is networking, connecting terminal equipment located

Read More

C Data Structures: Code Examples & Algorithms

Binary Tree Traversal in C

This code demonstrates binary tree traversal using C.

#include <stdio.h>
#include <stdlib.h>

struct node { int data; struct node left; struct node right; };

struct node *root = NULL;

struct node create() { struct node ptr, *ptr1; int x, a;

ptr = (struct node*)malloc(sizeof(struct node));
if (ptr == NULL) {
    printf("Memory Full");
    return NULL; // Important: Return NULL on memory allocation failure
}
printf("\nEnter the data for the current node: ");
scanf(
Read More

Data Transmission Techniques and Communication Channels

Modes of Transmission

Simplex Mode

The transmitter only sends information to the receiver.

Half-Duplex Mode

Protocols manage the transmission turn of each machine.

Full-Duplex Mode

Communication occurs simultaneously in both directions.

Communication Channels

A signal travels through designated “rails”.

Signals require specific bandwidth (range of frequencies for undistorted transmission).

The number of channels depends on the transmission medium.

Channel changes on a transmission medium involve modulation,

Read More

Algorithms in Java

Trapping Rain WaterUnique Paths IIWord Ladder
public int trap(int[] height) {
    if (height == null || height.length == 0) {
        return 0;
    }

    int n = height.length;
    int left = 0, right = n - 1;
    int leftMax = 0, rightMax = 0;
    int waterTrapped = 0;

    while (left <= right) {
        if (height[left] <= height[right]) {
            if (height[left] >= leftMax) {
                leftMax = height[left];
            } else {
                waterTrapped += leftMax - 
Read More

Communication Channels: Types and Applications

Communication Channels

A communication channel is used to route messages from the sender to the receiver’s transmission components. A physical medium can support one or more communication channels. These can be:

  • Guided: Such as copper wires or optical fiber (e.g., coaxial cable).
  • Unguided: Such as air or a vacuum (e.g., wireless communications).

To establish a communication channel, the following are used:

  • Dedicated Links: Establish an exclusive channel between two interlocutors.
  • Point-to-Point: There
Read More