Notes, summaries, assignments, exams, and problems for Computer science

Data Link Layer Functions and Frame Structures

Computer science3.1 KB

Data Link Layer Frames

In the link layer, data is organized into units called frames. Each frame has a header, which includes an address and control information, and a tail that is used for error detection.

The header of a Local Area Network (LAN) contains the physical addresses of the source and destination. The header of a frame that is spread by a Wide Area Network (WAN) contains a circuit identifier in the direction field.

Remember that a link is a local area network, a peer-to-peer facility, or another wide-area facility by which systems can communicate using a data link layer protocol.

Core Functions of the Data Link Layer

The data link layer is responsible for the reliable transfer of information through a data transmission circuit. Data...

Continue reading "Data Link Layer Functions and Frame Structures" »

Parcial_2_antonio_B

Computer science3.52 KB


Criteria to organize files · quick-access necessary when a single record is accessed. -not needed if a file will be processed in batches. Easy to update-a file on CD-ROM updates and never ease storage is not considered economic. -minimum data redundancy. -redundancy can be used to speed up access. · a single-index · Maintenance cheaper. -fewer errors.· Reliability A directory can have subdirectories, thus forming a hierarchical structure in the shape of an inverted tree, is symbolized by a bar of division (/) Some directories on Linux: • / bin Contains executable programs that are part of the Linux operating system . Many Linux commands like cat, cp, ls, more and tar are located in this directory. • / bootIt contains the kernel (or...

Continue reading "Parcial_2_antonio_B" »

Secure PHP File Upload Script for Word Documents

Computer science3.43 KB

Secure PHP Word Document Upload Script

This PHP script manages secure document uploads, specifically restricting files to the Microsoft Word format, validating file sizes, handling duplicate filenames, and saving the record to a MySQL database.

PHP Upload Code

<?php
// PROGRAMMING BEGINS //::::::::::::::::::::::::::::::: DOCUMENT
if ($success1) {
    // define() is a function that defines a constant. Equates to 300KB
    define('max_file_size', 3000000);
    define('UPLOAD_DIR2', 'documents/');

    $file = str_replace(' ', '_', $_FILES['file']['name']);
    
    // Calculate the maximum size of a file to upload
    $max = number_format(max_file_size / 2048, 1) . ' KB';
    
    // Define or calculate the file size
    $size = number_format(
...
Continue reading "Secure PHP File Upload Script for Word Documents" »

Network Hardware and Cabling Standards Explained

Computer science2.5 KB

Network Hardware Hubs, Switches, and Routers

  • HUB: Functions like a power strip. It distributes network traffic to all connected devices without identifying specific recipients, which can limit individual performance.
  • SWITCH: Contains internal memory to identify connected devices, ensuring data is sent only to the intended recipient. It supports individual device speeds, though total throughput is limited by the cable capacity.
  • ROUTER: Acts as a gateway to external networks. It uses software to generate IP addresses and serves as a bridge between different networks. If data is intended for an external destination, the switch or hub forwards it to the router to find the recipient.

Network Cable Types

  • Shielded Twisted Pair (STP): Each pair is coated
...
Continue reading "Network Hardware and Cabling Standards Explained" »

Database Normalization and Indexing Principles

Computer science3.08 KB

1. Functional Dependency (FD)

A functional dependency A → B means: if you know the value of attribute A, you can always determine the value of attribute B. In other words, no two rows can have the same A value but different B values.

Example: In a table Student(StudentID, Name, Email): StudentID → Name, Email (Given a StudentID, the Name and Email are always uniquely determined.)

2. Boyce-Codd Normal Form (BCNF)

A relation is in BCNF if, for every functional dependency X → Y, X is a superkey.

  • Compliance: Every determinant in the table is a candidate key—no changes needed.
  • Evaluation: Whenever there is a non-trivial FD X → Y where X is not a superkey. This means some attribute depends on only part of a key, or on a non-key attribute—causing
...
Continue reading "Database Normalization and Indexing Principles" »

Data Structures Master Cheat Sheet: CC-104 Exam Prep

Computer science8.93 KB

CC-104 Data Structures Master Cheat Sheet

1. High-Yield Formulas & Operations

  • 2D Array Address (Row-Major):
    Address = Base + Size × (i × TotalColumns + j)
  • 2D Array Address (Column-Major):
    Address = Base + Size × (j × TotalRows + i)
  • Circular Queue Index Increment:
    rear = (rear + 1) % MAX;
  • AVL Tree Balance Factor:
    Balance Factor = Height(Left Subtree) - Height(Right Subtree)
    (Valid values are strictly -1, 0, or 1. Anything else triggers rotation).
  • 3-Step Postfix Conversion Shortcut (A + B * C):
    1. Bracket by precedence: (A + (B * C))
    2. Move operators right of brackets: (A (B C)*)+
    3. Remove brackets: A B C * +

2. Mandatory Comparison Tables

Array vs. Linked List

FeatureArrayLinked List
Memory LayoutContiguous (sequential blocks)Non-contiguous (scattered
...
Continue reading "Data Structures Master Cheat Sheet: CC-104 Exam Prep" »

Essential Kubectl Commands: The Ultimate Kubernetes Cheat Sheet

Computer science7.76 KB

Key Takeaways

  • kubectl is the core tool for managing Kubernetes clusters, enabling you to inspect, deploy, troubleshoot, and scale workloads from the command line. Mastering flags like -n, -o, and --dry-run is essential.
  • Use a consistent workflow for debugging: get → describe → logs. This structured approach surfaces issues faster and reduces downtime.
  • Favor declarative over imperative commands by using YAML manifests with kubectl apply to promote version control and repeatability.

Kubernetes (K8s) is the industry standard for orchestrating containerized applications, but managing it can be complex. At the center of every Kubernetes workflow is kubectl, the command-line utility used to interact with clusters, deploy applications, and troubleshoot

...

Continue reading "Essential Kubectl Commands: The Ultimate Kubernetes Cheat Sheet" »

Java Stream Classes and ArrayList Methods

Computer science2.78 KB

What is a Stream and its Classes in Java?

Introduction
A Stream is a sequence of data that flows between a program and an input/output device. Streams are used to perform input and output operations in Java. Java provides stream classes in the java.io package for reading and writing data. Streams simplify file handling and data communication.

Types of Streams

1. Input Stream

Used to read data from a source such as a file, keyboard, or network. Data flows from the source to the program.

2. Output Stream

Used to write data to a destination such as a file, screen, or network. Data flows from the program to the destination.

Various Stream Classes in Java

1. FileInputStream

Used to read data from a file. It reads data in byte format and is suitable for reading...

Continue reading "Java Stream Classes and ArrayList Methods" »

C# WPF Login Window: Authentication with DatabaseService Example

Computer science1.62 KB

using System.Data;
using System.Windows;

namespace WpfApp1
{
public partial class LoginWindow : Window
{
private readonly DatabaseService db = new DatabaseService();

public LoginWindow()
{
InitializeComponent();
}

private void LoginButton_Click(object sender, RoutedEventArgs e)
{
string login = LoginTextBox.Text.Trim();
string password = PasswordBox.Password.Trim();

if (login == "" || password == "")
{
MessageBox.Show("Введите логин и пароль.", "Ошибка");
return;
}

DataTable user = db.Login(login, password);

if (user.Rows.Count == 0)
{
...

Continue reading "C# WPF Login Window: Authentication with DatabaseService Example" »

Админ панель: управление пользователями в WPF с SQL Server и экспортом данных

Computer science3.31 KB

Админ панель







Панель администратора









Инициализация страницы

public AdminPage()
{
    InitializeComponent();
    LoadUsers();
}

Загрузка пользователей

private void LoadUsers()
{
    using (SqlConnection conn = new SqlConnection(connStr))
    {
        conn.Open();
        string sql = "SELECT id_User, Login, Block, FailPassword FROM Users";
        SqlDataAdapter da = new SqlDataAdapter(sql, conn);
        System.Data.DataTable dt = new System.Data.DataTable();
        da.Fill(dt);
        dgUsers.ItemsSource = dt.DefaultView;
    }
}

private void btnRefresh_Click(object sender, RoutedEventArgs e) => LoadUsers();

Добавление пользователя

private
...
Continue reading "Админ панель: управление пользователями в WPF с SQL Server и экспортом данных" »