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

Java AWT Architecture: Components, Events & Listeners

Computer science11.3 KB

Java AWT Architecture: Components and Events

The Abstract Window Toolkit (AWT) is Java's original platform-dependent windowing, graphics, and user interface (UI) toolkit.

AWT Class Hierarchy

🖼️ The core of the AWT is structured around a few key classes, all of which inherit from the Object class.

1. Component Class

The Component class is the root of all AWT UI elements. A Component is an object with a graphical representation that can be displayed on the screen and can interact with the user. Examples of components include buttons, text fields, and scrollbars.

  • Key capabilities:
    • Defining visual appearance and behavior
    • Handling events (user input)
    • Drawing and painting

2. Container Class

A Container is a special type of component that can hold and organize...

Continue reading "Java AWT Architecture: Components, Events & Listeners" »

Computer Terminology Glossary

Computer science5.84 KB

A

  • ATTACHMENT: A file that is sent with an email.
  • BANDWIDTH: A measurement of the amount of information that a computer network can send or receive. High bandwidth allows images and websites to load quickly on the Internet.
  • BANNER: A rectangular graphic on a website that advertises a business.
  • CASE: An enclosure that holds the computer's components.
  • CODE: A set of words and symbols that give instructions to a computer.
  • CONTENT: The material on a web page, including text and graphics.
  • CROP: To cut off unwanted parts of an image.
  • DATABASE: A large group of data organized in a computer system. It allows you to search and find information easily.
  • DESKTOP: Everything that a user sees on a computer screen.
  • DESKTOP COMPUTER: A computer that is small enough to
...
Continue reading "Computer Terminology Glossary" »

Dijkstra's Algorithm in C: Code & Explanation

Computer science3.5 KB

Dijkstra's Algorithm in C

This code implements Dijkstra's algorithm to find the shortest path from a source vertex to all other vertices in a graph represented as an adjacency matrix. The program reads graph data from an input.txt file and writes the results to an output.txt file.

Code Implementation


#include <stdio.h>
#include <limits.h>
#include <stdbool.h>

#define MAX_VERTICES 100

// Function to find the vertex with minimum distance
int minDistance(int dist[], bool visited[], int vertices) {
    int min = INT_MAX, min_index;

    for (int v = 0; v < vertices; v++)
        if (!visited[v] && dist[v] <= min) {
            min = dist[v];
            min_index = v;
        }

    return min_index;
}

// Dijkstra'
...
Continue reading "Dijkstra's Algorithm in C: Code & Explanation" »

Thread Synchronization, Priority Inversion, and CPU Efficiency

Computer science2.18 KB

Can the Priority Inversion Problem Happen with User-Level Threads?

The priority inversion problem occurs when a low-priority process is in its critical region and suddenly a high-priority process becomes ready and is scheduled. With user-level threads, it cannot happen that a low-priority thread is suddenly preempted to allow a high-priority thread to run. There is no preemption. With kernel-level threads, this problem can arise.

Does Round-Robin Scheduling Resolve Priority Inversion?

Round-robin scheduling can resolve the issue. Sooner or later, the low-priority process will run and eventually leave its critical region. With priority scheduling, the low-priority process never gets to run at all; with round-robin, it gets a normal time slice periodically,...

Continue reading "Thread Synchronization, Priority Inversion, and CPU Efficiency" »

Operating System Concepts: Process, Memory, and Disk Management

Computer science64.1 KB

Primary Functions of an Operating System

An operating system (OS) is system software that acts as an interface between the user and the computer hardware. Its primary functions are:

  • Process Management: Creation, scheduling, and termination of processes.
  • Memory Management: Allocation and deallocation of memory.
  • File Management: Organization, storage, and retrieval of files.
  • Device/I-O Management: Controls peripheral devices.
  • Security & Protection: Prevents unauthorized access.

What Is a Batch Processing System?

  • A batch operating system groups similar jobs (with the same requirements) together and executes them as a single batch without user interaction.
  • A resident monitor reads jobs sequentially from input and submits them to the CPU.
  • Advantage: Less
...
Continue reading "Operating System Concepts: Process, Memory, and Disk Management" »

