Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

Polynomial-Time Reductions for NP-Complete Problems

Classified in Computers

Written on in English with a size of 3.67 KB

1. Independent Set to Vertex Cover Reduction

Input

A graph G and an integer k.

Reduction Steps

  1. Call the black-box for Vertex Cover with the input graph G.
  2. Provide n-k as the target size, where n is the number of nodes in G.
  3. Return the result ('yes' or 'no') from the black-box call.

2. SAT to Independent Set Reduction

Input

A CNF formula F.

Reduction Steps

  1. Construct a graph G where the nodes of G are the literals occurring in F (with possible repetitions).
  2. Add the following edges to G:
    • An edge joining every pair of complementary literals.
    • An edge joining any two literals that occur in the same clause.
  3. Call the black-box for Independent Set with input graph G and an integer k, where k is the number of clauses in F.
  4. Return the result ('yes' or 'no') from the
... Continue reading "Polynomial-Time Reductions for NP-Complete Problems" »

Jacobi Method Implementation in Fortran

Classified in Computers

Written on in English with a size of 3.12 KB

This section details the implementation of the Jacobi method in Fortran for solving a system of linear equations. The subroutine solucion_Jacobi takes a matrix A, a vector b, and an initial guess X as input, and returns the solution vector X.

Subroutine: solucion_Jacobi(A, b, X)

The subroutine begins with the following declarations and initializations:

  • use normas
  • integer, parameter :: Kx = 100
  • real(8), parameter :: tolerancia = 1E-6
  • real(8), allocatable :: X0(:), ERROR(:)
  • real(8), intent(in) :: A(:,:), b(:)
  • real(8), allocatable, intent(out) :: X(:)
  • integer :: i, j, k, n
  • real(8) :: sum, zero, ek

Where:

  • Kx is the maximum number of iterations.
  • tolerancia is the error tolerance.
  • X0 is the previous iteration's solution vector.
  • ERROR is the error vector.
  • A is the
... Continue reading "Jacobi Method Implementation in Fortran" »

Understanding Binary Conversion and Computer Performance

Classified in Computers

Written on in English with a size of 3.88 KB

Binary Conversion

Single-Precision Floating-Point

Format: 1 sign bit, 8 exponent bits, 23 fraction bits

Bias: +127 (decimal to binary), -127 (binary to decimal)

Double-Precision Floating-Point

Format: 1 sign bit, 11 exponent bits, 52 fraction bits

Bias: +1023 (decimal to binary), -1023 (binary to decimal)

Example: -17.6875 (Single-Precision)

  1. Sign Bit: + = 0, - = 1 (In this case, 1)
  2. Integer Part to Binary: Repeatedly divide the integer part by 2 and record the remainders.
  3. Fractional Part to Binary: Repeatedly multiply the fractional part by 2 and record the integer parts.
  4. Combine and Normalize: Combine the binary integer and fractional parts. Normalize to the form 1.xxx * 2^exponent.
  5. Calculate Exponent: Add the bias to the exponent.
DivideAnswerRemainder
17
... Continue reading "Understanding Binary Conversion and Computer Performance" »

Routing Protocols: RIP, OSPF, BGP, CSMA/CD, CSMA/CA

Classified in Computers

Written on in English with a size of 4.41 KB

Intra-AS Routing

RIP – Based on Distance-Vector (D-V), fewer messages, converges slower, smaller size.

OSPF – Based on Link-State (L-S), converges faster, more messages, larger networks.

Distance-Vector is distributed, and each router only knows the costs to its neighbors and their distance vectors.

Link state is global and requires that each router knows the network topology and link costs to all nodes.

OSPF: Used internally inside a network, an intra-network/domain protocol used in an AS.

BGP: An internetwork protocol used between two different ASs, used at the edge of your network to connect your network to the internet.

RIP: An intra-network protocol used in an AS, used for small networks (maximum number of hops is 16).

EBGP: Runs between two... Continue reading "Routing Protocols: RIP, OSPF, BGP, CSMA/CD, CSMA/CA" »

Essential Tech Terms Defined

Classified in Computers

Written on in English with a size of 4.8 KB

  • Accuracy

    Tells us how correct a GPS measurement is.
  • Array

    A group of disk drives that are connected and used as a single unit.
  • Assembler

    A program that translates low-level programming language into machine code.
  • Attachment

    A file sent as part of an email.
  • Avatar

    An image in a computer game that represents a person.
  • Barcode

    An arrangement of lines and spaces that represent data.
  • Bit

    The smallest unit of computer data.
  • Bitrate

    A measurement of the amount of data that is processed.
  • Broadband

    A system that allows computers to transfer large amounts of information.
  • Calibration

    The act of adjusting printers and scanners to display colors correctly.
  • Capacity

    The amount of space an MP3 player has to store files.
  • Catalog

    An inventory of books in a library.
  • Cell phone

    A wireless
