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

Control Flow Testing Techniques and Coverage Types

Computer science3.43 KB

Control Flow Testing is a white-box testing technique that focuses on the logical flow of a program. It checks whether all the statements, branches, and paths in the code are executed at least once during the testing process. By analyzing the control flow, this method helps uncover logical errors, unreachable code, and unexpected behavior in the program.

Types of Coverage in Control Flow Testing

Statement Coverage

  • What it does: Ensures that every line of code or statement is executed at least once.
  • Why it's useful: It helps identify if any statements have been missed during testing, ensuring no part of the code is skipped.
  • Example: In a block of code with if (x > 10) { print("X is large"); }, statement coverage would check that both the if condition
...
Continue reading "Control Flow Testing Techniques and Coverage Types" »

Point-to-Point Protocol and Data Link Layer Design

Computer science2.25 KB

Point-to-Point Protocol (PPP)

PPP stands for Point-to-Point Protocol. It is the most commonly used protocol for point-to-point access. For instance, if a user wants to access the internet from home, the PPP protocol is typically employed.

As a Data Link Layer protocol residing in Layer 2 of the OSI model, it encapsulates Layer 3 protocols and all payload information for transmission across serial links. The PPP protocol functions on synchronous links like ISDN as well as asynchronous links like dial-up. It is primarily used for communication between two devices.

Physical Network Compatibility

PPP operates over various physical networks, including:

  • Serial cables
  • Phone lines
  • Trunk lines
  • Cellular telephones
  • Fiber optic links (such as SONET)

Since the Data...

Continue reading "Point-to-Point Protocol and Data Link Layer Design" »

How PGP Encryption Secures Your Digital Communications

Computer science2.68 KB

What is Pretty Good Privacy (PGP)?

Pretty Good Privacy, commonly known as PGP, is a data encryption and decryption program that provides cryptographic privacy and authentication for data communication. Created by Phil Zimmermann in 1991, it is typically used for securing email communications. PGP uses a combination of symmetric-key encryption for efficiency and public-key encryption for secure key exchange.

Core Features of PGP Encryption

Hybrid Encryption Scheme

PGP utilizes a hybrid encryption scheme. When you want to send a message securely, PGP generates a symmetric session key, encrypts the message with this key, and then encrypts the symmetric key itself with the recipient's public key. This ensures that only the intended recipient, who possesses...

Continue reading "How PGP Encryption Secures Your Digital Communications" »

NLTK Text Processing Examples: Tokenization to NER

Computer science4.53 KB

NLTK Text Processing Examples

Experiment 4: Basic Text Preprocessing

This section demonstrates fundamental text preprocessing steps using NLTK, including tokenization, stop word removal, filtering for alphabetic tokens, and stemming.

import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.stem import PorterStemmer
from nltk.corpus import words

text = "Random sampling is a method of choosing a sample of observations from a population to make assumptions about the population"

tokens = word_tokenize(text)
stop_words = set(stopwords.words('english'))
stemmer = PorterStemmer()

# 1. Lowercase and filter for alphabetic tokens
alpha_tokens = [token.lower() for token in tokens if token.isalpha()]

# 2. Filter
...
Continue reading "NLTK Text Processing Examples: Tokenization to NER" »

Array and String Algorithms: Core Problem Solutions

Computer science6.48 KB


Longest Substring Without Repeating Characters

This problem involves finding the length of the longest substring in a given string that does not contain any repeating characters. A common approach uses a sliding window technique with a Set to efficiently track unique characters.

Strategy:

  • Utilize a Set to store characters within the current window.
  • Iterate through the string with a right pointer, adding characters to the Set.
  • If a duplicate character is encountered, move the left pointer forward, removing characters from the Set, until the duplicate is no longer present.
  • At each step, update the maximum length found.

Java Implementation Snippet

