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

Process Planning and Scheduling in Operating Systems

Computer science4.92 KB

Process Planning

Objectives

  • Justice: Avoid favoring some processes over others.
  • Maximum Number of Interactive Users: Focus on most time-sharing systems.
  • Predictability: The strategy must enable the execution of processes.
  • Minimizing Overhead: Minimize context switches.
  • Balance in the Use of Resources: Resources must be used fairly and for as long as possible.
  • Safety Priorities: Established priorities should be respected.
  • Maximum Capacity of Execution: Minimize process changes.

Criteria

  • Response Time: Speed with which the system responds to a request.
  • Service Time: Response time minus time for I/O.
  • Runtime: Service time minus timeout.
  • Processor Time: Processor time occupation.
  • Timeout: Waiting times in queues.
  • Efficiency: Processor utilization.
  • Yield: Number
...
Continue reading "Process Planning and Scheduling in Operating Systems" »

Digital Sound and Video: Formats, Properties, and Tools

Computer science4.86 KB

Digital Sound Features

Sample Rate: The number of samples per second taken from a continuous analog signal to make a discrete digital signal. For example, CD-quality digital audio uses 44,100 Hz.

Channels: The number of audio channels in a sound recording. Mono = 1, Stereo = 2, 5.1 = 5 channels.

Sample Size: Indicates the number of bits of information in each sample. CD-quality audio uses 16 bits.

Formula: Size = Frequency x Sample Size x Number of Channels x Time (in seconds).

Audio Formats

WAV: A digital audio format without compression. It supports mono and stereo files, and its extension is .wav. It is seldom used on the internet. Microsoft and all programs recognize it.

MIDI: A protocol for communication between digital musical instruments and...

Continue reading "Digital Sound and Video: Formats, Properties, and Tools" »

Essential Python Programming Snippets

Computer science2.76 KB

File Handling

# Basic file reading
file = open("data.txt", "r")
content = file.read()          # Read entire file
lines = file.readlines()       # Read as list of lines
file.close()

# Reading line by line
file = open("data.txt", "r")
for line in file:
    print(line.strip())        # strip() removes \n
file.close()

# Write to file (overwrites)
file = open("output.txt", "w")
file.write("Hello World\n")
file.close()

# Append to file (adds to end)
file = open("output.txt", "a")
file.write("New line\n")
file.close()

Working with Lists

# Creating lists
numbers = [1, 2, 3, 4, 5]
names = ["John", "Maria", "Carlos"]

# Accessing elements
first = numbers[0]            # First element
last = numbers[-1]            # Last element
slice = numbers[1:4]
...
Continue reading "Essential Python Programming Snippets" »

C Linked List Student Data Management Systems

Computer science14.42 KB

C Linked List Implementations for Student Data

This document presents two distinct C language implementations for managing student records using linked lists: a singly linked list and a circular linked list. Both examples demonstrate fundamental data structure operations such as adding, deleting, searching, and displaying student information.

1. Singly Linked List Implementation

This section details a student management system built using a singly linked list. Students are stored in ascending order of their roll numbers, and duplicate roll numbers are prevented.

Core Structure and Global Head

The Student structure defines the data for each node, including roll number, total marks, average, and a pointer to the next student. The head pointer always...

Continue reading "C Linked List Student Data Management Systems" »

SQL Database Design Examples for Common Systems

Computer science3.62 KB

This document provides practical SQL Data Definition Language (DDL) examples for creating and modifying database schemas across various common applications. Each section details the necessary tables and their relationships, offering a clear foundation for building robust relational databases.

Library Management System Database

The following SQL DDL statements define the core tables for a library management system, enabling the tracking of books, members, and loan transactions.

Table Creation

CREATE TABLE Books (
    BookID INT PRIMARY KEY,
    Title VARCHAR(100) NOT NULL,
    Author VARCHAR(100) NOT NULL,
    ISBN VARCHAR(20) UNIQUE,
    PublishedYear INT CHECK (PublishedYear >= 1500 AND PublishedYear <= 2025)
);

