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

Processor Architectures: RISC, CISC, and Micro-operations Demystified

Computer science3.23 KB

CISC: Complex Instruction Set Computer

The Complex Instruction Set Computer (CISC) architecture packs more complex instructions into the processor. Some instructions might perform several tasks in one go. This design reduces the number of instructions a programmer needs to write but makes the CPU's internal logic more complicated and potentially slower for some tasks.

  • Think: “Do more, but it might take longer.”

CISC is commonly found in x86 architectures (e.g., typical laptops or desktops), where compatibility and code density often matter more than raw efficiency.

RISC vs. CISC: Architectural Approaches

Both RISC (Reduced Instruction Set Computer) and CISC architectures aim to solve the same problem—efficient program execution—but they...

Continue reading "Processor Architectures: RISC, CISC, and Micro-operations Demystified" »

Von Neumann Architecture: Components, Instruction Flow, and RISC Design

Computer science3.24 KB

Von Neumann Architecture Fundamentals

The Von Neumann Architecture is a foundational computer architecture model where the Central Processing Unit (CPU), memory, and input/output devices share a single communication pathway—the system bus.

This design is characterized by using the same memory space for both instructions (programs) and data, often referred to as the stored-program concept.

We can examine how instructions flow through this architecture and how it compares to other models, such as the Harvard Architecture.

Essential Components for Instruction Execution

Here is a breakdown of three key registers—the Program Counter (PC), Instruction Register (IR), and Memory Address Register (MAR)—all essential for executing instructions in a...

Continue reading "Von Neumann Architecture: Components, Instruction Flow, and RISC Design" »

Software Design Principles and Patterns

Computer science4.98 MB

Lecture 2: Dynamic Dispatch and Interfaces

  • Dynamic Dispatch: The process of selecting which implementation of a polymorphic operation to call at runtime.
  • Interface: Calling a method that is not in the interface will cause a compilation error.

Lecture 3: N/A

Lecture 4: Method Contracts, Exceptions, and Unit Testing

  • Method Contract: Should define pre/post conditions and exceptional behavior. The client is to blame if the precondition is not met, and the service is to blame if the postcondition is not met. Exceptional behavior specifies what the code will do if a precondition is violated.
  • Exception: Runtime exception (unchecked) and IO exception (checked). The IO exception must be caught; otherwise, the code won't compile.
  • Unit Test: Test boundary
...
Continue reading "Software Design Principles and Patterns" »

Leveraging AI for Index Recommendations and Regular Path Queries

Computer science4.45 KB

AI Meets AI: Leveraging Query Executions to Improve Index Recommendations

How artificial intelligence (AI) can benefit automated indexing (AI)?: Comparing the execution cost of two plans (different index configurations of same query) is key for index tuning. Instead of using optimizer’s estimates for such comparison, formulating it as a classification task in machine learning results in significantly higher accuracy.

MOTIVATION:

  • Being able to fully automate index recommendation and implementation is a significant value-add for improving query execution cost.
  • Requirement: creating or dropping indexes should not cause significant query performance regressions - users enforce a no query regression constraint.
  • Using the optimizer’s estimates to
...
Continue reading "Leveraging AI for Index Recommendations and Regular Path Queries" »

Runtime Memory Organization: Code, Static Memory

Computer science2.37 KB

Runtime Memory Organization

The organization of memory at runtime depends on the type of language (declarative, imperative), the compiler, and the operating system.

General Structure of Programming Languages

When you run a program, the OS loader allocates the required amount of memory and loads the code to be executed (stored in a file) into the code area.

The OS should detect collisions between the stack and the heap. In these cases, the program may abort, or the amount of allocated memory may be increased.

In memory paging systems, the above scheme can be fragmented and scattered between real memory and the virtual memory system.

Any reference to a storage location within the code should be relative to the position assigned to the process by the...

Continue reading "Runtime Memory Organization: Code, Static Memory" »

C Programming Language: Functions, Pointers, and Files

Computer science4.96 KB

Functions in C

Void functions provide a way to emulate what are called procedures in other languages (e.g., PASCAL). They are used when it is not required to return a value. Here is an example that prints the squares of certain numbers:

