Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

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

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.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" »

Programming Language Fundamentals: Core Concepts

Posted by Anonymous and classified in Computers

Written on in English with a size of 7.28 KB


1. Why Study Programming Language Concepts?

  • Expressiveness: Leverage diverse language features

  • Selection: Match language to task (e.g., LISP for AI, PHP for web)

  • Learning: Foundations ease uptake of new languages

  • Efficiency: Choose constructs (recursion vs. iteration) for performance

  • Maintenance: Better code reuse and understanding


2. Programming Domains and Typical Languages

DomainFocusLanguage Example
ScientificFloating-point computationsFortran
BusinessReports, decimals, textCOBOL
Artificial IntelligenceSymbolic processing, linked listsLISP/Prolog
SystemsEfficiency, low-level controlC
WebMarkup, scripting, general-purposeHTML/JS/PHP/Java

3. Language Categories

  • Imperative: Variables + assignment + iteration (C, Java, Python, Perl)

  • Functional: Computation

... Continue reading "Programming Language Fundamentals: Core Concepts" »

Programming Fundamentals: Loops, Structures, Functions & File Handling

Classified in Computers

Written on in English with a size of 22.07 KB

When to Use For Loops vs. While Loops

A for loop and a while loop are both used for iteration in programming, but they serve different purposes and are used in different scenarios. Here are three key points to consider when deciding which loop to use:

  • Known vs. Unknown Iterations

    For Loop: Use a for loop when the number of iterations is known beforehand. For example, iterating over a fixed range of numbers or elements in a collection (like an array or list).

    While Loop: Use a while loop when the number of iterations is not known in advance and depends on a condition being met. This is useful for scenarios where you need to continue looping until a specific condition changes (e.g., reading input until a user decides to stop).

  • Control Structure Differences

    For

... Continue reading "Programming Fundamentals: Loops, Structures, Functions & File Handling" »

Essential Object-Oriented Programming Concepts Defined

Posted by Anonymous and classified in Computers

Written on in English with a size of 11.61 KB

Core OOP Definitions

Class and Object

  • Class: A user-defined data structure that binds data members and operations (methods) into a single unit.
  • Object: An instance of a class. Objects are used to perform actions or allow interactions based on the class definition.

Variables and Attributes

  • Method: An action performed using the object's attributes.
  • Attributes: Characteristics or properties of a class. Also known as instance variables (declared outside methods, belonging to one object). They are accessible through static and public methods.
  • Class Variable: Declared using the static keyword; shared among all objects of the class.
  • Local Variables: Declared inside methods, constructors, or blocks; they exist only while the method runs. They cannot be accessed
... Continue reading "Essential Object-Oriented Programming Concepts Defined" »

Computer Security Principles and Cryptographic Systems

Posted by Anonymous and classified in Computers

Written on in English with a size of 29.69 KB

Foundations of Computer Security

The CIA Triad and Security Design Principles

  • Confidentiality: Ensures data is accessible only to authorized entities. It prevents unauthorized disclosure of sensitive information using encryption, access controls, and data masking.
  • Integrity: Guarantees that data remains accurate, complete, and uncorrupted by unauthorized modification or deletion. Maintained using hash functions, checksums, and digital signatures.
  • Availability: Ensures systems, networks, and data remain operational and accessible to authorized users when needed. Protected via hardware redundancy, backups, and DDoS mitigation.
  • Key Design Principles:
    • Least Privilege: Give entities only the minimum permissions necessary to perform their functions.
    • Fail-
... Continue reading "Computer Security Principles and Cryptographic Systems" »

Essential Unity Game Development Concepts

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.94 KB

Sound in Unity

Definition: Sound in Unity is used to add audio effects and background music to games.

Components

  • Audio Source: Plays sound
  • Audio Clip: The audio file
  • Audio Listener: Receives sound

Concept and Application

The Audio Source plays the sound, while the Listener receives it. This adds realism to games and is used for both background music and sound effects.

Canvas and UI in Unity

