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

It used to define the member functions of a class outside

Computer science3.65 KB

Q1. Difference between Object Oriented Programming (OOP) and Procedure Oriented Programming (POP)

(12 Marks – Expanded Answer)

Programming is the process of writing instructions for a computer.
Based on program design, programming languages are mainly divided into Procedure Oriented Programming (POP) and Object Oriented Programming (OOP).


Procedure Oriented Programming (POP)

Procedure Oriented Programming is a traditional approach of programming in which functions play the main role.
The program is divided into a number of functions and these functions work on shared data.

In POP, data is not secure because most data is declared globally and can be accessed by any function.
Due to this reason, POP is suitable only for small and simple programs.

Main

...
Continue reading "It used to define the member functions of a class outside" »

Essential Array Algorithms: Span, Second Largest, Floor, Ceil, and Bitonic Search

Computer science4.59 KB

1. Span of Array

Problem Statement:
Find the span of an array (the difference between the maximum and minimum elements).

Example:
Input: [3, 4, 7, 10, 1]
Output: 9 (since 10 - 1 = 9)

Approach:

  • Initialize max = -∞ and min = +∞.
  • Traverse the array once:
    • Update max if the current element is greater than max.
    • Update min if the current element is less than min.
  • Return max - min.

Time Complexity: O(n)
Space Complexity: O(1)

2. Second Largest Element

Problem Statement:
Find the second largest element in an array without sorting it.

Example:
Input: [20, 42, 99, 10, 88, 6]
Output: 88

Approach:

  • Initialize two variables: max1 (largest) and max2 (second largest).
  • Compare the first two elements to set initial values for max1 and max2.
  • From the third element onward, iterate:
...
Continue reading "Essential Array Algorithms: Span, Second Largest, Floor, Ceil, and Bitonic Search" »

Information Security Fundamentals: Concepts, Cryptography, and Jamming Defenses

Computer science8.66 KB

What is Information Security?

Information security means protecting data from theft, alteration, destruction, disclosure, or denial of access. It has traditionally relied on physical measures (e.g., locked cabinets) and administrative controls (e.g., personnel screening). Even today, some reliance on physical security remains.

Modern Information Security Needs

With increased computer usage, automated tools are now essential for protecting stored information. As network usage grows, securing data during transmission has become equally essential.

Aspects of Information Security (ITU-T X.800/1205)

  • Security Attack: Any action that compromises system security.
  • Threat: A potential violation, defined as capability plus intent.
  • Security Mechanism: Any policy
...
Continue reading "Information Security Fundamentals: Concepts, Cryptography, and Jamming Defenses" »

C# Design Patterns: Essential Reference for Developers

Computer science12.41 KB

C# Design Patterns: Essential Reference

Creational Design Patterns

PatternWhen to UseKey Implementation
SingletonNeed exactly one instance globally accessible.private static Singleton _instance;
public static Singleton Instance => _instance ??= new Singleton();
FactoryCreate objects without specifying concrete classes.public static IProduct Create(string type) => type switch { "A" => new ProductA(), ... }
BuilderConstruct complex objects step-by-step.public class CarBuilder { ... public CarBuilder WithEngine(...) { ... } }
PrototypeClone existing objects instead of creating new ones.public interface IPrototype { IPrototype Clone(); }

Structural Design Patterns

PatternWhen to UseKey Implementation
AdapterMake incompatible interfaces work together.
...
Continue reading "C# Design Patterns: Essential Reference for Developers" »

Dafny Verification and Formal Methods Exam Review

Computer science644.93 KB

Dafny Concepts and Preconditions

Preconditions are required; postconditions are ensured.

Methods do not change given parameters unless a modifies clause is present.

Old(E) has the value of E at the start of the method.

Fresh(E) as a postcondition shows that E was created by M.

With if statements, Dafny works normally. With if-case statements, you introduce nondeterminism (hard; you need to prove all options).

Classes have instance variables and methods, which need clear contracts.

A trait is an abstract class, from which classes inherit (like a template in Java). Example: trait A; class B extends A

Class invariants must hold before and after any method. Use ghost predicate Valid().

Behavioral Subtyping: When a class A inherits from another class/trait,...

Continue reading "Dafny Verification and Formal Methods Exam Review" »

