Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

Network Fundamentals: Protocols, Addressing, Security

Posted by Anonymous and classified in Computers

Written on in English with a size of 17.78 KB

TCP Reliable Transfer and Connection Management

TCP Reliable Transfer

  1. Sequence Numbers

    • Each byte of data is assigned a sequence number. This number is used by the receiver to correctly order the data and ensure there are no missing segments.
  2. Acknowledgements

    • The receiver sends back an ACK to the sender for the sequence number of the next expected byte. If the sender receives the ACK before its timer expires, it knows everything up to that byte was received correctly.
  3. Retransmission

    • If the ACK is not received before the timer expires, the sender retransmits the data.

TCP Connection Management

Managing a TCP connection begins with a three-way handshake, which establishes a connection before any actual data is transmitted.

Steps in Three-Way Handshake

  1. SYN
    • The
... Continue reading "Network Fundamentals: Protocols, Addressing, Security" »

Synchronization and CPU Scheduling in Operating Systems

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.87 KB

Chapter 5: Synchronization

Critical Section Conditions

  • Mutual Exclusion: Only one process may be in the critical section at a time.
  • Progress: If the critical section is empty, some waiting process can enter.
  • Bounded Waiting: No starvation; each process waits a bounded number of turns.

Atomic Instructions

  • Test-and-Set: old = *b; *b = TRUE; return old
  • Swap: temp = *a; *a = *b; *b = temp

Spinlocks

  • TAS:
    bool m = false;
    lock() { while (TestAndSet(&m)); }
    unlock() { m = false; }
    
  • Swap:
    bool m = false;
    lock() { bool key = true; while (key) Swap(&m, &key); }
    unlock() { m = false; }
    

Semaphores

  • wait(S): S.val--; if S.val < 0 block
  • signal(S): S.val++; if S.val <= 0 wake one
  • Binary semaphore as mutex: init = 1; lock = wait; unlock = signal

Peterson's

... Continue reading "Synchronization and CPU Scheduling in Operating Systems" »

Implementing Dijkstra's Algorithm in Java

Classified in Computers

Written on in English with a size of 2.71 KB

This implementation demonstrates how to find the shortest path from a source node to all other nodes in a graph using Dijkstra's Algorithm.

Core Components

  • minDist: Identifies the node with the minimum distance not yet included in the shortest path tree.
  • print: Displays the calculated shortest distances from the source.
  • dijkstra: The primary logic that updates distances based on the adjacency matrix.
import java.util.*;

public class Main {
    static int V;

