Notes, summaries, assignments, exams, and exercises for Computer science for Other courses

Distributed Systems: Consensus, Concurrency, and Recovery

Computer science924.39 KB

01. Election Algorithms and Requirements

An election algorithm is a method used in distributed systems to designate a single process as the coordinator or leader. The primary requirements include ensuring that only one leader is elected at a time and that all processes agree on the outcome.

2AAAAABJRU5ErkJggg==

KysCKBIoHeS6AAXO+3uCywSGC4EigAN9y9LysvEui9BArA9X6LywKLBIYrgQJww937svIigd5LoABc77e4LLBIYLgSKAA33L0vKy8S6L0ECsD1fovnucB+5S3OU1Ll3suRQAG45ci9fGuRQHsJlPOktcwKwLUWWflAkUCRwGmRwP+2YqZu0XHbqQAAAABJRU5ErkJggg==

2rUapVIp2d3a5BmL7pKnEp6v0dyDRYapDbv8AxgDRdc3pSV0AAAAASUVORK5CYII=

02. Two-Phase Commit Protocol

The Two-Phase Commit (2PC) protocol ensures atomicity and consistency across distributed transactions. It coordinates multiple nodes to ensure they either all commit or all abort.

Phases of 2PC

  • Phase 1: The Prepare Phase (Voting): The coordinator asks participants if they can commit.
  • Phase 2: The Commit Phase (Decision): The coordinator instructs participants to finalize the transaction based on the votes.

wMyHYYxJZAChgAAAABJRU5ErkJggg==

Roles and Steps

  • Coordinator:
...
Continue reading "Distributed Systems: Consensus, Concurrency, and Recovery" »

Essential Algorithms and Data Structures: A Quick Reference

Computer science580.94 KB

fUlQAAAABJRU5ErkJggg==

AOUNZyjQwEJMAAAAAElFTkSuQmCC


Essential Algorithms and Data Structures

Longest Increasing Subsequence (LIS):

  • Subproblem: dp[i] = length of LIS ending at index i
  • Recursion: dp[i] = max(dp[j] + 1 for j < i and arr[j] < arr[i])
  • Base case: dp[i] = 1 (every element is a subsequence of length 1)
  • Time Complexity: O(n^2), O(n log n) with binary search optimization.

Longest Alternating Subsequence (LAS):

  • Subproblem: dp[i][0] (increasing), dp[i][1] (decreasing)
  • Recursion: dp[i][0] = max(dp[j][1] + 1 for j < i and arr[j] < arr[i]), dp[i][1] = max(dp[j][0] + 1 for j < i and arr[j] > arr[i])
  • Base case: dp[0][0] = 1, dp[0][1] = 1
  • Time Complexity: O(n^2)

