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

Understanding Assembly Language: Instructions and Assemblers

Computer science2.8 KB

Understanding Assembly Language

Assembly language is a low-level programming language where instructions are written using mnemonic codes rather than binary machine language. An assembler translates these instructions into executable machine code.

Classification of Assembly Instructions

Assembly language instructions are categorized into three primary types:

  • Imperative Statements (IS): Specify operations for the processor to perform. These generate executable machine code. Examples include: STOP, ADD, SUB, MULT, MOVER, MOVEM, COMP, BC, DIV, READ, and PRINT.
  • Declarative Statements (DL): Used for memory allocation and data definition. DS (Define Storage) reserves memory locations, while DC (Define Constant) stores a constant value in memory.
  • Assembler
...
Continue reading "Understanding Assembly Language: Instructions and Assemblers" »

OWASP & Cybersecurity Essentials: Threats, Tools, and Defenses

Computer science15.3 KB

The Open Web Application Security Project (OWASP)

The Open Web Application Security Project (OWASP) is a non-profit foundation providing guidance on developing, purchasing, and maintaining trustworthy and secure software applications. It's an online community that produces free articles, methodologies, documentation, tools, and technologies in IoT, system software, and web application security.

Key Aspects of OWASP

  • Origin: Started by Mark Curphey on September 9, 2001.
  • Leadership: Jeff Williams was the volunteer Chair from late 2003 to September 2011. As of 2015, Matt Konda chaired the Board. Bill Corry was an OWASP Foundation Global Board of Directors officer in February 2023.
  • Goal: To provide tools, resources, and guidelines to developers, businesses,
...
Continue reading "OWASP & Cybersecurity Essentials: Threats, Tools, and Defenses" »

Fundamental Computer Architecture Concepts

Computer science5.63 KB

Common Bus System Explained

The common bus system is an architecture where a single bus is used for communication between various components of a computer, such as memory, registers, and the ALU. This system minimizes the number of pathways required, thereby simplifying the design and saving space.

Components of a Common Bus System:

  • Set of Registers (R1, R2, ...)
  • Arithmetic Logic Unit (ALU)
  • Control Unit
  • Common Bus
  • Memory Unit

Operation of a Common Bus System:

  • Only one register can place its contents on the bus at a time.
  • A control unit uses selection lines and control signals to manage data transfers.
  • A multiplexer selects which register’s data will go onto the bus.
  • A decoder selects the destination register to receive the data.

Advantages:

  • Reduces hardware
...
Continue reading "Fundamental Computer Architecture Concepts" »

Automated Fact-Checking of Text Summaries for Relational Databases

Computer science4.06 KB

Verifying Text Summaries of Relational Data Sets

• Relational data is often summarized by text.
• The focus of this paper is the problem of verifying, in an automated fashion, whether text claims are consistent with the actual database.
• The authors proposed a tool for verifying text summaries of relational data sets, which works similarly to a spell checker and marks up claims that are believed to be erroneous.
• The system converts claims into SQL queries and then evaluates them.
• The main problem is converting natural language claims to SQL queries.
• The tool is called AggChecker.

AggChecker

• AggChecker consists of two parts: a relational data set and a text document.
• The text contains claims about the data.
• The goal is to
...
Continue reading "Automated Fact-Checking of Text Summaries for Relational Databases" »

Java Sudoku Solver: Backtracking Algorithm Implementation

Computer science5.57 KB

Building a Sudoku Solver in Java with Backtracking

This document presents a Java implementation of a Sudoku solver, utilizing a classic backtracking algorithm. The code demonstrates how to represent a Sudoku board, check for valid moves, and recursively find a solution to the puzzle.

Initial Sudoku Puzzle Setup

The Sudoku board is represented as a 2D integer array. A value of 0 indicates an empty cell that needs to be filled.

int[][] board = {
  { 8, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 3, 6, 0, 0, 0, 0, 0 },
  { 0, 7, 0, 0, 9, 0, 2, 0, 0 },
  { 0, 5, 0, 0, 0, 7, 0, 0, 0 },
  { 0, 0, 0, 0, 4, 5, 7, 0, 0 },
  { 0, 0, 0, 1, 0, 0, 0, 3, 0 },
  { 0, 0, 1, 0, 0, 0, 0, 6, 8 },
  { 0, 0, 8, 5, 0, 0, 0, 1, 0 },
  { 0, 9, 0, 0, 0, 0, 4, 0, 0 }
};