class Solution {
    public int findLongestSubstringWithoutRepeatingCharacter(String str) {
        Set&
...
Continue reading "Array and String Algorithms: Core Problem Solutions" »

Operating Systems: Processes, Threads, and System Calls

Computer science31.86 KB

Chapter 1: System Fundamentals

w8sCxppQRjzZQAAAABJRU5ErkJggg==

Inter-process Communication (IPC):

  • Network: Communication between processes over a network.
  • Pipe (Special File): Process A writes into a pipe, and Process B reads from it.

Privileged vs. User Mode

The OS runs in privileged mode (also called supervisor or system mode), where specific operations—such as accessing a disk or network card—are permitted. User programs run in user mode and cannot perform these operations directly. When a program requires an OS service, such as accessing a file or creating a process, it is accomplished by a system call.

CPU Instruction Cycle

The CPU executes programs through a continuous loop:

  1. Fetch Instruction
  2. Decode and Execute
  3. Read/Write Data
  4. Loop until powered off

OS Invocation Methods

  • System
...
Continue reading "Operating Systems: Processes, Threads, and System Calls" »

Understanding Data Storage and Binary Number Representation

Computer science221.76 KB

Data Storage Conversion:

  • 1 gigabyte (GB) equals 1,024 megabytes (MB).
  • 1 megabyte (MB) equals 1,024 kilobytes (KB).
  • To convert gigabytes to kilobytes, multiply by 1,024 twice. For example: 1 GB = 1,024 MB * 1,024 KB = 1,048,576 KB.
  • To convert gigabytes to megabytes, multiply by 1,024. For example: 1 GB = 1,024 MB
  • To convert 20 megabytes to bytes: 20 MB = 20 * 1,024 KB * 1,024 bytes = 20,971,520 bytes
  • To convert 2 gigabytes to kilobytes: 2 GB = 2 * 1,024 MB * 1,024 KB = 2,097,152 KB

Example: SHKRONJA A has a value of 1010, B - 1011, C - 1100, D - 1101, E - 1110, F - 1111.

Binary Number Representations

There are three main ways to represent signed numbers in binary:

1. Signed Magnitude

  • Positive Numbers: Standard binary representation.
  • Negative Numbers: The
...
Continue reading "Understanding Data Storage and Binary Number Representation" »

Introduction to PL/SQL: Features, Differences, and Advantages

Computer science3.98 KB

PL/SQL

PL/SQL is a procedural language designed specifically to embrace SQL statements within its syntax. PL/SQL program units are compiled by the Oracle Database server and stored inside the database. And at run-time, both PL/SQL and SQL run within the same server process, bringing optimal efficiency. PL/SQL includes procedural language elements like conditions and loops. It allows declaration of constants and variables, procedures and functions, types and variable of those types and triggers. It can support Array and handle exceptions (runtime errors).

Differences between SQL and PL/SQL

  • SQL is a single query that is used to perform DML and DDL operations.
  • PL/SQL is a block of codes that used to write the entire program blocks/ procedure/ function,
...
Continue reading "Introduction to PL/SQL: Features, Differences, and Advantages" »

Mastering Apache Flink and HBase Data Operations

Computer science4.37 KB

Identify High-Volume Customer Purchases in Flink

The following Java code utilizes Apache Flink to identify customers who purchase more than 10 units of a specific item within a session window.

public class CustomerPurchase {
    public static void main(String[] args) throws Exception {
        final ParameterTool params = ParameterTool.fromArgs(args);
        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<String> text = env.readTextFile(params.get("input"));
        env.getConfig().setGlobalJobParameters(params);

        SingleOutputStreamOperator<Tuple3<Long, Integer, Integer>> mapStream = text.map(new MapFunction<String, Tuple3<Long, Integer, Integer>
...
Continue reading "Mastering Apache Flink and HBase Data Operations" »

FIR vs. IIR Filters: Advantages, Disadvantages, & Structures

Computer science14.44 KB

FIR Filters

A Finite Impulse Response (FIR) filter is characterized by its finite-duration impulse response, settling to zero in a finite time. Unlike Infinite Impulse Response (IIR) filters, which can have internal feedback and respond indefinitely, an Nth-order discrete-time FIR filter's impulse response lasts precisely N+1 samples. FIR filters are predominantly implemented in software and can be continuous-time analog or digital and discrete-time.

Transfer Function of FIR Filter

Z

Frequency Response

Z

IIR Filters

An Infinite Impulse Response (IIR) filter is a recursive filter where the output is calculated using current and previous inputs and outputs. This feedback mechanism within the filter structure is a defining characteristic. IIR filter design...

Continue reading "FIR vs. IIR Filters: Advantages, Disadvantages, & Structures" »