0/1 Knapsack Problem:

  • Subproblem: dp[i][w] = maximum value for the first i items and weight limit w
  • Recursion: dp[i][w] = max(
...
Continue reading "Essential Algorithms and Data Structures: A Quick Reference" »

Point-to-Point Protocol and Data Link Layer Design

Computer science2.25 KB

Point-to-Point Protocol (PPP)

PPP stands for Point-to-Point Protocol. It is the most commonly used protocol for point-to-point access. For instance, if a user wants to access the internet from home, the PPP protocol is typically employed.

As a Data Link Layer protocol residing in Layer 2 of the OSI model, it encapsulates Layer 3 protocols and all payload information for transmission across serial links. The PPP protocol functions on synchronous links like ISDN as well as asynchronous links like dial-up. It is primarily used for communication between two devices.

Physical Network Compatibility

PPP operates over various physical networks, including:

  • Serial cables
  • Phone lines
  • Trunk lines
  • Cellular telephones
  • Fiber optic links (such as SONET)

Since the Data...

Continue reading "Point-to-Point Protocol and Data Link Layer Design" »

Mastering Apache Flink and HBase Data Operations

Computer science4.37 KB

Identify High-Volume Customer Purchases in Flink

The following Java code utilizes Apache Flink to identify customers who purchase more than 10 units of a specific item within a session window.

public class CustomerPurchase {
    public static void main(String[] args) throws Exception {
        final ParameterTool params = ParameterTool.fromArgs(args);
        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<String> text = env.readTextFile(params.get("input"));
        env.getConfig().setGlobalJobParameters(params);

        SingleOutputStreamOperator<Tuple3<Long, Integer, Integer>> mapStream = text.map(new MapFunction<String, Tuple3<Long, Integer, Integer>
...
Continue reading "Mastering Apache Flink and HBase Data Operations" »

C# Project & Developer Management Controller

Computer science7.12 KB

C# Project and Developer Management Controller

This document outlines the core logic for a C# controller designed to manage software projects and their associated developers. It demonstrates fundamental operations such as adding, finding, and listing projects and developers, ensuring data integrity by preventing duplicates.

GestorController Class Definition

The GestorController class serves as the central hub for managing project and developer data. It resides within the GestionProyectos.Controllers namespace and utilizes models from GestionProyectos.Models.

using GestionProyectos.Models; //Controllers-GestionP

namespace GestionProyectos.Controllers
{
    public class GestorController
    {
        public static List Projects { get; set; };
...
Continue reading "C# Project & Developer Management Controller" »

Malicious Software: Types, Threats, and Advanced Viruses

Computer science3.31 KB

Logic Bombs and Resource Exhaustion Attacks

Logic Bombs

A logic bomb is a program that performs an action violating the site security policy when a specific external event occurs. These are typically associated with insider threats.

Example: A program that deletes a company’s payroll records when one particular record is deleted.

  • The "particular record" is usually that of the person who created the logic bomb.
  • The idea is that if (or when) the creator is fired and their payroll record is deleted, the company loses all those records.

Rabbits and Bacteria (Resource Exhaustion)

Rabbits or Bacteria refer to programs designed to absorb all of a specific class of system resources, leading to denial of service or system instability.

Example: For a UNIX...

Continue reading "Malicious Software: Types, Threats, and Advanced Viruses" »

Understanding Firewalls: Essential for Network Security

Computer science3.11 KB

Firewalls lay the foundation for network security. One of the most effective steps an organization can take to ensure network security is to install firewalls. A firewall can effectively enforce general security guidelines, such as disallowing audio streaming, controlling Internet access, or providing a virtual blockade from unknown network traffic. A firewall can be implemented as a software application or a hardware device and is designed to handle a number of crucial security tasks:

  • Firewalls restrict network traffic between networks.
  • Firewalls provide a chokepoint—a single point of entry or exit.
  • Firewalls can record network activity.

Because firewalls play such an important role within a network and are usually placed in the most vulnerable...

Continue reading "Understanding Firewalls: Essential for Network Security" »

VB.NET Code Examples for Arrays and Timer Controls

Computer science2.92 KB

Weight Calculation and Session Management in VB.NET

This example demonstrates how to handle weight data using arrays and manage application sessions with timers.

Public Class Form1
    Dim PESOPERSONA(1) As Integer
    Dim PESOTOTAL As Integer

    Private Sub Form1_Load(...)
        Me.Text = "CÁLCULO DE PESO"
        Label1.Text = "RESULTADO"
        Label2.Text = "" & vbCrLf
        PESOPERSONA(0) = 105
        PESOPERSONA(1) = 55

        For i = 0 To 7
            If PESOPERSONA(i) < 10 Or PESOPERSONA(i) > 100 Then
                Label2.Text = Label2.Text & "EL DATO DE PESO " & i & " no es válido por no estar entre 10 y 100 " & vbCrLf
            Else
                PESOTOTAL = PESOTOTAL + PESOPERSONA(i)
...
Continue reading "VB.NET Code Examples for Arrays and Timer Controls" »

OSI Model Layers and Network Infrastructure Fundamentals

Computer science3.32 KB

The Seven Layers of the OSI Reference Model

Physical Layer (Layer 1)

The Physical Layer of the OSI reference model is responsible for the physical connections of the computer to the network. It is responsible for transmitting bits of information through the medium used for transmission.

Data Link Layer (Layer 2)

The Data Link Layer is concerned with physical addressing, network topology, network access, error notification, ordered distribution of frames, and flow control.

Network Layer (Layer 3)

The aim of the Network Layer is to ensure data arrives from the origin to the destination, even though both are not connected directly. The devices that facilitate such a task are called routers.

Transport Layer (Layer 4)

The function of the Transport Layer

...

Continue reading "OSI Model Layers and Network Infrastructure Fundamentals" »

Software Development Models: Waterfall, Prototype, and More

Computer science3.14 KB

Software Development Models

Attributes of Effective Requirements (AtrERS): Correct, unambiguous, complete, verifiable, consistent, modifiable, concise, organized, searchable, understandable by the client, regardless of design.

Scaling Factors: Correctness, reliability, efficiency, integrity, ease of use and maintenance, flexibility, ease of testing, portability, reusability, ease of interoperation.

Life History: Succession of stages through which a software product passes during its existence. Attempts to determine the order of the steps involved and the criteria associated with the transition between these stages.

Software Engineering: Application of scientific knowledge to the design and construction of computer programs and associated documentation...

Continue reading "Software Development Models: Waterfall, Prototype, and More" »