Python Programming Basics: Essential Code Snippets

Computer science4.07 KB

Python Fundamentals: Practical Code Examples

This document presents a collection of basic Python code snippets, demonstrating fundamental programming concepts such as conditional statements, loops, data input, and list manipulation. Each example is designed to illustrate a specific programming principle, making it ideal for beginners learning Python.

Compare Car Top Speeds with Python

This Python script compares two user-entered car speeds to determine which is faster, showcasing basic input and conditional logic.

car_a = int(input("Please enter the top speed of a Ferrari: "))
car_b = int(input("Please enter the top speed of a Lamborghini: "))

if car_a >= car_b:
    print("The fastest car is a Ferrari.")
elif car_b > car_a:
    print("The
...
Continue reading "Python Programming Basics: Essential Code Snippets" »

CPU Terminals, Buses, and Instruction Execution Cycle

Computer science3.92 KB

CPU Terminals and Bus Interconnection

The terminals (pins) of a Central Processing Unit (CPU) are typically divided into three main types: Address, Data, and Control.

These terminals are connected to similar terminals on memory chips and Input/Output (I/O) devices. This interconnection is collectively known as the bus system.

Communication between the CPU, memory, and I/O devices is effective through both transmitting and receiving signals at these terminals.

Key Bus Parameters

The functionality of the bus system is defined by three basic parameters:

  • Address Lines: A chip that has m address lines can address up to 2m memory locations.
  • Data Lines: A chip that has n data lines can write or read a word of n bits in a single operation.
  • Control Lines: These
...
Continue reading "CPU Terminals, Buses, and Instruction Execution Cycle" »

Computer Memory Systems and I/O Device Management

Computer science12.61 KB

🧠 Computer Memory Systems

Computer memory is essential for storing data and instructions. It is measured and organized using specific terminologies and a hierarchical structure.

1. Fundamental Memory Concepts

A. Basic Units of Data Storage

The smallest addressable units of data in a computer are based on the binary system:

UnitSizeDescription
Bit (Binary Digit)1The smallest unit of data, represented as either a 0 or a 1.
Nibble4 bitsHalf of a byte; often corresponds to a single hexadecimal digit.
Byte8 bitsThe fundamental unit of data storage; typically represents a single character (e.g., 'A', '7', '$').
WordVaries (16, 32, 64 bits)The natural unit of data used by a specific CPU design (its register size and bus width).

B. Storage Locations and Addresses

  • Storage
...
Continue reading "Computer Memory Systems and I/O Device Management" »

Concurrency Control and ER Model in Database Systems

Computer science2.2 KB

Concurrency Control in RDBMS

What are Transactions?

Transactions are sets of operations (like reading or writing data) treated as a single unit. Think of transferring money: multiple steps must happen together.

Isolation Levels

RDBMS uses isolation levels to manage how transactions interact:

  • Read Uncommitted: Transactions see changes before they're finalized, which is risky due to potential inaccuracies.
  • Read Committed: Transactions only see finalized changes, safer but still prone to inconsistencies.
  • Repeatable Read: Data remains unchanged during a transaction, preventing some issues.
  • Serializable: Transactions run sequentially, avoiding all problems but potentially slowing performance.

Concurrency Control Techniques

Techniques like locking data, timestamps,...

Continue reading "Concurrency Control and ER Model in Database Systems" »

Comprehensive Guide to HTML Headings: Types, Usage, and SEO Optimization

Computer science2.25 KB

Types of HTML Headings

HTML headings are classified into six levels, ranging from <h1> to <h6>, with <h1> representing the most important heading and <h6> the least important.

Usage of HTML Headings

Headings play a crucial role in structuring your web content and enhancing its readability. They help:

  • Organize content: Headings divide your content into logical sections, making it easier for users to navigate and understand.
  • Establish hierarchy: The different heading levels create a visual hierarchy, indicating the relative importance of each section.
  • Improve accessibility: Headings provide context and structure for screen readers, assisting users with disabilities.

SEO Optimization of HTML Headings

Headings are significant for...

Continue reading "Comprehensive Guide to HTML Headings: Types, Usage, and SEO Optimization" »