Notes, summaries, assignments, exams, and exercises for Computer science for Other courses

Design Pattern Classification and Implementation Strategy

Computer science4.06 KB

Ideal Steps for Design Pattern Utilization

The following steps outline the ideal process for effectively using design patterns:

  1. (P1) Define Criteria: Define criteria for the organization of patterns.
  2. (P2) Assemble Catalog: Assemble a catalog of patterns that will facilitate the search for suitable standards.
  3. (P3) Generalize Patterns: Generalize the selected patterns for independence from specific methods or private models.
  4. (P4) Develop Pattern Language: Develop a pattern language that reflects the natural relationships among elements, leading the designer from general patterns to more specific ones.

Benefits of Indexed Patterns

Patterns indexed by criteria allow for the simple search of a solution to a specific problem.

Criteria for Pattern Classification

Patterns...

Continue reading "Design Pattern Classification and Implementation Strategy" »

Python String Methods and Character Functions

Computer science4.03 KB

Explain 1. ord() and chr(), 2. in and not in Operators

1. ord() and chr() Functions

Python provides the ord() and chr() functions for converting between characters and their Unicode values.

  • ord() converts a character into its corresponding Unicode (ASCII) integer value.
  • chr() converts a Unicode integer value into its corresponding character.

These functions are useful in character manipulation, encoding, encryption, and text processing applications.

Example

print(ord('A'))
print(ord('a'))
print(chr(65))
print(chr(97))

Output

65
97
A
a

2. in and not in Operators on Strings

The in and not in operators are called membership operators in Python. They are used to check whether a character, word, or substring exists in a string.

  • in returns True if the specified value
...
Continue reading "Python String Methods and Character Functions" »

Theory of Computation: Solved Questions on Automata

Computer science9.55 KB

DFA vs NFA: Key Differences

Deterministic Finite Automata (DFA) vs Nondeterministic Finite Automata (NFA):

Deterministic Finite Automata (DFA)

  • For each input symbol, only one transition is possible.
  • No ε (epsilon) transitions are allowed.
  • The transition function gives exactly one next state.
  • Easier to implement in code.

Nondeterministic Finite Automata (NFA)

  • For one input symbol, multiple transitions may be possible.
  • ε-transitions may exist.
  • The transition function gives zero, one, or many next states.
  • Easier to design.

Pumping Lemma for Regular Languages

Statement

If L is a regular language, then there exists a pumping length p such that any string w in L with |w| ≥ p can be written as:

w = xyz

such that:

  1. |xy| ≤ p
  2. |y| > 0
  3. xynz ∈ L for all n ≥ 0

Primary

...
Continue reading "Theory of Computation: Solved Questions on Automata" »

Mastering Python String Methods and Syntax

Computer science2.83 KB

Case Manipulation Methods

  • title(): Displays each word in a string in Title Case, where every word begins with a capital letter.
  • upper(): Converts every character in a string to all uppercase letters.
  • lower(): Converts every character in a string to all lowercase letters. This is particularly useful for normalizing user input before storing it.

Whitespace Stripping Methods

Python considers whitespace (tabs, spaces, etc.) significant. Use these methods to clean up extra spacing:

  • rstrip(): Removes whitespace from the right side (end) of a string.
  • lstrip(): Removes whitespace from the left side (beginning) of a string.
  • strip(): Removes whitespace from both the beginning and the end of a string simultaneously.

Related Data Type Conversion

  • str(): While not
...
Continue reading "Mastering Python String Methods and Syntax" »

ICT Exam Solutions and Technical Concepts

Computer science3.53 KB

1. Hardware and Spreadsheet Fundamentals

1(a) Input and Output Devices

  • 1(a)(i) Output
  • 1(a)(ii) Input
  • 1(a)(iii) Input
  • 1(a)(iv) Output
  • 1(a)(v) Input

1(b) Network Types and Components

  • 1(b)(i) LAN
  • 1(b)(ii) MAN
  • 1(b)(iii) WAN

Wireless Networking

  • Component: Wireless NIC, Wi-Fi adapter
  • Reason: Connects device to wireless network without cables

1(c) Spreadsheet Operations

  • 1(c)(i) =C2*D2
  • 1(c)(ii) Average item cost: C8; Grand total: E8
  • 1(c)(iii) =AVERAGE(C2:C7)
  • 1(c)(iv) Stock ID: Text; Total Value: Currency
  • 1(c)(v) Dinghy, Fender

2. Data Processing and Validation