Understanding the Spiral Model in Software Development

Computer science2.13 KB

What Is the Spiral Model?

The Spiral Model is a Software Development Life Cycle (SDLC) model that provides a systematic and iterative approach to software development. In its diagrammatic representation, it looks like a spiral with many loops. The exact number of loops is unknown and can vary from project to project. Each loop of the spiral represents a phase of the software development process.

Key Points of the Spiral Model

  • The exact number of phases needed to develop the product can be varied by the project manager depending upon the project risks.
  • As the project manager dynamically determines the number of phases, they have an important role in developing a product using the spiral model.
  • It is based on the idea of a spiral, with each iteration
...
Continue reading "Understanding the Spiral Model in Software Development" »

PHP Programming Essentials and Core Features

Computer science2.95 KB

What is PHP?

PHP (Hypertext Preprocessor) is a widely-used open-source scripting language primarily designed for web development. It runs on the server-side, meaning the code is executed on the web server before the output is sent to the user's browser. PHP is embedded within HTML and supports various databases, making it a powerful tool for creating dynamic and interactive web applications.

Key Features of PHP

PHP has several features that make it a popular choice for web development:

  • Open-Source – PHP is free to use, with a large community of developers providing support and updates.
  • Cross-Platform Compatibility – PHP works on multiple operating systems like Windows, Linux, and macOS.
  • Easy to Learn and Use – Its syntax is simple and similar
...
Continue reading "PHP Programming Essentials and Core Features" »

Master API Testing: Core Concepts and Best Practices

Computer science3.52 KB

API Testing Fundamentals

Definition: API testing involves verifying that APIs meet functionality, performance, reliability, and security requirements.

Types of APIs

  • REST
  • SOAP
  • GraphQL
  • gRPC

Key Components of API Testing

Endpoints

  • URI: Unique resource identifier.
  • Methods: HTTP/HTTPS methods like GET, POST, PUT, and DELETE.

Request Components

  • Headers: Transfer metadata (e.g., Authorization, Content-Type).
  • Body: Data payload for POST or PUT requests, usually in JSON or XML format.
  • Parameters: Path, query, and form parameters used to pass data.

Core Testing Types

  • Functional Testing: Validate API operations and output against requirements.
  • Performance Testing: Assess speed, scalability, and reliability under load.
  • Security Testing: Ensure the API protects data and
...
Continue reading "Master API Testing: Core Concepts and Best Practices" »

Python Fundamentals and Algorithms Explained

Computer science5.17 KB

Algorithms

Algorithms involve inputs, instructions, outputs, and a purpose.

Instruction Types

  • Instruction
  • Decision
  • Loop
  • Variable
  • Function

Python Basics

Comments

Comments explain what code is for, intended for human readers.

Variables

Storing a value in a variable is called assignment. It's best practice not to use generic names.

Calculations (Operators)

  • + : Addition
  • - : Subtraction
  • * : Multiplication
  • / : Division
  • // : Integer Division (e.g., 6 // 4 = 1)
  • % : Remainder / Modulo (e.g., 6 % 4 = 2)
  • ** : Exponentiation

mass_in_kg = 15

weight_in_pounds = mass_in_kg * 2.2

print('the weight in pounds is: ', weight_in_pounds)

user_name = input("enter your user name: ")

print('hello', user_name)

Data Types

  • int: Integer numbers (e.g., -1, 0, 2, 1000)
  • float: Floating-point (real)
...
Continue reading "Python Fundamentals and Algorithms Explained" »

Set-UID Security and Buffer Overflow Exploitation

Computer science3.95 KB

Set-UID Privilege Management

The Set-UID approach provides the following:

  • Fine-grained access control.
  • Normal users run special programs to gain privileges and conduct privileged operations.
  • No need for a background process; therefore, it offers better performance.
  • A larger attack surface, as environment variables come from the user process.
  • A Set-UID process does not always run with root privileges; it runs with the program owner's privileges.

Process Inheritance and Shell Variables

Environment Variables in fork() and execve()

  • In the case of fork(), all environment variables from the parent process are inherited by the child process.
  • In the case of execve(), the inherited environment variables are decided based on the parameters provided to the execve(
...
Continue reading "Set-UID Security and Buffer Overflow Exploitation" »