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

LEGv8 Architecture and Assembly: Performance, Registers, Instructions and Branching

Computer scienceUpdated on 239.58 KB

Performance Metrics

  • Elapsed Time: Represents overall system performance. It is the total time taken to complete a task.
  • User CPU Time: Indicates CPU performance. It is the time the task actively runs on the CPU, excluding idle time.
  • CPU Time: The time the CPU spends executing instructions, either from the task or the operating system, excluding idle time.
  • Clock Speed: 1 MHz equals 1 million clock cycles per second. 1 GHz equals 1 billion clock cycles per second.
  • Response Time: Equivalent to execution time.
  • Throughput: Equivalent to bandwidth.
  • Performance Comparison: (PerfA) / (PerfB) = (ExecTimeB) / (ExecTimeA) = n

Impact of Processor Upgrades

  • Replacing a processor with a faster one decreases response time and increases throughput.
  • Adding an additional
...
Continue reading "LEGv8 Architecture and Assembly: Performance, Registers, Instructions and Branching" »

Complete Data Structures C++ Implementation Templates

Computer science54.36 KB

Lecture 1 — Introduction to Data Structures

Is lecture mein mostly theory, ADT, data organization, time aur space complexity aati hai. Is mein koi specific data structure implementation template nahi.

Basic program template:

#include <iostream>
using namespace std;

int main()
{
    // Declare variables

    // Take input

    // Perform operation

    // Display output

    return 0;
}

Algorithm likhne ka template:

START
    Input data
    Perform required operation
    Display result
STOP

ADT (Abstract Data Type) ka answer likhne ke liye:

  • Data structure ka naam

  • Data kis tarah store hota hai

  • Available operations

  • Operations ka expected behaviour

Example: Stack ADT mein push, pop, top, isEmpty operations hoti hain.

Lecture 2 — Arrays

High priority

1.

...
Continue reading "Complete Data Structures C++ Implementation Templates" »

Additive Manufacturing: SLA, FFF, DfAM and Design Considerations

Computer science8.11 KB

Define Additive Manufacturing and compare it with conventional CNC machining.

Additive Manufacturing (AM) is a manufacturing process in which a 3D object is created by adding material layer by layer from a digital CAD model. It uses materials such as polymers, metals and ceramics.

Comparison between Additive Manufacturing and CNC Machining

Additive Manufacturing>>

  1. Material is added layer by layer.
  2. Material is added layer by layer.
  3. Produces less material wastage.
  4. Complex shapes can be easily produced.
  5. Suitable for rapid prototyping and customization.
  6. Generally requires less tooling.

CNC Machining>>

  1. Material is removed from the workpiece.
  2. It is a subtractive process.
  3. Produces more material wastage.
  4. Complex shapes require multiple machining operations.
...
Continue reading "Additive Manufacturing: SLA, FFF, DfAM and Design Considerations" »

Processor and Memory Interface: CPU Datapath, Registers & ALU

Computer science967.85 KB

Processor & Memory Interface

Processor & Memory Interface: The maximum size of the memory that can be used in any computer is determined by the addressing scheme. For example, a computer that generates 16-bit addresses is capable of addressing up to 216 = 65,536 (≈ 64K) memory locations. Machines whose instructions generate 32-bit addresses can utilize a memory that contains up to 232 = 4,294,967,296 (≈ 4G) locations, whereas machines with 64-bit addresses can access up to 264 ≈ 1.84 × 1019 locations. The number of locations represents the size of the address space of the computer.

The connection between the processor and its memory consists of address, data, and control lines. The processor uses the address lines to specify the...

Continue reading "Processor and Memory Interface: CPU Datapath, Registers & ALU" »

The Complete HTTP Request Lifecycle Explained Step-by-Step

Computer science4.45 KB

1. Client Initiation and DNS Lookup

  • The user enters a URL or clicks a link in the browser. The browser parses the URL and extracts the domain (e.g., www.example.com).

  • A **DNS lookup** translates this domain into an IP address—acting like a digital phonebook entry.


2. Establishing the TCP Connection

The browser’s operating system (OS) creates a socket and initiates the **TCP three-way handshake** with the server:

  1. SYN: Client sends a synchronization request to the server.
  2. SYN-ACK: Server acknowledges the request and sends its own synchronization.
  3. ACK: Client acknowledges the server's response.

Once this handshake is complete, a full-duplex TCP connection is open and ready for reliable data exchange.


3. Sending the HTTP Request Message

