Notes, summaries, assignments, exams, and problems for Computer science

Core Concepts in Computer Architecture and Assembly

Computer science3.56 KB

CPU Fundamentals and Timing

Clock Cycles and Frequency

A clock that oscillates 1 million times per second (1 MHz) produces a clock cycle of 1 microsecond (1 μs), which equals 10-6 seconds per cycle.

Instruction Execution Pipeline

The steps for executing a machine instruction are:

  1. Fetch the instruction.
  2. Decode the instruction.
  3. Fetch the operand (if any).
  4. Execute the instruction.
  5. Store the result or output.

Cache Memory Operations

Cache memory is a small, fast memory used to temporarily store frequently accessed data or instructions to speed up CPU operations.

  • A cache hit occurs when the CPU finds the required data in cache memory.
  • A cache miss occurs when the data is not found and must be fetched from main memory.

Assembly Language Basics

General-Purpose

...
Continue reading "Core Concepts in Computer Architecture and Assembly" »

Programming Fundamentals and OOP Cheat Sheet

Computer science3.49 KB

MEGA CHEAT SHEET

1. Programming Fundamentals

Software Development Life Cycle (SDLC)

Steps: Requirements → Specifications → Design → Development → Integration → Testing/Debugging → Installation → Maintenance.

Mnemonic: Really Smart Developers In Tech Install Machines.

Algorithms

  • Control Structures:
    • Sequence (In Order)
    • Selection (If/Else)
    • Iteration (Loops)
  • Design Strategies: Divide and Conquer, Backtracking.
  • Representations: Pseudocode, Flowcharts, Structure Charts, Abstraction Diagrams.
  • Checking: Identify Input/Output, Purpose, Desk Check with data.

Programming Paradigms

  • Imperative: Step-by-step instructions (e.g., Python).
  • OOP: Objects and classes (e.g., Java, Python).
  • Logic: Facts and rules (e.g., Prolog).
  • Functional: Pure functions, no state
...
Continue reading "Programming Fundamentals and OOP Cheat Sheet" »

Essential Python Recursion and Pandas Data Analysis

Computer science2.86 KB

Recursive Functions in Python

def range_sum(num_list, start, end):
    if start > end:          # Base case
        return 0
    else:                    # Recursive case
        return num_list[start] + range_sum(num_list, start + 1, end)

numbers = [2, 4, 6, 8, 10]
print(range_sum(numbers, 1, 3))  # Expected output: 18

Tower of Hanoi

def hanoi(n, from_peg, to_peg, temp_peg):
    if n > 0:
        # Step 1: Move n-1 discs to temp peg
        hanoi(n - 1, from_peg, temp_peg, to_peg)
        # Step 2: Move the bottom disc
        print(f"Move disc from peg {from_peg} to peg {to_peg}")
        # Step 3: Move n-1 discs from temp peg to target peg
        hanoi(n - 1, temp_peg, to_peg, from_peg)

Greatest Common Divisor

def gcd(x, y):
    if x
...
Continue reading "Essential Python Recursion and Pandas Data Analysis" »

Fundamental Data Structures and C Programming Concepts

Computer science302.19 KB

1. Understanding Arrays and Their Types

An array is a collection of elements of the same data type stored in contiguous memory locations. It is used to store multiple values in a single variable and can be accessed using index numbers. The indexing in an array starts from 0. Arrays help manage and process data efficiently, especially when dealing with large volumes of similar data.

Types of Arrays Based on Dimensions

  1. One-Dimensional Array: It stores data in a linear list format.
  2. Multi-Dimensional Array: It stores data in matrix form (like 2D, 3D arrays), which is useful in applications like image processing and tables.

Types of Arrays Based on Memory Allocation

  1. Static Array: The size of the array is fixed at compile-time. Memory is allocated when
...
Continue reading "Fundamental Data Structures and C Programming Concepts" »

Core Python for Data Analysis and Scientific Computing

Computer science11.79 KB

Key Concepts in Data Science & Scientific Computing

Visualization Techniques

  • Overlapping Histograms: Use semi-transparent alpha parameter for comparison.

Data Structures & Algorithms

  • BFS Implementation: collections.deque is ideal for Breadth-First Search.
  • Grid Representation: Obstacles often represented by a value like 1.

Jupyter Notebook & Markdown

  • Markdown Headings: Use # prefix for headings in Jupyter Markdown cells.

Optimization & Least Squares

  • Normal Equations: Direct matrix inversion for Least Squares: β = (XᵀX)⁻¹Xᵀy.

Numerical Integration & Simulation

  • Orbit Simulation: Runge–Kutta 4th order method is a common integration technique.

Search Algorithms

  • Brute-Force Search: Often implemented using nested loops.

Python Ecosystem

...
Continue reading "Core Python for Data Analysis and Scientific Computing" »

