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

Understanding Automata Theory and Formal Languages

Computer science2.86 KB

Nondeterministic Finite-State Machine

It is a set of states and sets of transitions from state to state that occur on input symbols taken from an alphabet.

Language

A language is a set of words (strings) of finite length formed from a finite alphabet.

Regular Expression

A way of representing regular languages using alphabet characters on which the language is defined.

Networking

This seems to be a misunderstanding or mislabeling in the original text. Based on the examples, it describes Concatenation.

Concatenation is the combination of characters or strings. For example:

  • 'z' concatenated with '132' = "Z132"
  • '456' concatenated with 'AB' = "456AB"
  • 'z' concatenated with 'A' = "ZA"

Alphabet

An alphabet is an ordered set of symbols for a language. It is the...

Continue reading "Understanding Automata Theory and Formal Languages" »

Data Link Layer Functions and Frame Structures

Computer science3.1 KB

Data Link Layer Frames

In the link layer, data is organized into units called frames. Each frame has a header, which includes an address and control information, and a tail that is used for error detection.

The header of a Local Area Network (LAN) contains the physical addresses of the source and destination. The header of a frame that is spread by a Wide Area Network (WAN) contains a circuit identifier in the direction field.

Remember that a link is a local area network, a peer-to-peer facility, or another wide-area facility by which systems can communicate using a data link layer protocol.

Core Functions of the Data Link Layer

The data link layer is responsible for the reliable transfer of information through a data transmission circuit. Data...

Continue reading "Data Link Layer Functions and Frame Structures" »

Java Backtracking Algorithms: Sudoku, Knapsack, and Tasks

Computer science2.25 KB

Sudoku Solver Implementation

private boolean isValid(int r, int c, int n) {
  boolean valid = true;
  int sr, sc, fr, fc;
  for (int i = 0; i < 9 && valid; i++) {
    if (i != r) if (grid[i][c] == n) valid = false;
    if (i != c) if (grid[r][i] == n) valid = false;
  }
  if (valid) {
    sr = (r / 3) * 3; fr = sr + 3; sc = (c / 3) * 3; fc = sc + 3;
    for (int i = sr; i < fr && valid; i++) {
      for (int j = sc; j < fc && valid; j++) {
        if (grid[i][j] == n) valid = false;
      }
    }
  }
  return valid;
}

