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

Sort by
Subject
Level

Java Programming: Classes, Objects, and Key Concepts

Classified in Computers

Written on in English with a size of 5.28 KB

Classes (الصفوف)

  • A class consists of variables (fields) and methods.
  • Variables are data members of a class.
  • Methods are functions that define the class's behavior.

Variables (المتغيرات)

  • Declared with a data type and a name.
  • Can be public or private.
  • Examples: int age, String name.

Methods (الأساليب)

  • Functions that perform specific tasks.
  • Can have parameters and return values.
  • Types:
    • Void methods: Don't return a value.
    • Return type methods: Return a value.
    • Static methods: Can be called without creating an object.
    • Instance methods: Require an object to be called.
    • Abstract methods: Declared without a body; used in abstract classes.
    • Overloaded methods: Multiple methods with the same name but different parameters.

Constructors (البناؤون)

... Continue reading "Java Programming: Classes, Objects, and Key Concepts" »

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" »

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" »

C Code Examples: Data Structures and Algorithms

Classified in Computers

Written on in English with a size of 5.54 KB

Recursive Binary Tree Traversals

Inorder Traversal:

void inorder(struct node *root)
{
  if(root != NULL)
  {
    inorder(root->left);
    printf("%d\t", root->data);
    inorder(root->right);
  }
}

Preorder Traversal:

void preorder(struct node *root)
{
  if(root != NULL)
  {
    printf("%d\t", root->data);
    preorder(root->left);
    preorder(root->right);
  }
}

Postorder Traversal:

void postorder(struct node *root)
{
  if(root != NULL)
  {
    postorder(root->left);
    postorder(root->right);
    printf("%d\t", root->data);
  }
}

Linked List Operations

Search

void search(struct node *head,int key)
{
  struct node *temp = head;
  while(temp != NULL)
  {
    if(temp->data == key)
      printf("key found");
    temp =
... Continue reading "C Code Examples: Data Structures and Algorithms" »

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" »

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+jBkMCCho4VvYwACczL2qMNLDy0x6cIGoEjR45Iq1atZNWqVbqNnTt3SpUqVYJujxWdQYArMGdwZ68OI4AY19dff10GDBggbdu2lblz50p8fLzDo2L3ZhEggZlFjOXDBgEEmaekpEhcXBzJy6NaJYF5VHEcNhEgAiIkMM4CIkAEPIsACcyzquPAiQARIIFxDhABIuBZBEhgnlUdB04EiAAJjHOAC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ffgHyEyAQL2Do4ysWkACBdgFD334B8hMgEC9g6OMrFpAAgXYBQ99+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" »

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" »

Mastering Stacks, Deques, Trees, and Graph Data Structures

Classified in Computers

Written on in English with a size of 21.54 KB

A stack is a fundamental data structure in computer science that follows the Last In, First Out (LIFO) principle. This means that the last element added to the stack is the first one to be removed. You can think of it like a stack of plates: you can only add or remove the top plate.

### Key Concepts of a Stack:

1. Basic Operations:
   - Push: This operation adds an element to the top of the stack.
   - Pop: This operation removes the element from the top of the stack and returns it.
   - Peek (or Top): This operation returns the top element of the stack without removing it.
   - IsEmpty: This operation checks whether the stack is empty.

2. Implementation:
   Stacks can be implemented using arrays or linked lists. Here are the details for... Continue reading "Mastering Stacks, Deques, Trees, and Graph Data Structures" »