Java Programming Essentials: Exceptions, Threads, Events, and Adapters

Computer science7 KB

Core Java Programming Concepts Explained

Key Java Definitions

  • Exception: An event that disrupts the normal flow of a program's instructions.
  • Thread: A lightweight subprocess enabling multitasking within a program.
  • Event Handling: Implemented using listeners and event classes that respond to user actions.
  • Applet: A small Java program embedded in a web page for interactive content.
  • Remote Applets: Used to download and execute applets from a web server over the internet.
  • Applet Parameters: Passed to applets using <PARAM> tags in HTML, accessed via the getParameter() method.
  • Daemon Thread: Runs in the background for services like garbage collection and ends when main threads finish.
  • Thread Synchronization Advantages:
    • Prevents thread interference.
    • Ensures
...
Continue reading "Java Programming Essentials: Exceptions, Threads, Events, and Adapters" »

Cheat-Sheet Editor: Professional Document Formatting Tools

Computer science1.78 KB

  • File
  • Home
  • Insert
  • Options
  • Information

Editor Toolbar

Font and Paragraph Controls

Adjust your Font, Size, and Line Spacing. Use formatting options like Bold, Italic, Underline, Subscript, and Superscript. Align text or use lists (ordered and unordered) to organize your content.

Insert Elements

  • Table: Insert a table into the document.
  • Image: Include an image from a local file.
  • Link: Create a link for quick access to web pages.
  • Separator: Insert a horizontal line to divide sections.
  • Quote: Insert a blockquote.

Advanced Features

  • Search: Find documents on Wikiapuntes, xuletas.es, and wikiteka.com.
  • Compress: Reduce text size to occupy minimum space.
  • Preview: View how the cheat sheet looks when printed.
  • Install: Use the editor offline for better performance.

Print and

...
Continue reading "Cheat-Sheet Editor: Professional Document Formatting Tools" »

Digital Electronics Concepts: Flip-Flops, Registers, and Converters

Computer science1.38 MB

1. JK Flip-Flop Operation and Truth Table

Logic Diagram:

wBjcvJtk2sNIQAAAABJRU5ErkJggg==

EAjrov4gZdUr+SxbQQf9fGi1dW7+IBXTQfxEz6pT8lyzwf4VinCuWPVOZAAAAAElFTkSuQmCC

Working Principle

The JK flip-flop is an enhanced version of the gated SR flip-flop. It incorporates clock input circuitry to eliminate the invalid output condition that occurs when both S and R inputs are logic level "1".

Because of the added clock input, the JK flip-flop offers four distinct input combinations:

  • Logic "1" (Set)
  • Logic "0" (Reset)
  • No Change
  • Toggle

The S and R inputs of the preceding SR bistable are replaced by J and K inputs, named after its inventor, Jack Kilby. Thus, J = S and K = R.

The two 2-input AND gates in the gated SR bistable are replaced by two 3-input NAND gates. The third input of each NAND gate connects to the outputs Q and $\bar{Q}$. This cross-coupling allows the...

Continue reading "Digital Electronics Concepts: Flip-Flops, Registers, and Converters" »

Database Management Systems and ERD Fundamentals

Computer science36.02 KB

Introduction to Database Management Systems

A database is a structured collection of data stored on a computer system. It is managed using a Database Management System (DBMS), which provides the necessary tools for data storage, retrieval, and modification.

Core Benefits of Using a DBMS

  • Reduced Data Redundancy: A DBMS helps minimize repeated data through organizational rules such as normalization.
  • Enhanced Data Accuracy: The system uses specific rules, such as referential integrity, to maintain data consistency.
  • Support for Multiple Users: Many people can access and use the database simultaneously without encountering operational problems.

Centralized vs. Distributed Databases

  • Centralized: All data is stored in a single, primary location. This setup
...
Continue reading "Database Management Systems and ERD Fundamentals" »

C++ Code Examples: Arithmetic Mean, Sum, Product, Square

Computer science1.55 KB

Arithmetic Mean

The following C++ code calculates the arithmetic mean of numbers from 1 to n:

int main() {
    int n;
    double suma = 0;
    cout << "Vnesi broj: ";
    cin >> n;
    if (n <= 0) {
        cout << "Brojot na elementi mora da bide pogolem od 0!" << endl;
        return 1;  
    }
    for (int i = 1; i <= n; i++) {
        suma += i;  
    }
    double sredina = suma / n;
    cout << "Aritmetichkata sredina na broevite od 1 do " << n << " e: " << sredina << endl;
    return 0;
}

Sum

The following C++ code calculates the sum of numbers from 1 to n:

int main() {
    int n, sum = 0;
    cout << "Vnesi broj n: ";
    cin >> n;
    for (int i = 1; i <= n; i++)
...
Continue reading "C++ Code Examples: Arithmetic Mean, Sum, Product, Square" »