Notes, summaries, assignments, exams, and exercises for Computer science for Other courses

Java Inheritance and Polymorphism Examples

Computer science3.49 KB

Single Inheritance in Java

This Single Inheritance program demonstrates how a child class inherits properties and methods from a single parent class.

class Animal {
    // Constructor of Parent class
    Animal() {
        System.out.println("Animal constructor called");
    }
    // Method of Parent class
    void eat() {
        System.out.println("I can eat");
    }
}

// Child class inheriting from Animal
class Dog extends Animal {
    // Constructor of Child class
    Dog() {
        System.out.println("Dog constructor called");
    }
    // Method of Child class
    void bark() {
        System.out.println("I can bark");
    }
}

// Main class to test inheritance
public class Main {
    public static void main(String[] args) {
        /
...
Continue reading "Java Inheritance and Polymorphism Examples" »

Software Engineering Principles and System Design

Computer science301.21 KB

Software Engineering and Processes

Agile Manifesto

  • Individuals/Interactions over Processes
  • Working software over documentation
  • Collaboration over negotiation
  • Responding to change over following a plan

Requirements Engineering

Descriptions of the services that a system should provide and the constraints on its operation.

Functional

What the system should do.

Non-functional

Not directly concerned with the specific services delivered by the system to its users.

Quality Attributes

A scenario describing quality attributes typically involves these elements:

  1. Source: Origin of the stimulus.
  2. Stimulus: The event arriving.
  3. Artifact: Where the event arrives.
  4. Environment: Conditions in which the scenario takes place.
  5. Response: The result of the event.
  6. Response Measure: Must
...
Continue reading "Software Engineering Principles and System Design" »

Essential SSH and SCP Command Cheat Sheet

Computer science4.22 KB

Connecting via SSH

Connect to a server (default port 22):

$ ssh [email protected]

Connect on a specific port:

$ ssh [email protected] -p 6222

Connect via PEM file (requires 0400 permissions):

$ ssh -i /path/file.pem [email protected]

See: SSH Permissions

Executing Remote Commands

Execute a remote command:

$ ssh [email protected] 'ls -l'

Invoke a local script:

$ ssh [email protected] bash < script.sh

Compress and download from a server:

$ ssh [email protected] "tar cvzf - ~/source" > output.tgz

SCP File Transfers

  • Copy from remote to local: scp user@server:/dir/file.ext dest/
  • Copy between two servers: scp user@server:/file user@server:/dir
  • Copy from local to remote: scp dest/file.ext user@server:/dir
  • Copy a whole folder: scp -r user@server:/dir dest/
  • Copy all files
...
Continue reading "Essential SSH and SCP Command Cheat Sheet" »

Excel & Business Software Essentials for Data Management

Computer science3.04 KB

Mastering Excel & Business Software Essentials

This document covers fundamental and advanced concepts in Microsoft Excel, alongside an introduction to Tally ERP accounting software, providing insights into essential tools for data management and business operations.

Excel Macros: Automation & VBA

A macro is a small program created in Excel to automate repetitive tasks, saving significant time and effort. Macros are developed using VBA (Visual Basic for Applications), which allows their functionality to be linked to a button or other triggers. It's essential to record or write a macro before it can be executed.

Understanding Excel Cells

A cell in Excel is a fundamental, box-like structure that forms the grid of rows and columns within a worksheet....

Continue reading "Excel & Business Software Essentials for Data Management" »

Python Django Project Setup and Database Integration

Computer science4.14 KB

Python Django Project Setup

Follow these steps to initialize and configure your Python Django environment.

Initial Environment Navigation

  • Step 1: Open the Command Prompt and use cd.. to navigate back.
  • Step 2: Use cd.. again to reach the desired root.
  • Step 3: Navigate to your Python directory: cd Raj_Python.
  • Step 4: Enter your project folder: cd mscit_dproject.

Creating the Project and Application

  • Step 5: Create the project: django-admin startproject [Project Name].
  • Step 6: Navigate into the project folder: cd [Project Name].
  • Step 7: Create a new application: python manage.py startapp [App Name].
  • Step 8: Open the project in VS Code and configure settings.py.

Configuring settings.py

In settings.py, import the OS module and define your template directory:

import

...
Continue reading "Python Django Project Setup and Database Integration" »

Python Algorithms: Sorting, Searching, and Knapsack

Computer science3.72 KB

Selection Sort

The Selection Sort algorithm sorts an array by repeatedly finding the minimum element from the unsorted part and putting it at the beginning.

array = [45, 2, 23, 76, 7]

for i in range(0, len(array) - 1):
    smallest = array[i]
    pos = i
    for j in range(i + 1, len(array)):
        if array[j] < smallest:
            smallest = array[j]
            pos = j
    array[pos] = array[i]
    array[i] = smallest

print(array)

Insertion Sort

Insertion Sort is a simple sorting algorithm that builds the final sorted array one item at a time, which is much less efficient on large lists than more advanced algorithms.

array = [35, 7, 18, 30]

for i in range(1, len(array)):
    testPosition = i - 1
    while True:
        if testPosition
...
Continue reading "Python Algorithms: Sorting, Searching, and Knapsack" »

CPU Scheduling Algorithms and Message Passing Mechanisms

Computer science3.21 KB

Guaranteed Scheduling

Guaranteed scheduling algorithms aim to ensure that each process receives its fair share of CPU time. These systems penalize processes that have consumed a large amount of CPU time, though this penalty fades over time. This approach is utilized in most versions of UNIX, Windows NT, and subsequent Linux distributions.

BSD Scheduler

Unlike legacy UNIX schedulers, the BSD scheduler accounts for system load by monitoring the length of the ready queue, known as the "Load average." Additionally, it forgives old CPU usage more slowly when the system load is high.

Linux 2.4 Scheduler

Epoch-Based Allocation

The Linux 2.4 scheduler partitions CPU time into epochs. At the start of each epoch, every process is assigned a time quantum, which...

Continue reading "CPU Scheduling Algorithms and Message Passing Mechanisms" »

Theory of Computation: Automata, and Regular Expressions

Computer science3.97 KB

Theory of Computation

Automata Theory

Automata theory is a theoretical branch of computer science and mathematics that deals with the logic of computation using simple machines called automata. The main goal of automata theory is to develop methods for describing and analyzing the dynamic behavior of discrete systems. Automata consist of states (represented by circles) and transitions (represented by arrows).

Finite Automata

A finite automaton is an abstract computing device and a mathematical model of a system with discrete input, output, states, and a set of transitions between states that occur on input symbols from an alphabet. Finite automata are the simplest machines for pattern recognition, used to characterize regular languages, analyze...

Continue reading "Theory of Computation: Automata, and Regular Expressions" »

Complete CSS Pseudo-Class Reference

Computer science10.29 KB

CSS Pseudo-Class Reference

SelectorExampleDescription
:activea:activeSelects the active link.
:checkedinput:checkedSelects every checked element.
:disabledinput:disabledSelects every disabled element.
:emptyp:emptySelects every <p> element that has no children.
:enabledinput:enabledSelects every enabled element.
:first-childp:first-childSelects every <p> element that is the first child of its parent.
:first-of-typep:first-of-typeSelects every <p> element that is the first <p> element of its parent.
:focusinput:focusSelects the element that has focus.
:hovera:hoverSelects links on mouse over.
:in-rangeinput:in-rangeSelects elements with a value within a specified range.
:invalidinput:invalidSelects all elements with an invalid value.
...
Continue reading "Complete CSS Pseudo-Class Reference" »

Core Concepts in Data Processing and Information Retrieval

Computer science3.3 KB

Fundamental Concepts in Knowledge and Data

  • The most fundamental combiner is the unification of the Self with itself, which gives rise to the knower, the process of knowing, and the known.
  • Normalization is a mathematically interesting, bottom-up technique for producing a set of relations with desirable properties from a set of mathematical dependencies in the data.
  • A graphical technique employed by Vedic science is the unified field chart, which provides a holistic overview of a discipline and links all knowledge with the Self.

Data Compression Techniques

Variable-Length Integer Coding (VarInt)

A simple approach to compression is to use only as many bytes as necessary to represent an integer. This technique is known as variable-length integer coding...

Continue reading "Core Concepts in Data Processing and Information Retrieval" »