private boolean solveRec(int row, int col) {
  boolean solved = false;
  if (row == 9) solved = true;
  else {
    if (grid[row][col] == 0) {
      for (int i = 1; i < 10; i++) {
        if
...
Continue reading "Java Backtracking Algorithms: Sudoku, Knapsack, and Tasks" »

Effective SEO Strategies and PHP Web Development Essentials

Computer science3.25 KB

Keyword Research and Analysis

SEO keywords are the important words and phrases related to the developed website content. A list of keywords needs to be carefully chosen to optimize the search. Keyword Research and Analysis is an important part of Search Engine Optimization (SEO) as well as Search Engine Marketing. For Search Engine Marketing, one can pay for certain keywords. There are various online Keyword Planner tools (such as Google Ads Keyword Planner) to shortlist keywords. This is more useful to compare the cost of various keywords if the website designer opts for Paid Search Engine Marketing.

Features of PHP Scripting Language

PHP is the most popular and frequently used worldwide server-side scripting language. Following are features...

Continue reading "Effective SEO Strategies and PHP Web Development Essentials" »

Sistema de Gestión de Usuarios con Java Web

Computer science21.85 KB

Archivos HTML del Frontend

INDEX.HTML: Menú Principal del Sistema

<!DOCTYPE html>
<html>
<head>
    <title>Menú Principal del Sistema</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        h2 { color: #789; font-size: 45px; }
        select { color: brown; font-size: 30px; }
        h3 { color: #8b4513; font-size: 30px; }
    </style>
</head>
<body>
    <h2>Menú de Opciones del Sistema</h2>
    <h3>Seleccione una opción:</h3>
    <ol>
        <li><a href="Registro.html">Registrar Usuario</a></li>
        <li><a href="Acceso.html">Acceso
...
Continue reading "Sistema de Gestión de Usuarios con Java Web" »

Practical Guide to Node.js, MongoDB, AngularJS and Flutter Projects

Computer science15.15 KB

Practical 1: Node.js, Express and Mongoose Setup

Run these commands first:

  • npm init -y
  • npm install express mongoose cors dotenv
  • mkdir models
  • Create the files: app.js, db.js, models/Post.js, models/User.js

User.js

const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema(
    {
       name: { type: String, required: true },
       email: { type: String, required: true, unique: true },
       age: { type: Number, required: true }
    },
    { timestamps: true }
);

module.exports = mongoose.model("User", UserSchema);

Post.js

const mongoose = require("mongoose");

const PostSchema = new mongoose.Schema(
    {
       title: { type: String, required: true },
       content: { type: String, required: true },
       author: { type: mongoose.
...
Continue reading "Practical Guide to Node.js, MongoDB, AngularJS and Flutter Projects" »

Functional vs Object-Oriented Programming: Python Concepts

Computer science2.29 KB

Functional vs. Object-Oriented Programming

Object-Oriented Programming (OOP) models problems as objects containing data and methods that perform actions on that data. Functional Programming treats problems as a chain of functions evaluated to produce a result.

Code Output Analysis

  • SQUARE [1, 4, 9]: []
  • FIB FUNC: 0: 1, 1: 8, 2: 19, 3: 46
  • HELLO F: The first prints “Hello world”. The second raises an error because say_hello() is bound to an object but is called without an instance.

Python Methods Explained

A class method takes the class as the first argument. A static method takes no class or instance reference. An instance method takes an instance as an argument.

Intersection of N Lists

To find the intersection of multiple lists, use reduce with set.

...
Continue reading "Functional vs Object-Oriented Programming: Python Concepts" »

Fundamentals of Optimization and Statistical Modeling

Computer science3.51 KB

Optimization Problem and LP Relaxation

The objective function for an optimization problem is: Min 3x – 2y, with constraints x ≥ 0, y ≥ 0. x and y must be integers. Suppose that the integer restriction on the variables is removed. If so, this would be a familiar two-variable linear program; however, it would also be an example of an LP relaxation of the integer linear program.

Integers in Linear Programs

Integers cannot be used in linear programs.

  • False

Simple Linear Regression Model

In a simple linear regression model, y = b0 + b1x + eb1, b1 represents the intercept.

Time Series Recurring Pattern

A time series that shows a recurring pattern over one year or less is said to follow a cyclical pattern.

Binary Integer Program Variables

In binary integer...

Continue reading "Fundamentals of Optimization and Statistical Modeling" »

Python Class: Store Management System

Computer science4.38 KB

Python Store Management System

This code defines a Store class in Python, designed to manage customers, sellers, and orders. It uses basic object-oriented principles and data structures.

Class Definition

from Problema2.Cliente import Cliente
from Problema2.Vendedor import Vendedor

class Tienda():
    def __init__(self):
        self.__personas = []
        self.__pedidos = []

    def altaCliente(self, Cliente):
        alta = False
        if Cliente in self.__personas:
            alta = False
        else:
            self.__personas.append(Cliente)
            alta = True
        return alta

    def altaVendedor(self, Vendedor):
        alta = False
        if Vendedor in self.__personas:
            alta = False
        else:
...
Continue reading "Python Class: Store Management System" »

Java Linked List Implementation: Essential Methods

Computer science2.81 KB

Java Linked List Implementation

Inserting Elements at Positions

public void insertPos() {
    if (isEmpty()) {
        throw new EmptyCollectionException("Lista");
    } else {
        LinearNode actual = first;
        LinearNode nuevo = null;
        int posActual = 1;
        while (actual != null) {
            nuevo = new LinearNode(posActual);
            nuevo.next = actual.next;
            actual.next = nuevo;
            actual = nuevo.next;
            nElements++;
            posActual++;
        }
    }
}

Skipping Iterator Implementation

private class SkippingIteratorImpl implements Iterator<T> {
    private Node<T> current;

    public SkippingIteratorImpl() {
        current = first;
        if (first != null) {
...
Continue reading "Java Linked List Implementation: Essential Methods" »