Implementing

...
Continue reading "Java Sudoku Solver: Backtracking Algorithm Implementation" »

Functions, Arguments, and Recursion in Programming

Computer science4.58 KB

Functions and Arguments

A function is a module of program code that takes input (arguments) and produces output (a return value).

  • Arguments allow us to customize the operation performed by the function.
  • The return value is often the result of executing the code.
  • Calling a function causes the code in a function to execute. If called again, it will execute again.

To document a function, use a multi-line comment immediately after the def line.

Local Variables

Local variables are variables used inside functions.

  • They are accessible/usable within that function only.
  • This refers to the variable's scope.

Global Variables

Global variables are variables used outside of a function.

  • Global variables' scope includes both inside and outside of functions.
  • However, since
...
Continue reading "Functions, Arguments, and Recursion in Programming" »

Alpha Vantage API Integration for Stock Market Data

Computer science3.22 KB

Stock Market Data Integration

Listar

Stock Data Table Headers

OPENHIGHLOWCLOSEVOLUME

Alpha Vantage API Implementation

The following script utilizes jQuery AJAX to fetch real-time stock data for MSFT from the Alpha Vantage API.


function main() {
    $("#list").click(function() {
        $.ajax({
            type: "GET",
            url: "https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=1min&apikey=demo",
            success: function (azul) {
                var roxo = azul["Time Series (1min)"];
                for (var verde in roxo) {
                    var vermelho = roxo[verde];
                    var str = "<tr><td>" + vermelho["1. open"] + "</td>"
...
Continue reading "Alpha Vantage API Integration for Stock Market Data" »

C++ Cheat Sheet: Structs, Classes, Pointers, Arrays, and More

Computer science6.65 KB


```c++
    //input 
    int main(int argc, char * argv[]){ // or char ** argv
        const char* strs[] = {"Hello", "World!"};
        const char str[] = {"Hello"};
        const int arr[] = {1,2,3};
        std::cout << *strs<< std::endl;
        std::cout << str << std::endl;
        std::cout << arr << std::endl;
        std::cout << *arr << std::endl;
        std::cout << *str << std::endl;
        std::cout << *(strs + 1)<
    } 
    //output
    Hello
    Hello
    0x77d02fb38050
    1
    H
    World!
    void insert(int array[], int size, int item, int num_copies){
    for(int * i = array; i < array + size - num_copies;
...
Continue reading "C++ Cheat Sheet: Structs, Classes, Pointers, Arrays, and More" »

Deadlock and Semaphores: Concurrency in Operating Systems

Computer science2.21 KB

Understanding Deadlock

A deadlock is a critical situation in which two or more computer programs, sharing the same resource, effectively prevent each other from accessing that resource. This results in both programs ceasing to function or becoming unresponsive.

Historically, the earliest computer operating systems ran only one program at a time, making all system resources available to that single program. As operating systems evolved to run multiple programs concurrently through interleaving, programs initially had to specify their resource needs in advance to avoid conflicts.

The advent of dynamic resource allocation, where programs could request further resources after execution began, introduced the problem of deadlocks. Addressing deadlocks...

Continue reading "Deadlock and Semaphores: Concurrency in Operating Systems" »

IPv6 Packet Structure: Base Header and Extension Headers

Computer science2.54 KB

IPv6 Packet Format: Base Header

Each IPv6 packet consists of a mandatory base header followed by the payload. The payload is made up of two parts: optional extension headers and the upper-layer data. The base header is 40 bytes long, whereas the extension headers and the data from the upper layer can contain up to 65,535 bytes of information.

The base header has 8 fields:

  • Version: A 4-bit field that defines the version of IP, such as IPv4 or IPv6. For IPv6, the value of this field is 6.
  • Priority: A 4-bit field that defines the priority of the packet, which is important in connection with traffic congestion.
  • Flow Label: A 24-bit field designed for providing special handling for a particular flow of data.
  • Payload Length: A 2-byte field used to define
...
Continue reading "IPv6 Packet Structure: Base Header and Extension Headers" »