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

Software Architecture Essentials: Design Principles & Patterns

Computer science7.09 KB

Software Architecture Fundamentals

  • Definition (IEEE): The fundamental organization of a software system, including components, their relationships, and design principles.

  • Purpose: To ensure reliability, efficiency, security, and maintainability.


Architectural Design Process

  • Goal: Design the system’s overall structure and its communication.

  • Outputs: An architectural model showing component interaction.

  • Key Link: Connects requirements to design.


Software Architecture Documentation

  • Includes:

    • Product Overview

    • Static and Dynamic Architectural Models

    • Mapping Between Models

    • Design Rationale


Architectural Abstraction Levels

  • In the Small: Structure of a single program.

  • In the Large: Structure of enterprise-level systems across networks.


Benefits of Explicit Architecture

  • Stakeholder

...

Continue reading "Software Architecture Essentials: Design Principles & Patterns" »

Python Fundamentals: Strings, Lists, Math, and Plotting Examples

Computer science6.74 KB

P1: Python String Manipulation Techniques

Demonstrating String Operations

s = "hello"
print(s.capitalize())
print(s.upper())
print(s.rjust(100))
print(s.center(100))
print(s.replace('l','(M)'))
print(s)
print("don't")

Indexing

a = 'symbiosis2024'
print(a[2])

Negative Indexing

print(a[-1])
print(a[-6])

Slicing

print(a[9:12])
print(a[9:])
print(a[9:-1])
print(a[:8])
print(a[-12:-1])

Stride [start index:end index:step size]

print(a[0:13:2])
print(a[0::2])

Concatenation

b = 'hello'
c = 'world'
d = b + c
print(d)
e = b + " " + c
print(e)

Repetition

f = a * 3
print(f)
g = "2024"
print(g * 2)
print(a + '2')

Reversing a String

print(a[::-1])

Split