2(a) Data Entry Devices

  • 2(a)(i) MICR
  • 2(a)(ii) Sensor
  • 2(a)(iii) OMR
  • 2(a)(iv) OCR

2(b) Validation Checks

  • 2(b)(i) Presence check
  • 2(b)(ii) Range check
  • 2(b)(iii) Format check

2(c) Database Concepts

  • 2(c)(i) Boolean: Stores only
...
Continue reading "ICT Exam Solutions and Technical Concepts" »

Client-Server Architecture and Java Network Programming

Computer science109.83 KB

Understanding the Client-Server Software Model

The client-server model is a distributed application structure that partitions tasks or workloads between providers of a resource or service, called servers, and service requesters, called clients.

Core Components: Server and Client

  • Server: A server is a powerful computer or process that hosts, manages, and provides resources, data, services, or programs to other computers (clients) over a network. Its primary characteristics are that it is always on, waiting for requests, and is designed to handle multiple clients simultaneously. Examples include web servers, file servers, and database servers.
  • Client: A client is a computer or software that accesses a service made available by a server. The client
...
Continue reading "Client-Server Architecture and Java Network Programming" »

Blockchain Technology: Core Concepts and Mechanics

Computer science174.76 KB

What is Blockchain?

Blockchain is a decentralized, distributed digital ledger that records transactions in a secure, immutable, and chronological order without a central authority.

Key Characteristics

  • Decentralized: No central control.
  • Immutable: Data cannot be changed.
  • Transparent: Shared ledger.
  • Secure: Uses cryptographic hashing.

How Blockchain Works

  1. A user initiates a transaction.
  2. The transaction is broadcast to a peer-to-peer network.
  3. Nodes validate the transaction using consensus algorithms.
  4. Valid transactions are grouped into a block.
  5. The block is hashed and includes the previous block's hash.
  6. The block is added to the blockchain.
  7. The ledger is updated across all nodes.

Types of Blockchain

  1. Public Blockchain: Open to anyone to join and participate. Fully
...
Continue reading "Blockchain Technology: Core Concepts and Mechanics" »

Java Producer-Consumer Pattern Implementation

Computer science2.28 KB

Java Producer-Consumer Implementation

class ObjCompartido {
    private int longArray;
    private ArrayList<Object> array = new ArrayList<>();

    public ObjCompartido(int longArray) {
        this.longArray = longArray;
    }

    public synchronized void producir(Object xxx) {
        while (this.array.size() == longArray) {
            try {
                System.out.println("ESPERANDO");
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        this.array.add(xxx);
        System.out.println("AÑADIDO");
        notifyAll();
    }

    public synchronized void consumir(Object xxx) {
        while (this.array.isEmpty()) {
            try {
...
Continue reading "Java Producer-Consumer Pattern Implementation" »

Splunk SPL Mastery: Essential Commands and Data Modeling

Computer science4.02 KB

Aggregation and Charting Commands

  • Stats vs. Eventstats vs. Streamstats: stats collapses events for aggregation; eventstats retains events for per-event comparison; streamstats performs rolling, order-sensitive calculations.
  • Chart vs. Timechart: Use chart for non-time data with over/by; use fillnull to handle gaps. timechart bins _time automatically; define intervals using span=12h. Note: chart count over X by Y differs from chart count by X,Y.

Data Manipulation and Filtering

  • Eval: Use tostring(field, "duration") for numeric time formatting; case() for multi-condition logic; and coalesce(field1, field2, …) to prevent null values.
  • Where vs. Search: where is a post-pipe, type-sensitive command. Strings treated as numbers result in nulls; cast using
...
Continue reading "Splunk SPL Mastery: Essential Commands and Data Modeling" »

Parallel Computing Architectures and Systems Explained

Computer science211.7 KB

Vector Processors: Characteristics

A vector processor is a computer system designed to perform operations on entire arrays (vectors) of data simultaneously instead of processing one element at a time. They are highly efficient when the same operation is performed repeatedly on large data sets.

Key Characteristics

  • Vector Registers: Capable of holding a complete vector of operands; supports simultaneous operations on all stored elements.
  • Vectorized and Pipelined Functional Units: Perform the same operation (e.g., addition) on all elements of a vector or between pairs of elements from two vectors in a SIMD fashion.
  • Vector Instructions: Operate on entire vectors, not just scalars. One instruction handles an entire block of elements, improving performance
...
Continue reading "Parallel Computing Architectures and Systems Explained" »