CREATE TABLE Members (
...
Continue reading "SQL Database Design Examples for Common Systems" »

Computer Science Core Concepts: Data, Systems, and Networks

Computer science74.9 KB

💾 Data Representation Fundamentals

Binary Coded Decimal (BCD) Benefits

BCD is a method to represent decimal numbers in binary form, where each decimal digit is represented by a fixed number of bits, usually four.

Benefits of BCD include:

  • Straightforward conversion between BCD and **decimal (base 10)**.
  • Less complex to encode and decode for programmers.
  • Easier for digital equipment to use BCD to display information.
  • Can represent monetary values exactly.

Applications of BCD:

  • Electronic displays (e.g., calculators, digital clocks) - easier conversion between decimal and BCD when only individual digits need to be shown.
  • Storage of date and time in PC BIOS - easier conversion with decimal values.

Hexadecimal Applications

Hexadecimal is used in:

  1. MAC addresses.
...
Continue reading "Computer Science Core Concepts: Data, Systems, and Networks" »

PHP & Web Development Essentials: Core Concepts

Computer science315.08 KB

2Q==

9k=

PHP Core Concepts: Quick Answers

PHP Array Types

  • Indexed Array: A normal array with numeric keys.
  • Associative Array: An array with named keys (strings).
  • Multidimensional Array: An array containing one or more other arrays.

PHP Arithmetic Operators

  • + (Addition): Adds two operands.
  • - (Subtraction): Subtracts the second operand from the first.
  • * (Multiplication): Multiplies two operands.
  • / (Division): Divides the first operand by the second.
  • % (Modulus): Returns the remainder of a division.

Understanding PHP Abstract Classes

An abstract class in PHP is a class that cannot be directly instantiated. It may contain abstract methods that must be defined (implemented) in any child classes that inherit from it.

What is a Sticky Form?

A sticky form is a web form that...

Continue reading "PHP & Web Development Essentials: Core Concepts" »

Core Concepts in Compiler Design and Language Runtime

Computer science10.45 KB

Core Concepts in Compiler Design

Compiler

Compiler: Translates entire source code to target code before execution. It requires a full parse and upfront error checking, then executes the generated target code.

Interpreter

Interpreter: Executes source code incrementally (line-by-line or statement-by-statement). It translates and executes on the fly, and may partially execute ill-formed programs until an error is encountered.

LVar vs. x86 Architecture

LVar: Features nested expressions, implicit control flow (represented by an Abstract Syntax Tree - AST), and an unlimited number of logical variables.

x86: Characterized by flat instructions, atomic operands (registers/memory), explicit control flow (jumps), and a limited set of registers. Compilation passes...

Continue reading "Core Concepts in Compiler Design and Language Runtime" »

Client-Side Web Application Development Examples

Computer science8.49 KB

Client-Side Web Application Logic

Course Registration Script

This script handles the client-side logic for a course registration form. It fetches available courses, populates a selection dropdown, and processes form submissions to register new entries via an API.

DOM Element Selection and Initialization

The script begins by selecting necessary DOM elements for interaction and notification display.

const init = async function () {
  const selectEl = document.querySelector("select");
  const formEl = document.querySelector("form");
  const notifEl = document.querySelector(".success-notif");
  const errNotifEl = document.querySelector(".fail-notif");

Notification Dismissal Logic

Functionality to close success and error notification boxes is implemented

...

Continue reading "Client-Side Web Application Development Examples" »

Tensors and Variables in PyTorch and TensorFlow

Computer science2.4 KB

Tensors and Variables in PyTorch and TensorFlow

Here's a brief explanation of tensors and variables in the context of deep learning frameworks like PyTorch and TensorFlow:

Tensors

  • Definition: A tensor is a multi-dimensional array used to represent data (such as scalars, vectors, matrices, or higher-dimensional data).
  • Common Operations: Tensors can be manipulated with mathematical operations (addition, multiplication, etc.), reshaped, sliced, etc.

In PyTorch, tensors are the core data structure:

import torch
# Create a tensor
a = torch.tensor([[1, 2], [3, 4]])
# Basic operations
b = a + 2         # Adds 2 to each element
c = a * a         # Element-wise multiplication
d = a @ a         # Matrix multiplication

Output:

Tensor `b`: [[3, 4], [5, 6]]
Tensor
...
Continue reading "Tensors and Variables in PyTorch and TensorFlow" »