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

Sort by
Subject
Level

Introduction to Computer Systems and Assembly Language Programming

Classified in Computers

Written on in English with a size of 7.29 KB

Computer System

Components:

  • CPU
  • Memory (ROM/RAM)
  • I/O unit

BCD (Binary-Coded Decimal)

  • Add 0110 to the result if it falls between 1010 and 1111.

Overflow

  • Occurs when both numbers being added are positive or negative, and the result exceeds the maximum representable value.

IEEE-754 Standard

  • 32 bits: 1 sign bit, 8 exponent bits, 23 mantissa bits
  • NAN (Not a Number): Represents an error, exponent with all 1s and a sign bit of 0.
  • Always add trailing zeros to complete the required number of bits.

Decoder

  • Converts input to output using 2^n AND gates.

Memory

  • Components: Address, data, enable, read, write

Control Unit

  • Hardware instruction logic
  • Decodes and monitors the execution of instructions.

ALU (Arithmetic Logic Unit)

  • Performs numerical and logical evaluations.
  • Receives
... Continue reading "Introduction to Computer Systems and Assembly Language Programming" »

C# Currency Persistence Class Implementation

Classified in Computers

Written on in English with a size of 3.25 KB

Namespace Pers
{
    public class Persistencia
    {
        

Method: Add Currency (AniadirDivisa)

Adds a currency and its value to Divisas.txt if it does not already exist.

public static void AniadirDivisa(String d, double valor)
{
    if (!ExisteDivisa(d))
    {
        StreamWriter sw = new StreamWriter(@"Divisas.txt", true);
        sw.WriteLine(d + "\t" + valor);
        sw.Close();
    }
}

Method: Get Currency Value (ValorDivisa)

Retrieves the value associated with a specific currency symbol.

public static double ValorDivisa(String d)
{
    String v = "";
    StreamReader sr = new StreamReader(@"Divisas.txt");
    String l = sr.ReadLine();
    while (l != null)
    {
        if (l.Contains(d))
        {
            // Extracts the value
... Continue reading "C# Currency Persistence Class Implementation" »

Core Principles of Object-Oriented Programming

Classified in Computers

Written on in English with a size of 921 bytes

Abstraction

  • Application Analysis: The class or object model extracts the essential features of a real-world class or object.
  • Software Design: The public interface supports a simple logical model, while implementation complexity remains hidden from the client view.

Modularity

  • Application Analysis: Objects provide a more expressive and fine-grained structuring capability than decomposition by processing activity alone.
  • Software Design: Objects are information clusters that can be declared as often and wherever needed.

Encapsulation

  • Classes build “firewalls” around objects, forcing all access through public interfaces and preventing access to private implementation.
  • Objects intercept errors before they propagate outward throughout the system.

Assembly Language Instructions and MS-DOS Functions

Classified in Computers

Written on in English with a size of 3.39 KB

Data Transfer Instruction:

LEA

Gets source effective address and stores it in the target. Source segment address is stored in DS. Example: LEA DX, OPERANDO1

Control Transfer Instructions

Loops

Operation (IP decrement) + Conditional jump on operation result.

Example:

MOV CX, 4
Bucle:
  INC BX
  ADD BX, CX
  LOOP Bucle

Compare Instruction:

CMP

Compares source and target operands and properly modifies the flag register. It internally works by subtracting the target from the source operand. Operands are equal if the result is zero. Source is greater than target if the result is negative. Target is greater than source otherwise. Example: CMP AX, DX; Compares AX and DX.

Interrupt Instructions:

INT

INT jumps to a specified interrupt address. i8086 interrupt addresses... Continue reading "Assembly Language Instructions and MS-DOS Functions" »

Essential Java Design Patterns: Implementation Examples

Classified in Computers

Written on in English with a size of 2.99 KB

Memento Pattern

The Memento pattern allows you to capture and externalize an object's internal state so that the object can be restored to this state later.

public class MementoDemo {
    public static void main(String[] args) {
        Caretaker caretaker = new Caretaker();
        Originator originator = new Originator();
        originator.setState("State1");
        caretaker.addMemento(originator.save());
        originator.restore(caretaker.getMemento());
    }
}

Composite Pattern

The Composite pattern is used to compose objects into tree structures to represent part-whole hierarchies.

public class CompositeDemo {
    public static void main(String[] args) {
        Box root = initialize();
        int[] levels = new int[args.length];
... Continue reading "Essential Java Design Patterns: Implementation Examples" »

Key Concepts in IT: Client Facilities, XML, and Security

Classified in Computers

Written on in English with a size of 3.59 KB

Client Facilities

Client Facilities: Performance, ensure integrity, updates, risk confidential. Static pages, forms, active content, plugins, stand-alone applications.

XML

XML (Extensible Markup Language): Preferred form for B2B and internal documents with legal effect. Key benefits: non-proprietary, platform independent, HTTP compatibility, international support, extensible, self-defining, common tools, and transformation. Complementary techniques: UDDI (Universal Description, Discovery, and Integration), WSDL (Web Services Description Language) – web service design. Signatures have legal effect.

Components

Components: Good because turn-key systems tend to be too large and inflexible. Advantages: higher quality and design, maintenance shared,... Continue reading "Key Concepts in IT: Client Facilities, XML, and Security" »

Java Programs: Character Frequency, Inheritance, Palindrome, Matrix Multiplication & Polymorphism

Classified in Computers

Written on in English with a size of 5.03 KB

Character Frequency

FREQUENCY

import java.util.Scanner;
class Test2 {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
System.out.print("ENTER THE STRING:");
String abc = s.nextLine();
System.out.println("Enter The Character for checking:");
char ch = s.nextLine().charAt(0);
int count = 0;
for(int i = 0; i < abc.length(); i++) {
if(ch == abc.charAt(i)) {
count++;
}
}
System.out.println("The given character repeats " + count + " times");
} }

OUTPUT

ENTER THE STRING: MALAYALAM
Enter The Character for checking:
M
The given character repeats 2 times

Inheritance Example

import java.util.Scanner;
class Employee {
String name = "Name";
String address = "Address";
int age = 23, phn_no = 123456789, salary = 500000;
void printsalary() {
System.out.println(

... Continue reading "Java Programs: Character Frequency, Inheritance, Palindrome, Matrix Multiplication & Polymorphism" »

Fundamental Sorting and Searching Algorithms in C Language

Classified in Computers

Written on in English with a size of 4.07 KB

This document provides essential C language implementations for several fundamental sorting and searching algorithms. These examples are crucial for understanding basic data manipulation techniques in computer science.

QuickSort Implementation (Non-Standard Partition)

The following function, quick, attempts to implement a recursive sorting mechanism, often associated with QuickSort. Note that the partitioning logic here uses an insertion-like approach to place elements smaller than the pivot (pivo) before it.

void quick(int vet[], int esq, int dir){
    int pivo = esq, i,ch,j;         
    for(i=esq+1;i<=dir;i++){        
        j = i;                      
        if(vet[j] < vet[pivo]){     
            ch = vet[j];
... Continue reading "Fundamental Sorting and Searching Algorithms in C Language" »

Computer Science: Algorithms, Complexity, and Pioneers

Classified in Computers

Written on in English with a size of 4.6 KB

Algorithm Complexity

  • O(1): Parity Check
  • O(log n): Binary Search
  • O(n): Sequential Search
  • O(n log n): QuickSort
  • O(n2): Bubble Sort

Computer Science Fields

Theoretical Computer Science

  • Mathematical Logic
  • Automata Theory
  • Computability
  • Computational Complexity
  • Cryptography
  • Combinatorial Optimization

Practical Computer Science

  • Artificial Intelligence
  • Computer Architecture
  • Computer Graphics
  • Databases
  • Software Engineering
  • Distributed Systems
  • Computer Security
  • Human-Computer Interaction

Turing Machine Elements

  • Possible States
  • Initial State
  • Final State
  • Current State
  • Finite Set of Symbols
  • Input Symbols

Abstract Machines

Theoretical models for analyzing computability and algorithm complexity. Includes Automata and State Machines.

Deterministic Turing Machine (DTM)

For each state, there... Continue reading "Computer Science: Algorithms, Complexity, and Pioneers" »

Python Functions and Errors: Time, Triangle, Bonus, and Digits

Classified in Computers

Written on in English with a size of 4.09 KB

TIME DIFFERENCE

def time_difference(time1, time2):
time1=time_to_seconds(time1)
time2=time_to_seconds(time2)
diffinsecond=time2-time1
hours=diffinsecond//3600
minutes=(diffinsecond-(hours*3600))//60
seconds=diffinsecond-(hours*3600)-(minutes*60)
return(make_time_string(hours,minutes,seconds))

# Predefined helper functions. Do not edit them.
def time_to_seconds(time):

x = list(map(int, time.split(":"))
return x[0] * 3600 + x[1]*60 + x[2]

def make_time_string(hours, mins, seconds):
return "{:02d}:{:02d}:{:02d}".format(hours, mins, seconds)

TYPE OF TRIANGLE

def triangle(side1, side2, side3):
if side1+side2<>
return "Not a triangle"
elif side1==side2 and side2==side3:
return "Equilateral"
elif... Continue reading "Python Functions and Errors: Time, Triangle, Bonus, and Digits" »