AVL Tree and MinHeap Java Implementations with Complexity
AVL Tree Java Implementation
Balanced binary search tree (AVL) implementation in Java.
// AVLTree implementation
class AVLTree {
class Node {
int key, height;
Node left, right;
Node(int key) {
this.key = key;
this.height = 1;
}
}
Node root;
int height(Node n) {
return (n == null) ? 0 : n.height;
}
int balance(Node n) {
return (n == null) ? 0 : height(n.left) - height(n.right);
}
Node rotateRight( Read More
Computer Networks: Concepts, Topologies, Signals and Media
1. Introduction to Computer Networks (16 Marks)
Meaning of Computer Network
A computer network is a collection of two or more computers and devices connected together to share data, resources, and information using communication links.
Definition
A computer network is an arrangement of hardware and software that allows devices to communicate and exchange data.
Components of a Network
- Sender – Device that sends data
- Receiver – Device that receives data
- Transmission medium – Path for data (cable, air)
Cybersecurity Essentials: Principles, Mechanisms, and Defense
Computer Security Fundamentals: Core Pillars
The foundation of information security rests on five core principles, often summarized by the CIA Triad plus Authentication and Non-Repudiation (A&NR):
| Principle | Goal | Purpose | Example Mechanism |
|---|---|---|---|
| Confidentiality | Secrecy | Prevent unauthorized viewing or reading of data. | Encryption (turning plaintext into ciphertext). |
| Integrity | Accuracy | Prevent unauthorized modification or deletion of data. | Hashing (creating a fixed-length data digest). |
| Availability | Accessibility | Ensure |
Sensors and Actuators: Differences, DAQ, Types & Applications
Q1: Sensors vs Actuators — Detailed Explanation
Definition of Sensor
A sensor is a device that detects, measures, or senses a physical quantity such as temperature, pressure, displacement, light, humidity, flow, etc., and converts it into a usable electrical signal (voltage, current, resistance).
Sensors act as the input element of any measurement or control system.
They form the first stage of data acquisition.
Without sensors, a system cannot perceive real-world conditions.
Definition of Actuator
An
Read MoreAI Algorithms and Prolog Examples — BFS, A*, Minimax
AI Algorithms and Prolog Examples
This document contains:
- Prolog family facts and queries
- Python implementations of BFS, DFS, A*, Minimax, Alpha-Beta
- 8-puzzle A* solver, Tic-Tac-Toe minimax, a simple reflex agent, and a Chess AI
Prolog Family Facts and Queries
Prolog
parent(john, mary).
parent(john, david).
parent(susan, mary).
parent(susan, david).
parent(david, emily).
parent(david, james).
parent(mary, ann).
male(john).
male(david).
male(james).
female(susan).
female(mary).
female(ann).
female(emily) Read More
Java Programming Examples and Code Snippets
1. Prime Number via Command-Line Argument
This program checks if a number provided via command-line arguments is a prime number.
class PrimeCheck {
public static void main(String[] args) {
int n = Integer.parseInt(args[0]);
boolean isPrime = true;
if (n <= 1) isPrime = false;
for (int i = 2; i <= n / 2; i++) {
if (n % i == 0) {
isPrime = false;
break;
}
}
if (isPrime)
System. Read More