The client constructs...

Continue reading "The Complete HTTP Request Lifecycle Explained Step-by-Step" »

Essential Python Programming Snippets

Computer science2.76 KB

File Handling

# Basic file reading
file = open("data.txt", "r")
content = file.read()          # Read entire file
lines = file.readlines()       # Read as list of lines
file.close()

# Reading line by line
file = open("data.txt", "r")
for line in file:
    print(line.strip())        # strip() removes \n
file.close()

# Write to file (overwrites)
file = open("output.txt", "w")
file.write("Hello World\n")
file.close()

# Append to file (adds to end)
file = open("output.txt", "a")
file.write("New line\n")
file.close()

Working with Lists

# Creating lists
numbers = [1, 2, 3, 4, 5]
names = ["John", "Maria", "Carlos"]

# Accessing elements
first = numbers[0]            # First element
last = numbers[-1]            # Last element
slice = numbers[1:4]
...
Continue reading "Essential Python Programming Snippets" »

Mastering Matrix Operations and Linear Equations in MATLAB

Computer science3.98 KB

Matrix Operations and Linear Equations in MATLAB

Format short, long format, format rat (format is the x / y), format short (as is 3 * 10-5 = 3e-5). A = [; ;]. To extract a positive one: A(2,2). Changing a number in one position: A(row, column) = number in that position.

Write a whole line: A(row,:). or A(row, 2:4) - the columns you want from that row. For columns it is the same but in reverse: A(:, 3:7). Extract a submatrix A(2:3, 2:3) - ever-growing range. Transpose: A.'. Conjugate matrix (star A*): A'. Matrix for blocks: [A | E] - like n-th row or [A; E] - so I place it under.

Matrix by number unit: 23 * ones(3). Identity: eye(x, y).

Systems of Linear Equations Ax = b:

  • Rank(A) = rank(A | b) = No incog. - SCD: x = A \ b
  • Rank(A) = rank(A | b)
...
Continue reading "Mastering Matrix Operations and Linear Equations in MATLAB" »

Thread Synchronization, Priority Inversion, and CPU Efficiency

Computer science2.18 KB

Can the Priority Inversion Problem Happen with User-Level Threads?

The priority inversion problem occurs when a low-priority process is in its critical region and suddenly a high-priority process becomes ready and is scheduled. With user-level threads, it cannot happen that a low-priority thread is suddenly preempted to allow a high-priority thread to run. There is no preemption. With kernel-level threads, this problem can arise.

Does Round-Robin Scheduling Resolve Priority Inversion?

Round-robin scheduling can resolve the issue. Sooner or later, the low-priority process will run and eventually leave its critical region. With priority scheduling, the low-priority process never gets to run at all; with round-robin, it gets a normal time slice periodically,...

Continue reading "Thread Synchronization, Priority Inversion, and CPU Efficiency" »

CPU Terminals, Buses, and Instruction Execution Cycle

Computer science3.92 KB

CPU Terminals and Bus Interconnection

The terminals (pins) of a Central Processing Unit (CPU) are typically divided into three main types: Address, Data, and Control.

These terminals are connected to similar terminals on memory chips and Input/Output (I/O) devices. This interconnection is collectively known as the bus system.

Communication between the CPU, memory, and I/O devices is effective through both transmitting and receiving signals at these terminals.

Key Bus Parameters

The functionality of the bus system is defined by three basic parameters:

  • Address Lines: A chip that has m address lines can address up to 2m memory locations.
  • Data Lines: A chip that has n data lines can write or read a word of n bits in a single operation.
  • Control Lines: These
...
Continue reading "CPU Terminals, Buses, and Instruction Execution Cycle" »

Cheat Sheets: Definition, Academic Use, and Technical Reference

Computer science3.02 KB

What is a Cheat Sheet? Definition and Terminology

A cheat sheet or crib sheet is a concise set of notes used for quick reference. The term may also be rendered as cheatsheet.

Academic Use and Exam Preparation

Cheat sheets are so named because they may be used by students without the instructor's knowledge to cheat on a test. However, in many educational settings, particularly high school or undergraduate studies, rote memorization is often less important than basic education or intense graduate studies. Therefore, students may be permitted to consult their own notes during the exam, which is not considered cheating.

The act of preparing a so-called cheat sheet is also an educational exercise. For this reason, students are typically only allowed...

Continue reading "Cheat Sheets: Definition, Academic Use, and Technical Reference" »