Definition: The Canvas is used to create user interface elements like buttons, text, and menus in Unity.

Components

  • Canvas
  • Button
  • Text

Concept and Application

UI elements are placed inside the Canvas to facilitate user interaction. It is used in all games to display information such as scores, health, and menus.

Artificial Intelligence (AI) in Unity

Definition: AI in Unity... Continue reading "Essential Unity Game Development Concepts" »

PHP & Web Development Essentials: Core Concepts

Posted by Anonymous and classified in Computers

Written on in English with a size of 315.08 KB

2Q==

9k=

PHP Core Concepts: Quick Answers

PHP Array Types

  • Indexed Array: A normal array with numeric keys.
  • Associative Array: An array with named keys (strings).
  • Multidimensional Array: An array containing one or more other arrays.

PHP Arithmetic Operators

  • + (Addition): Adds two operands.
  • - (Subtraction): Subtracts the second operand from the first.
  • * (Multiplication): Multiplies two operands.
  • / (Division): Divides the first operand by the second.
  • % (Modulus): Returns the remainder of a division.

Understanding PHP Abstract Classes

An abstract class in PHP is a class that cannot be directly instantiated. It may contain abstract methods that must be defined (implemented) in any child classes that inherit from it.

What is a Sticky Form?

A sticky form is a web form that... Continue reading "PHP & Web Development Essentials: Core Concepts" »

OS Concepts: RTOS, Critical Section, Memory & Deadlocks

Posted by Anonymous and classified in Computers

Written on in English with a size of 5.51 KB

Real-Time Operating System (RTOS)

A Real-Time Operating System (RTOS) is an operating system that provides a response within a specified time limit. It is used in applications where timing is critical.

Types of RTOS

  • Hard Real-Time OS: The deadline must be met. Missing a deadline may lead to system failure.
  • Soft Real-Time OS: Occasional delays are acceptable, but performance may be affected.

Applications of RTOS

  • Medical Equipment
  • Robotics
  • Air Traffic Control Systems
  • Industrial Automation
  • Automobile Control Systems

Advantages of RTOS

  • Fast response
  • High reliability
  • Predictable performance

Critical Section

A Critical Section is the part of a program where a process accesses or modifies shared data or resources. Only one process should execute its critical section... Continue reading "OS Concepts: RTOS, Critical Section, Memory & Deadlocks" »

Understanding Microcontrollers: Architecture and Functions

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.16 KB

What is a Microcontroller?

A microcontroller (MC, uC, or μC), also known as a microcontroller unit (MCU), is a small computer on a single integrated circuit. A microcontroller contains one or more processor cores along with memory and programmable input/output (I/O) peripherals.

Microprocessor Core Functions

The core directs all operations of the microprocessor:

  • Instruction Handling: It fetches instructions from memory, decodes them, and sends signals to other units.
  • Role: Think of it as the “manager” of the microprocessor.

Arithmetic and Logic Unit (ALU)

The ALU performs mathematical operations (addition, subtraction, etc.) and logical operations (AND, OR, NOT). It acts as the “calculator” part of the microprocessor.

Registers

Registers are... Continue reading "Understanding Microcontrollers: Architecture and Functions" »

Mastering JavaScript Objects: A Comprehensive Reference

Posted by Anonymous and classified in Computers

Written on in English with a size of 7.71 KB

Introduction to JavaScript Objects

In JavaScript, an object is a self-contained environment that stores data as a collection of properties and methods. A property is an association between a name (or key) and a value, while a method is a function associated with an object.

Think of an object as a real-world entity. For example, a Car is an object. It has properties like color, brand, and weight, and methods like start, drive, and brake.

// A simple conceptual look at an object
let car = {
    brand: "Tesla",       // Property (key: value)
    color: "Red",         // Property
    start: function() {   // Method
        console.log("Engine started!");
    }
};

Types of Objects in JavaScript

While almost everything in JavaScript is an object (or acts... Continue reading "Mastering JavaScript Objects: A Comprehensive Reference" »