h = "sspu"
print(h.split()) # Returns a list
i = "05/08/2024"
print(i.split("/"))
j = "14:20:25"
print(j.split("
...
Continue reading "Python Fundamentals: Strings, Lists, Math, and Plotting Examples" »

Compiler Design: SDTS, LR Parsing, and Code Optimization

Computer science232.62 KB

Syntax-Directed Translation Schemes (SDTS)

A possible Syntax-Directed Translation Scheme (SDTS) uses the attribute val to store the value of each non-terminal.

  • E → E1 + T { E.val = E1.val + T.val }
  • E → T { E.val = T.val }
  • T → T1 * F { T.val = T1.val * F.val }
  • T → F { T.val = F.val }
  • F → num { F.val = num.value }

Bottom-Up Evaluation of 3 + 2 * 4

Evaluation using SDTS (bottom-up):

  • F → num(4): F.val = 4
  • F → num(2): F.val = 2
  • F → num(3): F.val = 3
  • T → F (for num(2)): T.val = F.val = 2
  • T → T * F: T.val = T.val (from num(2)) * F.val (from num(4)) = 2 * 4 = 8
  • T → F (for num(3)): T.val = F.val = 3
  • E → T (for num(3)): E.val = T.val = 3
  • E → E + T: E.val = E.val (from num(3)) + T.val (from 2 * 4) = 3 + 8 = 11

Therefore, the result of the computation...

Continue reading "Compiler Design: SDTS, LR Parsing, and Code Optimization" »

Neural Networks: Neurons, Activation, Structure

Computer science3.62 KB

Biological Neurons

A biological neuron is the fundamental unit of the nervous system, responsible for transmitting information throughout the body. It consists of three main parts:

  • Dendrites: These are branch-like structures that receive signals from other neurons and transmit them to the cell body.
  • Cell Body (Soma): Contains the nucleus and other essential organelles responsible for processing information.
  • Axon: A long, thread-like extension that carries nerve impulses away from the cell body to other neurons, muscles, or glands.

Neurons communicate using electrical and chemical signals through synapses, where neurotransmitters help in transmitting the signals. The brain contains billions of neurons that work together to perform cognitive functions,...

Continue reading "Neural Networks: Neurons, Activation, Structure" »

Java Implementations: Dijkstra, Balanced BST, and Hash Table

Computer science5.54 KB

Java Implementations of Dijkstra's Algorithm, a Balanced Binary Tree, and a Hash Table

Dijkstra's Shortest Path Algorithm

The following class implements Dijkstra's algorithm to compute the shortest distances from a source node to all other nodes in a weighted graph.

import java.util.*;

class Dijkstra {
static class Edge {
int dst, weight;

Edge(int dst, int weight) {
this.dst = dst;
this.weight = weight;
}
}

public static Map<Integer, Integer> shortestPath(int source, Map<Integer, List<Edge>> graph) {
Map<Integer, Integer> distances = new HashMap<>();
PriorityQueue<int[]> pq = new PriorityQueue<>(Comparator.comparingInt(a -> a[1]));

for (int node : graph.keySet()) {
distances.put(node, Integer.MAX_VALUE);
}
distances....

Continue reading "Java Implementations: Dijkstra, Balanced BST, and Hash Table" »

Find the Largest Number and Calculate Factorial in C++

Computer science2.11 KB

Input three numbers and find the largest. Enter a number and display the day name of the week.
#include
#include
using namespace std;
using namespace std;
int main() {
int num1, num2, num3;
int day;
cout << "Enter three numbers: ";
cout << "Enter a number (From 1 to 7): ";
cin >> num1 >> num2 >> num3;
cin >> day;
if (num1 > num2 && num1 > num3) {
cout << "Largest number is " << num1;
} else if (num2 > num3) {
cout << "Largest number is " << num2;
} else {
cout << "Largest number is " << num3;
}
switch (day) {
case 1: cout << "Sunday"; break;
case 2: cout << "Monday"; break;
...

Continue reading "Find the Largest Number and Calculate Factorial in C++" »

Key Characteristics of Effective Database Management

Computer science2.4 KB

A database has several key characteristics that make it an essential tool for managing information efficiently. Here are the main characteristics explained in simple language:

  • Structured Data Storage: Databases store data in a structured format, usually in tables with rows and columns. This structure makes it easy to organize, manage, and retrieve information.
  • Data Integrity: Databases ensure the accuracy and consistency of data. Rules can be set to prevent errors, such as entering text into a field meant for numbers or duplicating records.
  • Data Security: Databases provide features to protect data from unauthorized access. You can set permissions to control who can view, update, or delete data, ensuring that sensitive information remains secure.
...
Continue reading "Key Characteristics of Effective Database Management" »

Software Engineering Fundamentals: Principles and Requirements Analysis

Computer science2.91 KB

Definition of Software Engineering

Software engineering is the establishment and use of sound engineering principles in order to obtain software economically that is reliable and works efficiently on real machines.

Need for Software Requirements Specification (SRS)

The Software Requirements Specification (SRS) is necessary because it provides:

  • A detailed overview of the software product, including its parameters and goals.
  • A description of the project's target audience, user interface, and hardware and software requirements.
  • A common understanding of how the client, development team, and audience perceive the product and its functionality.

Four Core Principles of Software Engineering

1. The Reason It All Exists (Value to Users)

  • A software system exists
...
Continue reading "Software Engineering Fundamentals: Principles and Requirements Analysis" »

Java Socket Programming and Nmap Network Scanning

Computer science3.5 KB

Java Socket Programming Implementation

Code: Server-Side

import java.io.*;
import java.net.*;

public class MyServer {
    public static void main(String[] args) {
        try {
            ServerSocket ss = new ServerSocket(6666);
            Socket s = ss.accept();
            DataInputStream dis = new DataInputStream(s.getInputStream());
            String str = (String) dis.readUTF();
            System.out.println("Message: " + str);
            ss.close();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

Client-Side Code:

import java.io.*;
import java.net.*;

public class MyClient {
    public static void main(String[] args) {
        try {
            Socket s = new Socket("localhost", 6666);
...
Continue reading "Java Socket Programming and Nmap Network Scanning" »

Essential Computer Science: Binary, OS Kernel, Von Neumann, Assembly

Computer science53.68 KB

Binary Operations and Number Systems

s8wZJYEAlCkAAAAASUVORK5CYII=

Bitwise Shift Operations

Left Shift

The left shift operator (<<) shifts bits to the left, filling the vacated positions on the right with zeros. This is equivalent to multiplying the number by powers of two.

Right Shift

The right shift operator (>>) shifts bits to the right. There are two types:

  • Logical Right Shift: Fills the vacated positions on the left with zeros.
  • Arithmetic Right Shift: Fills the vacated positions on the left with the most significant bit (sign bit) of the original number, preserving the sign for signed integers.

Decimal to Binary Conversion

To convert a decimal number to binary, repeatedly divide the decimal number by 2. Record the remainder (which will be either 0 or 1) from right...

Continue reading "Essential Computer Science: Binary, OS Kernel, Von Neumann, Assembly" »