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

C++ Priority Queue Implementation: Code & Explanation

Computer science3.58 KB

C++ Priority Queue Implementation

This document provides a C++ implementation of a priority queue using a heap data structure. The code includes the class definition, member functions, and supporting utilities.

Priority Queue Class Definition


#ifndef priority_queue_h_
#define priority_queue_h_

#include <iostream>
#include <vector>
#include <cassert>

template <class T>
class priority_queue {
private:
    std::vector<T> m_heap;

public:
    priority_queue() {}

    priority_queue(std::vector<T> const& values)
    {
        m_heap = values;
        for (int i = 0; i < m_heap.size(); i++){
            percolate_down(i);
            for (int j = i; j < m_heap.size(); j++){
                percolate_down(
...
Continue reading "C++ Priority Queue Implementation: Code & Explanation" »

Working with Databases in Access: A Comprehensive Guide

Computer science2.35 KB

Topic 8: Exporting Data from Access

Exportable File Formats

  • SharePoint
  • Word files
  • Excel documents
  • Other Access databases
  • Text files

Linked Tables and Data Updates

Changes made to the original Excel data will not be reflected in the linked Access table.

Dividing a Database

An Access database can be split into two files:

  • Server File: Contains the tables.
  • Client File: Contains forms, reports, and other created objects.

Topic 9: Working with Forms in Access

Simple Forms

Access can automatically generate simple forms from active tables, displaying records in an organized layout and allowing for new data entry.

Form Tools

Form tools simplify the creation of forms by allowing you to select the desired data fields.

Split Forms

Split forms offer two views:

  • Form View
  • Datasheet
...
Continue reading "Working with Databases in Access: A Comprehensive Guide" »

Distributed Database Concepts and Architecture Fundamentals

Computer science3.08 KB

First Partial: Distributed Databases

1. The Database Concept

R: A database is a set of interrelated information for a common purpose.

2. Definition of Distributed Database

R: A distributed database is a collection of multiple databases located in different locations and connected via a network.

3. Goals of Distributed Databases

R: Building distributed systems, including databases, information sharing, reliability, availability, and speed in query processing.

4. Advantage of Data Distribution

R: The advantage of distributed systems is the ability to share and access information reliably and effectively.

5. Increasing Complexity Reflection

R: This reflects in gesta (management) software development, a greater likelihood of errors, and longer processing...

Continue reading "Distributed Database Concepts and Architecture Fundamentals" »

Distributed Systems: Invocation Semantics and Architectural Layers

Computer science2.41 KB

1. Maybe Semantics

Used in protocols like UDP or CORBA methods that return results. It is uncertain whether an object has been executed once or not at all. This approach does not apply any measures of fault tolerance and can suffer from omission failures if the invocation or the response is lost. If a timeout is set, the answer could be received after its expiry (asynchronous). This semantic is useful in applications where it is acceptable to have two failed invocations.

2. At-Least-Once Semantics

Used in consultations or SUN RPC. The client receives a result, ensuring the method was executed at least once, or receives an exception stating no results were obtained. This can achieve broadcast messages for those that did not respond. Depending on...

Continue reading "Distributed Systems: Invocation Semantics and Architectural Layers" »

Abstraction, Syntax, and Semantics in Software Design

Computer science3.51 KB

What is Abstraction? Types and Principles

Abstraction is a mental process involving the understanding of phenomena or situations that involve many details. It consists of two key aspects:

  • Highlighting the most relevant details of the object under study.
  • Ignoring irrelevant details of the object (at that specific level of abstraction).

Abstraction is fundamental for designing programs that are shorter, readable, easy to maintain, and reliable—i.e., quality software.

Programming languages are the tools used by programmers to implement these abstract models. Abstraction in programming is typically divided into two types:

  1. Operational Abstraction: It is based on the use of procedures and/or functions without worrying about how they are implemented.
...
Continue reading "Abstraction, Syntax, and Semantics in Software Design" »

TCP/IP Networking Concepts and Protocols Explained

Computer science3.85 KB

1. Server Type for Initial Network Client Connection

Which server type would a network client most likely use first when connecting to a network, such as a school network?

DHCP

2. Data Encapsulation Process

What does encapsulate the data? Explain briefly.

The information is converted into data by a specific application. Then, using TCP, the data is divided into segments, and each is assigned a header that includes the source and destination port numbers. Next, the IP protocol header assigns IP addresses (physical and logical). Finally, the Ethernet protocol sends the segments, which are framed with an Ethernet header and trailer containing the source and destination MAC addresses.

3. Identifying Application for Incoming Segments

If an Internet server

...

Continue reading "TCP/IP Networking Concepts and Protocols Explained" »

C++ Class Structure and Object Lifecycle Management

Computer science3.08 KB

Sections of a C++ Class

  • Private Section: Only member functions can access the class member functions; descendant classes are denied access to the private members of a class.
  • Protected Section: Only member functions of a class and its descendant classes' members can access these members.
  • Public Section: Specified members are visible to all member functions and external calls to the class.

Rules for Class Sections

  1. Sections of the class can appear more than once in any order.
  2. If no section is specified, C++ treats members as private by default.
  3. Grouping data members in the public section should be avoided unless such a declaration significantly simplifies the design. Data members are usually placed in the protected section to allow access for descendant
...
Continue reading "C++ Class Structure and Object Lifecycle Management" »

Software Installation & Uninstallation: Parallel Work, Backup & Troubleshooting

Computer science2.47 KB

8 Steps for Parallel Work & Uninstallation

The operation of the application, i.e., its use at full capacity.

Parallel Work

When an application is replaced by another, performing a parallel operation of the new application with the old. This means a double data entry, and duplicating all tasks for a certain period of time. This results in greater safety for two reasons:

  • You can compare the results of both applications. If the previous application had no failures, the results of the new application should be the same as the old, for identical processes.
  • If you detect a serious problem in the new application, you can continue working with the former, which has all the information up to date, while the situation is resolved.

Warranty and After-Sales

...
Continue reading "Software Installation & Uninstallation: Parallel Work, Backup & Troubleshooting" »

Program Translators: Compilers, Interpreters, and Execution

Computer science3.39 KB

Program Translators: Compilers and Interpreters

Programs written in a programming language need to be translated into machine code to be executed by the CPU. This task is carried out by translators.

Translators can be categorized into two main types based on the translation process:

  • Interpreters: Take the original program (source code), translate each instruction, and execute it immediately.
  • Compilers: Take the source code, translate it completely into object code, and then the translated program is executed.

The Compilation Process: Object Code and Linking

After compiling a program, the result is known as object code. Object code is a new program written in a language very similar to machine code, but it is still not executable by the CPU.

Following...

Continue reading "Program Translators: Compilers, Interpreters, and Execution" »

Python Logic for Sequences and Base Conversions

Computer science3.82 KB

Tile Sequence Validation Logic

The following function determines if a sequence of tiles is valid by checking their compatibility and adjusting their orientation if necessary.

def is_valid_sequence(seq: list[Tile]) -> bool:
    if len(seq) < 2:
        res = True
    else:
        if not are_compatible(seq[0], seq[1]):
            seq[0] = seq[0][1], seq[0][0]
        i = 1
        while i < len(seq) and are_compatible(seq[i - 1], seq[i]):
            if seq[i - 1][1] != seq[i][0]:
                seq[i] = seq[i][1], seq[i][0]
            i += 1
        res = i == len(seq)
    return res

Square-Free Number Verification

This function checks if a positive integer is square-free, meaning no prime factor has an exponent greater than one.

def
...
Continue reading "Python Logic for Sequences and Base Conversions" »