Notes, summaries, assignments, exams, and exercises for Computer science for Baccalaureate

Core Operating System Concepts: Processes, Shells, and Security

Computer science95.39 KB

Operations on a Process

  1. Process Creation: A user request or an already running process can create new processes. A parent process creates child processes using a system call, which, in turn, can create other processes, forming a tree of processes.
  2. Process Pre-emption: A process is pre-empted if an I/O event or timeout occurs. The process then moves from the running state to the ready state, and the CPU loads another process from the ready state to the running state, if available.
  3. Process Blocking: When a process requires an I/O event during its execution, it moves from the running state to the waiting state, and the CPU dispatches another process.
  4. Process Termination: A process is terminated when it completes its execution. Additionally, events
...
Continue reading "Core Operating System Concepts: Processes, Shells, and Security" »

Java Code Examples: Word Count, Fibonacci, Stack & Queue

Computer science6.62 KB

Class: CountOccurrenceOfWords

This class demonstrates how to count the occurrences of words in a given text string using a TreeMap to maintain sorted word counts.

public class CountOccurrenceOfWords {
    public static void main(String[] args) {
        // Set text in a string
        String text = "Good morning. Have a good class. " +
                      "Have a good visit. Have fun!";

        // Create a TreeMap to hold words as keys and counts as values
        Map<String, Integer> map = new TreeMap<>();

        String[] words = text.split("[ \n\t\r.,;:!?()]+");
        for (int i = 0; i < words.length; i++) {
            String key = words[i].toLowerCase();
            if (key.length() > 0) {
                if (!map.
...
Continue reading "Java Code Examples: Word Count, Fibonacci, Stack & Queue" »

Cybersecurity Fundamentals: Threats, CIA Triangle, and System Components

Computer science3.63 KB

Essential Concepts in Information Security

Threat vs. Threat Agent: Key Distinctions

The word “threat” usually stands for a category of things that pose a potential danger. Viruses, worms, and other types of malware, for example, are threats. A “threat agent,” by contrast, is a specific threat, or a specific type of virus, worm, or other malware. For example, the Blaster Worm is a threat agent.

Vulnerability vs. Exposure in Security Systems

Vulnerability is a fault within the system, such as software package flaws, unlocked doors, or an unprotected system port. It leaves things open to an attack or damage.

Exposure is a single instance when a system is open to damage. Vulnerabilities can in turn be the cause of exposure.

Infrastructure Protection

...
Continue reading "Cybersecurity Fundamentals: Threats, CIA Triangle, and System Components" »

How the World Wide Web Works: A Technical Breakdown

Computer science2.84 KB

How the World Wide Web Works

The World Wide Web is the most widely used part of the internet. When you browse the web, you view multimedia pages containing text, pictures, graphics, sounds, and videos. The web uses hypertext links to allow you to navigate from one place to another.

The web operates on a client/server model: client software (the web browser) runs on your computer, while server software runs on a web host.

To use the web, you need an internet connection and a web browser. You type the URL for the website you wish to visit, and your browser sends a request using the HTTP protocol. This is how the browser and server communicate. When the server finds the requested page, it sends it back to the browser.

How Web Pages Are Organized

The...

Continue reading "How the World Wide Web Works: A Technical Breakdown" »

Digital Audio Fundamentals: Capture, Playback, and Processing

Computer science3.85 KB

Audio editing is the process of manipulating and refining sound recordings. To understand this, it's essential to distinguish between analog and digital sound.

Analog vs. Digital Sound

Analog sound consists of continuous waves, while digital sound is represented by discrete values.

Analog Signals

Analog signals, which constitute analog sound, can take on all values of frequency and amplitude within a given range. They are continuous representations of sound waves.

Digital Signals

In contrast, digital signals, used for digital sound, take discrete values in both time and amplitude. For sound to be edited on a computer, it must first be digitized.

Digitizing Audio: Analog to Digital Conversion

The process of converting an analog signal into a digital...

Continue reading "Digital Audio Fundamentals: Capture, Playback, and Processing" »

Spreadsheet Software Functions and Disk Partitioning Concepts

Computer science3.8 KB

Software Applications and Data Handling

Spreadsheet Applications

Leaf is a software application that allows mathematical operations, working with numerical data, making complex calculations with formulas and functions, and generating graphs. In this unit, we will use the spreadsheet applications Excel and Calc.

Spreadsheet Errors

Spreadsheet errors do not tell us whether we made an error in an entry or operation. In Calc, error messages are available as codes. In Excel, the error messages are:

  • #####: The cell width cannot display content, or you have used a negative date or time.
  • #VALUE!: You have used an incorrect argument type or operation.
  • #NAME?: The text of the formula is not recognized.
  • #REF!: The cell reference is invalid.
  • #N/A: Not available
...
Continue reading "Spreadsheet Software Functions and Disk Partitioning Concepts" »

Duplicate Nodes Multiple of 5 in C Singly Linked List

Computer science4.29 KB

Duplicate Nodes Multiple of 5 in a Singly Linked List

Given a singly linked list whose nodes are defined as follows:
struct node {
int data;
struct node *next;
};
Perform a doubling-to-top: duplicate all nodes whose data are multiples of 5 and place those copies at the front of the list.
Example:
If the original list:
| -> | 2 | -> | 5 | -> | 3 | -> | 6 | -> | 10 | -> | 1 | -> | 5 | -> | X |
then the final list becomes:
| -> | 5 | -> | 10 | -> | 5 | -> | 2 | -> | 5 | -> | 3 | -> | 6 | -> | 10 | -> | 1 | -> | 5 | -> | X |

Fixed C implementation

The corrected and polished C implementation below initializes a list of N_NODOS nodes, prints the list, duplicates nodes whose values are multiples...

Continue reading "Duplicate Nodes Multiple of 5 in C Singly Linked List" »

Turing's Thesis: Computability and Algorithms

Computer science2.5 KB

Turing's Thesis and the Problem of Computability

Thesis 1

"Every problem that can be solved algorithmically can be solved by a Turing machine."

Concepts Associated with Thesis 1

  • Algorithm: A set of rules that can be mechanically applied to solve a problem of a given class. Mainly used in mathematical contexts.
  • Calculation: Any transaction which is carried out by manipulation of symbols as a means of representation. The symbolic operations are atomic, that is, quite simple, and are held in a computer. The action of the computer will depend on the symbols that have the system and the internal state in which the computer is.

Thesis 2

"Every computable function can be computed by a Turing machine. Every problem that can be solved by algorithmic methods

...
Continue reading "Turing's Thesis: Computability and Algorithms" »

Java Memory Management and Inheritance Principles

Computer science521.39 KB

Memory Management: Stack vs. Heap

The memory in Java is divided into two main areas:

  • Stack: Used for local primitive variables, local reference variables, and method calls.
  • Heap: Used for newly created objects.

Common Errors:

  • StackOverflowError: Occurs when the stack is overused.
  • OutOfMemoryError: Occurs when the heap is too full.

Access Control and Class Structure

Standard practices for class design include:

  • Public: Classes and constructors.
  • Private: Instance variables.
  • Public: Getters and setters to control access to class members.

Instance vs. Static:

  • Instance: Belongs to a particular object.
  • Static: Belongs to the class itself and is shared by all objects.

Variables and Data Types

Local variables must be initialized before use. When using arrays, they...

Continue reading "Java Memory Management and Inheritance Principles" »

Java Network Programming: Server Implementation Patterns

Computer science2.1 KB

Thread Pool Server Implementation

ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
try (ServerSocket serverSocket = new ServerSocket(4444)) {
    while (true) {
        System.out.println("\n Listening for a client connection");
        Socket socketForClient = serverSocket.accept();
        System.out.println("\n New connection accepted: " + socketForClient.getRemoteSocketAddress());
        WorkerThread task = new WorkerThread(socketForClient);
        System.out.println("Task created: " + task);
        executor.submit(task);
    }
}

public WorkerThread(Socket socketForClient) {
    this.socketForClient = socketForClient;
}

Network Programming MCQ Answers

  • Q4: The interest set defines what operations the
...
Continue reading "Java Network Programming: Server Implementation Patterns" »