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

Sort by
Subject
Level

Python Fundamentals and Algorithms Explained

Classified in Computers

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

Software Engineering Principles and UML Modeling

Posted by Anonymous and classified in Computers

Written on in English with a size of 5.55 KB

What is Software Engineering?

Software Engineering is the application of engineering principles, methods, and tools to the design, development, testing, deployment, operation, and maintenance of software systems in a systematic, disciplined, and measurable way.

Software Process Flows

A software process defines the approach used to develop a system. Common process flows include:

  • Linear/Sequential: Activities are performed one after another in a fixed order. Each phase must be completed before the next begins.
  • Iterative: The development process is repeated in cycles. Each iteration improves the software based on feedback.
  • Evolutionary: The system is developed in versions or increments, where each version adds new features and improves the previous
... Continue reading "Software Engineering Principles and UML Modeling" »

Compiler Design: SDTS, LR Parsing, and Code Optimization

Posted by Anonymous and classified in Computers

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

Digital Logic: Moore's Law, Logic Gates, and Number Systems

Classified in Computers

Written on in English with a size of 708.55 KB

Lecture 1: Moore's Law

Moore's Law: The number of transistors on microchips doubles every two years.

Lecture 2: Logic Gates

I7WgAAAABJRU5ErkJggg==

i3AAAAABJRU5ErkJggg==

+NnQQWHnrkU5hEgARmEjCXFieBuVQxHFZoESCBhRZfu1ongdmFNPtxFQIkMFepI+jBkMCCho4VvYwACczL2qMNLDy0x6cIGoEjR45Iq1atZNWqVbqNnTt3SpUqVYJujxWdQYArMGdwZ68OI4AY19dff10GDBggbdu2lblz50p8fLzDo2L3ZhEggZlFjOXDBgEEmaekpEhcXBzJy6NaJYF5VHEcNhEgAiIkMM4CIkAEPIsACcyzquPAiQARIIFxDhABIuBZBEhgnlUdB04EiAAJjHOACBABzyJAAvOs6jhwIkAESGCcA0SACHgWARKYZ1XHgRMBIkAC4xwgAkTAswiQwDyrOg6cCBABEhjnABEgAp5FgATmWdVx4ESACJDAOAeIABHwLAIkMM+qjgMnAkSABMY5QASIgGcRIIF5VnUcOBEgAiQwzgEiQAQ8iwAJzLOq48CJABEggXEOEAEi4FkESGCeVR0HTgSIAAmMc4AIEAHPIkAC86zqOHAiQAT+DyAtVcWtdpgpAAAAAElFTkSuQmCC

PKhJg4vKJJngcj4CICTBwugs1dMQJeQYCJwyua5HkwAi4iwMThItjcFSPgFQSYOLyiSZ4HI+AiAkwcLoLNXTECXkGAicMrmuR5MAIuIsDE4SLY3BUj4BUEmDi8okmeByPgIgJMHC6CzV0xAl5BgInDK5rkeTACLiLAxOEi2NwVI+AVBJg4vKJJngcj4CICTBwugs1dMQJeQYCJwyua5HkwAi4iwMThItjcFSPgFQSYOLyiSZ4HI+AiAkwcLoLNXTECXkGAicMrmuR5MAIuIsDE4SLY3BUj4BUEmDi8okmeByPgIgJMHC6CzV0xAl5BgInDK5rkeTACLiLAxOEi2NwVI+AVBP4HSdmP4LA25GYAAAAASUVORK5CYII=

5hQAAAAASUVORK5CYII=

eg8CIAACIAACfhGAQPiFDYVAAARAAARAwNkEIBDOjj96DwIgAAIgAAJ+EYBA+IUNhUAABEAABEDA2QT+D4sjTswCubX7AAAAAElFTkSuQmCC

o3LOcXr2Tof4HmKwTSBU6n03g8Hv9jfn5+pseNz2fo4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+AfITIBAvYOjjKxaQAIF2AUPffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXaBf18koFmMFdorAAAAAElFTkSuQmCC

wFbJNthuSOezwAAAABJRU5ErkJggg==

AND, OR, and NOT gates are universal.

Logic word problem steps:

Example: In a bank, there were four employees: the bank manager, assistant manager, teller, and the security guard. The bank has a single vault for the storage of their money. This vault was designed so that it needs four signals to open it. These four signals are from the bank manager, assistant manager, teller, and the security guard. For the vault to open, it needs the following conditions:

  1. No single employee can open the vault.
  2. It can be opened with three employees as long as one of them is the manager.
  3. It can be opened by the manager together with the assistant
... Continue reading "Digital Logic: Moore's Law, Logic Gates, and Number Systems" »

Data Structures and Algorithms Practice Problems

Posted by Anonymous and classified in Computers

Written on in English with a size of 338.98 KB

Q1. Array Address Calculation (Row & Column Major)

Problem: An array ARR[-5...15, 10...20] stores elements in Row Major with each element requiring 2 bytes. Base address is 2500. Find the address of ARR[10][15].

Answer:

  • Row range: -5 to 15, so Lr = -5, Ur = 15
  • Column range: 10 to 20, so Lc = 10, Uc = 20
  • Element size (w) = 2 bytes
  • Base Address (BA) = 2500

Step 1: Calculate dimensions

  • Number of rows (M) = Ur - Lr + 1 = 15 - (-5) + 1 = 21
  • Number of columns (N) = Uc - Lc + 1 = 20 - 10 + 1 = 11