... Continue reading "Essential Tech Terms Defined" »

CSS Styling Techniques for Web Layouts

Classified in Computers

Written on in English with a size of 467 bytes

CSS Layout and Component Styling

Core Styles

This document defines the foundational CSS for a 960px container layout, including:

  • Form Elements: Styled inputs and textareas.
  • Buttons: Gradient-based call-to-action buttons.
  • Grid System: Three-column layout for social, contact, and updates.
  • Media: Rounded image styling for news sections.

Wireless Network Technology: Key Concepts and Security

Classified in Computers

Written on in English with a size of 3.85 KB

1. Why Can IEEE 802.11 Transmit Further Than Bluetooth?

IEEE 802.11 (Wi-Fi) has a higher power output than Bluetooth.

2. Three Advantages of Wireless Over Wired Technology

  • Anytime, anywhere connectivity
  • Easy and inexpensive to install
  • Ease of adding additional devices

3. Two Benefits of Wireless Networks Over Wired Networks

  • Mobility
  • Reduced installation time

4. Factors Affecting the Number of Access Points Needed

Three factors that affect the number of access points needed for wireless connectivity are:

  • The size of the building
  • The number of solid interior walls in the building
  • The presence of microwave ovens in various offices

5. Why is Security Important in Wireless Networks?

Security is crucial because wireless networks broadcast data over a medium that

... Continue reading "Wireless Network Technology: Key Concepts and Security" »

Integração SQL Server e C# com SqlClient e DataAdapter

Classified in Computers

Written on in English with a size of 4.68 KB

Criação da Tabela no SQL Server

No banco SQL Server, execute o seguinte script para criar a tabela de CNH:

CREATE TABLE [dbo].[CNH](
    [identificador] [int] IDENTITY(1,1) NOT NULL,
    [numero] [varchar](250) NULL,
    [dataEmissao] [datetime] NULL,
    [dataValidade] [datetime] NULL,
    [categoriaCNH] [varchar](2) NOT NULL,
    [pessoa] [int] NOT NULL,
    CONSTRAINT [PK_CNH] PRIMARY KEY CLUSTERED 
    (
        [identificador] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

Implementação do Código em C#

No código C#, utilize a classe SqlConnection para gerenciar as operações de banco de dados:

using System;
using System.Collections.
... Continue reading "Integração SQL Server e C# com SqlClient e DataAdapter" »

Prolog vs CLIPS: A Detailed Comparison with Examples

Classified in Computers

Written on in English with a size of 197.63 KB

Prolog vs. CLIPS: A Detailed Comparison

This document provides a comparison between Prolog and CLIPS, two popular languages used in artificial intelligence and expert systems development. We will explore their syntax, features, and applications through examples.

Facts and Rules

Prolog:

Facts:


father(tom, john).  % tom is father of john
mother(susan, john). % susan is mother of john
father(george, tom). % george is father of tom

Rules:


parent(X, Y) :- father(X, Y), mother(X, Y).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
grandfather(X, Z) :- father(X, Y), parent(Y, Z).
grandmother(X, Z) :- mother(X, Y), parent(Y, Z).

CLIPS:

Facts:


(deffacts families
  (father tom john) ; tom is father of john
  (mother susan john) ; susan is mother of
... Continue reading "Prolog vs CLIPS: A Detailed Comparison with Examples" »

Operating System Core Functions and Digital Signature Essentials

Classified in Computers

Written on in English with a size of 3.12 KB

Operating System Core Functions

A program in execution requires resources for its tasks. The Operating System (OS) is responsible for managing these resources through various core functions.

Process Management

The OS is responsible for:

  • Creating and destroying processes.
  • Pausing and resuming processes.
  • Providing mechanisms to communicate and synchronize processes.

Memory Management

Memory is a table of words, each referenced using a unique address. The OS is accountable for:

  • Knowing which parts of memory are used and by whom.
  • Deciding which processes are loaded into memory when space is available.
  • Assigning and reclaiming memory space when needed.

Secondary Storage Management

Secondary storage is necessary because main memory is volatile and often too small... Continue reading "Operating System Core Functions and Digital Signature Essentials" »