    // Find the node with the minimum distance not yet in the shortest path tree
    int minDist(int dist[], Boolean boolset[]) {
        int min = Integer.MAX_VALUE, min_value = -1;
        for (int i = 0; i < V; i++) {
            if (!boolset[i] && dist[i] <= min) {
... Continue reading "Implementing Dijkstra's Algorithm in Java" »

Digital Electronics Concepts: Flip-Flops, Registers, and Converters

Posted by Anonymous and classified in Computers

Written on in English with a size of 1.38 MB

1. JK Flip-Flop Operation and Truth Table

Logic Diagram:

wBjcvJtk2sNIQAAAABJRU5ErkJggg==

EAjrov4gZdUr+SxbQQf9fGi1dW7+IBXTQfxEz6pT8lyzwf4VinCuWPVOZAAAAAElFTkSuQmCC

Working Principle

The JK flip-flop is an enhanced version of the gated SR flip-flop. It incorporates clock input circuitry to eliminate the invalid output condition that occurs when both S and R inputs are logic level "1".

Because of the added clock input, the JK flip-flop offers four distinct input combinations:

  • Logic "1" (Set)
  • Logic "0" (Reset)
  • No Change
  • Toggle

The S and R inputs of the preceding SR bistable are replaced by J and K inputs, named after its inventor, Jack Kilby. Thus, J = S and K = R.

The two 2-input AND gates in the gated SR bistable are replaced by two 3-input NAND gates. The third input of each NAND gate connects to the outputs Q and $\bar{Q}$. This cross-coupling allows the... Continue reading "Digital Electronics Concepts: Flip-Flops, Registers, and Converters" »

Core Web Development Concepts: Languages, Protocols, and Frameworks

Posted by Anonymous and classified in Computers

Written on in English with a size of 332.62 KB

JavaScript: The Heart of Interactive Web Development

JavaScript is a powerful and widely used programming language mainly used for making websites interactive and dynamic. It works on the client-side, which means it runs inside the user's web browser. JavaScript allows web pages to respond to user actions like clicking buttons, typing in text boxes, hovering over images, and more. It works together with HTML (for structure) and CSS (for design) to build modern and user-friendly websites. It is easy to learn and used by almost every website today.

Apart from the client-side, JavaScript is also used on the server-side using platforms like Node.js, which allows building full web applications using JavaScript alone. It is a platform-independent language,... Continue reading "Core Web Development Concepts: Languages, Protocols, and Frameworks" »

Python Fundamentals: Code Examples and Exercises

Posted by Anonymous and classified in Computers

Written on in English with a size of 10.65 KB

Python Operations and Operators

This section covers fundamental operations and operators in Python, which are symbols used to perform operations on values and variables.

# Examples of different operators
a = 10 // 3  # Floor Division
a = 10 % 3   # Modulo Operator
a = 3        # Assignment
b = 1        # Declaring variables
a == b       # Comparison

Types of Operators

Operators are used for operations between values and variables. The main types are:

  • Assignment Operators: Used to assign values to variables.
  • Logical Operators: Used to combine conditional statements.
  • Comparison Operators: Used to compare two values.
  • Arithmetic Operators: Used with numeric values to perform common mathematical operations.
  • Bitwise Operators: Used to compare binary numbers.
... Continue reading "Python Fundamentals: Code Examples and Exercises" »

Core Graph Algorithms Pseudocode Reference

Classified in Computers

Written on in English with a size of 3.58 KB

Core Graph Algorithms Pseudocode

Kruskal's Algorithm for MST

def Kruskal(V, E):

  1. Sort E by increasing weight.
  2. For each vertex v in V: create a tree for each v.

MST = {}

For i from 1 to |E|:

  1. (u, v) ← lightest edge in E.
  2. If u and v are not in the same tree:
  • MST.add((u,v))
  • Merge u and v trees.

Return MST.

Huffman Tree Construction

BuildHuffman(characters[1..n], frequencies[1..n]):

  • Create nodes for each character.
  • For i ← 1 to n: create a min-heap Q with each node frequency as a key.

While(length(Q) > 1):

  1. x = pop minimum value from Q.
  2. y = pop minimum value from Q.
  3. Create new node z.
  4. z.key = x.key + y.key
  5. z.leftChild = x
  6. z.rightChild = y
  7. Insert z into Q.

Return the root value from Q.

Topological Sort

topological_sort(G):

Stack = []

While (unvisited Nodes):

helper_toposort(

... Continue reading "Core Graph Algorithms Pseudocode Reference" »

Sistema de Gestión de Usuarios con Java Web

Classified in Computers

Written on in English with a size of 21.85 KB

Archivos HTML del Frontend

INDEX.HTML: Menú Principal del Sistema

<!DOCTYPE html>
<html>
<head>
    <title>Menú Principal del Sistema</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        h2 { color: #789; font-size: 45px; }
        select { color: brown; font-size: 30px; }
        h3 { color: #8b4513; font-size: 30px; }
    </style>
</head>
<body>
    <h2>Menú de Opciones del Sistema</h2>
    <h3>Seleccione una opción:</h3>
    <ol>
        <li><a href="Registro.html">Registrar Usuario</a></li>
        <li><a href="Acceso.html">Acceso
... Continue reading "Sistema de Gestión de Usuarios con Java Web" »

PHP Programming Essentials and Core Features

Classified in Computers

Written on in English with a size of 2.95 KB

What is PHP?

PHP (Hypertext Preprocessor) is a widely-used open-source scripting language primarily designed for web development. It runs on the server-side, meaning the code is executed on the web server before the output is sent to the user's browser. PHP is embedded within HTML and supports various databases, making it a powerful tool for creating dynamic and interactive web applications.

Key Features of PHP

PHP has several features that make it a popular choice for web development:

  • Open-Source – PHP is free to use, with a large community of developers providing support and updates.
  • Cross-Platform Compatibility – PHP works on multiple operating systems like Windows, Linux, and macOS.
  • Easy to Learn and Use – Its syntax is simple and similar
... Continue reading "PHP Programming Essentials and Core Features" »

C++ Code Examples: Arithmetic Mean, Sum, Product, Square

Classified in Computers

Written on in English with a size of 1.55 KB

Arithmetic Mean

The following C++ code calculates the arithmetic mean of numbers from 1 to n:

int main() {
    int n;
    double suma = 0;
    cout << "Vnesi broj: ";
    cin >> n;
    if (n <= 0) {
        cout << "Brojot na elementi mora da bide pogolem od 0!" << endl;
        return 1;  
    }
    for (int i = 1; i <= n; i++) {
        suma += i;  
    }
    double sredina = suma / n;
    cout << "Aritmetichkata sredina na broevite od 1 do " << n << " e: " << sredina << endl;
    return 0;
}

Sum

The following C++ code calculates the sum of numbers from 1 to n:

int main() {
    int n, sum = 0;
    cout << "Vnesi broj n: ";
    cin >> n;
    for (int i = 1; i <= n; i++)
... Continue reading "C++ Code Examples: Arithmetic Mean, Sum, Product, Square" »