Step 2: Row Major Order Formula

Address(A[i][j]) = BA + [(i - Lr) × N + (j - Lc)] × w
Address(ARR[10][15]) = 2500 + [(10 - (-5)) × 11 + (15 - 10)] × 2
= 2500 + [15 × 11 + 5] × 2
= 2500 + [165 + 5] × 2
= 2500 + 170 × 2 = 2840

Step 3: Column Major Order Formula

Address(... Continue reading "Data Structures and Algorithms Practice Problems" »

Digital Electronics CIE-1 Exam Preparation

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.49 KB

Here is a complete and concise answer sheet for your Digital Electronics CIE-1 preparation based on your questions:


1. Design Half and Full Subtractor with Truth Table

Half Subtractor

  • Inputs: A, B
  • Outputs: Difference (D), Borrow (Bo)
  • Logic Equations:
    • Difference (D) = A ⊕ B
    • Borrow (Bo) = A' · B

Full Subtractor

  • Inputs: A, B, Bin (Borrow In)
  • Outputs: Difference (D), Borrow Out (Bo)
  • Logic Equations:
    • D = A ⊕ B ⊕ Bin
    • Bo = B · Bin + B · A' + A' · Bin

2. Working of Adder and Subtractor

Adder Circuits

  • Half Adder: Adds two bits A and B.
    • Sum = A ⊕ B, Carry = A · B
  • Full Adder: Adds three bits A, B, and Cin.
    • Sum = A ⊕ B ⊕ Cin, Cout = AB + ACin + BCin

Subtractor Circuits

  • Half Subtractor: Subtracts B from A.
    • Difference = A ⊕ B, Borrow = A' · B
  • Full Subtractor:
... Continue reading "Digital Electronics CIE-1 Exam Preparation" »

Essential Python Recursion and Pandas Data Analysis

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.86 KB

Recursive Functions in Python

def range_sum(num_list, start, end):
    if start > end:          # Base case
        return 0
    else:                    # Recursive case
        return num_list[start] + range_sum(num_list, start + 1, end)

numbers = [2, 4, 6, 8, 10]
print(range_sum(numbers, 1, 3))  # Expected output: 18

Tower of Hanoi

def hanoi(n, from_peg, to_peg, temp_peg):
    if n > 0:
        # Step 1: Move n-1 discs to temp peg
        hanoi(n - 1, from_peg, temp_peg, to_peg)
        # Step 2: Move the bottom disc
        print(f"Move disc from peg {from_peg} to peg {to_peg}")
        # Step 3: Move n-1 discs from temp peg to target peg
        hanoi(n - 1, temp_peg, to_peg, from_peg)

Greatest Common Divisor

def gcd(x, y):
    if x
... Continue reading "Essential Python Recursion and Pandas Data Analysis" »

Mastering LVM: Dynamic Storage Management in Linux

Classified in Computers

Written on in English with a size of 3.44 KB

Logical Volume Management (LVM) in Linux Storage

F. The the vast realm of operating systems, Linux has emerged as a robust and versatile choice, powering everything from personal computers to enterprise-level servers. One of its standout features is Logical Volume Management (LVM), a powerful storage management system that offers enhanced flexibility, scalability, and reliability for handling storage devices in Linux environments. LVM revolutionizes how disk partitions and physical storage are managed, providing an abstract layer that simplifies storage administration and facilitates efficient utilization of available resources. By introducing logical volumes, volume groups, and physical volumes (PVs) (originally referred to as "physical books"... Continue reading "Mastering LVM: Dynamic Storage Management in Linux" »

Essential Software Design Patterns and Testing Techniques

Posted by Anonymous and classified in Computers

Written on in English with a size of 6.26 KB

Domain Model

  • Shows concepts only: classes, attributes, associations, and multiplicities.
  • No methods, no UI, and no controllers are included.
  • Purpose: To understand the real-world objects involved in the system.

Use Case Model (Module 6)

  • Focuses on Actor ↔ System interaction.
  • Uses the Verb + Noun naming convention.
  • Format: Defines Actor steps versus System steps.
  • Use cases serve as input for sequence diagrams, which inform class diagrams.

UML Class Diagram (Module 7)

  • Class Components: Name, attributes, and methods.
  • Association: Line connecting classes with multiplicity (1, 0..1, *, 1..*).
  • Inheritance: Represented by an open triangle arrow symbol.
  • Interface: Indicated by the «interface» stereotype.
  • DCD (Design Class Diagram): Explicitly includes methods
... Continue reading "Essential Software Design Patterns and Testing Techniques" »

Python Classes, Objects, and Inheritance Fundamentals

Classified in Computers

Written on in English with a size of 4.11 KB

Understanding Objects in Programming

An object is a software entity that contains data (attributes) and methods. It represents a real-world entity that can be distinctly identified.

Every object has a unique:

  • Identity: The name of the object (e.g., the variable name).
  • State: The data stored in the object, which defines its properties.
  • Behavior: The actions an object can perform, defined by its methods.

Can an object be passed as an argument to a function?

Yes. In Python, objects are passed by reference. This means any changes made to the object's attributes within the function will permanently alter the original object. This behavior is similar to how lists and dictionaries are handled. Think of it as sharing a key to a single locker rather than getting... Continue reading "Python Classes, Objects, and Inheritance Fundamentals" »