void square ()
{
int count;

for (counter = 1; count < 10; counter++)
printf ("%d\n", counter * counter);
}

main ()
{
square ();
}

Input and Output Parameters

To use parameters in/out, the formal parameter must be preceded by the ampersand symbol (&), and the current parameter must be a variable (not an expression). Input/output parameters are used when you want a procedure to change the contents of the current variable. The fact that these parameters are explicitly defined as variables makes the programmer aware of...

Continue reading "C Programming Language: Functions, Pointers, and Files" »

Device Communication: Controllers and Functions

Computer science3.5 KB

Key Functions of Device Communication

The main functions related to device communication are:

  • Sending commands to devices.
  • Detecting interrupts.
  • Handling errors.
  • Providing a simple and easy-to-use interface between devices and the rest of the system. This interface should ideally be the same for all devices, regardless of their specific type.

Device Categories

Human-Readable Devices

Used for communication with the user:

  • Printers
  • Graphic display terminals
  • Displays
  • Keyboards
  • Mice

Machine-Readable Devices

Used for communication with electronic equipment:

  • Disk and tape drives
  • Sensors
  • Controllers
  • Actuators

Communication Devices

Used for communication with remote devices:

  • Digital line drivers
  • Modems

Device Types

Devices fall into two broad categories:

  • Block devices
  • Character
...
Continue reading "Device Communication: Controllers and Functions" »

Digital and Analog Signals: Input and Output Channels

Computer science2.58 KB

Digital Awareness

When you want to receive digital information from the outside: The business card input channels are available, usually in groups of 8 bits, to which binary information is assigned by a program. These can be assigned to an internal variable state of a byte by a reading instruction that may have a port. There can be one or more bytes of input, assigning each an address.

Analog Outputs

To send analog control signals to the outside, the tallies have one or more channels of output through their respective A/D converters. A 1V analog converter generates a constant proportional to the numerical value of the digital data that it has on its input lines. Internally, they have a 5V memory. Different voltage ranges can be obtained using...

Continue reading "Digital and Analog Signals: Input and Output Channels" »

Prolog Predicates & Game AI Algorithms

Computer science3.47 KB

funcition min-max(pos,out-eval,out-best_move,in-whomoves,in-max_level){max=-?;min=?;best_move=0;if(level==0){evaluation=eval_(pos);best_move=0; return;}else{foi(i=0;i<num_succ(i);++i){succi=succesor(i);if(whomoves=='max'){min-max(succi,evaluation,best_move,'min', max_level-1);if(evaluation>max){max=evaluation; best_move=i;}}else{min-max(succi,evaluation,best_move,'max', max_level-1);}if(evaluation<min){min=evaluation;best_move=i;}}}}

funcition ??(pos,level,quien_juega,*eval,mejor_move,?,?){if(terminal(pos)||(level==0){*eval=eval(pos);return;}n_succ= num_succ(pos);for(i=0;i<n_succ;++i{if(quien_juega=='max'){succi=succesor(pos,i);??(succi,level-1,'min',evali, mejor_movi,?,?);if(evali>?){?=evali;*eval=?; *mejor_move=i;}if(?>?)...

Continue reading "Prolog Predicates & Game AI Algorithms" »

Essential OPAC Functions for Modern Libraries

Computer science2.77 KB

Features of an OPAC

OPAC (Online Public Access Catalogue):

Core Features of an OPAC

1. Advanced Search Capabilities

  • Multi-Field Searching: Allows retrieval using specific metadata like Author, Title, ISBN, Subject, and Call Number.
  • Boolean & Query Refinement: Supports Boolean operators (AND, OR, NOT), wildcard truncation, and phrase searching to narrow down results.

2. Real-Time Status & Location Tracking

  • Circulation Status: Displays live item availability (e.g., Available, Checked Out, On Hold, Lost).
  • Dynamic Location: Pinpoints the exact physical location, including the specific collection (e.g., Reference, Stack) and the Call Number/Shelf Mark.

3. Patron Self-Service (My Account)

  • Circulation Control: Enables users to log in to renew issued
...
Continue reading "Essential OPAC Functions for Modern Libraries" »