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

Sort by
Subject
Level

Vector Databases & RAG for Semantic Search and Retrieval

Posted by Anonymous and classified in Computers

Written on in English with a size of 206.28 KB

1. Vector Databases — High-Dimensional Embeddings

Store and search high-dimensional vector embeddings. Used in semantic search, similarity search, and RAG pipelines.

Indexing Techniques

  • Flat Index (Brute Force) → accurate but slow.
  • Approximate Nearest Neighbor (ANN) → fast and scalable.
    • Algorithms: HNSW, FAISS, Annoy.
    • f3Q1622KC84AAAAASUVORK5CYII= 8pk5+AsHqPHAAAAAElFTkSuQmCC

3. Retrieval-Augmented Generation (RAG)

Overview

Enhances LLM output by integrating retrieved external knowledge.

  • Reduces hallucination and outdated responses.
  • Improves factual grounding.

RAG Workflow

  1. Indexing: Convert raw data (PDF, HTML, Word) → embeddings.
  2. Retrieval: Retrieve relevant document chunks using similarity search.
  3. Generation: LLM synthesizes results with the query to produce the final answer.

Retrieval Types

TypeDescriptionExample
Sparse
... Continue reading "Vector Databases & RAG for Semantic Search and Retrieval" »

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

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

OLAP vs OLTP: Detailed Database System Comparison

Posted by Anonymous and classified in Computers

Written on in English with a size of 5.15 KB

ChatGPT Interaction

Log in
You said:

Explain in detail the concept of OLAP and OLTP. Also state the difference between them.

ChatGPT said:

Below is a clear, detailed explanation of OLAP and OLTP, followed by a structured comparison of the two.


OLAP (Online Analytical Processing)

Definition:
OLAP refers to systems designed for complex analysis, data modeling, and decision support. It allows users—typically analysts, managers, and executives—to analyze large volumes of historical data from multiple perspectives.

Purpose:
To support strategic decision-making by enabling deep data analysis, trend identification, forecasting, and reporting.

Key Characteristics:

  • Works with large volumes of historical data (often stored in data warehouses).
  • Supports complex
... Continue reading "OLAP vs OLTP: Detailed Database System Comparison" »

Core Java Concepts: Inheritance, Polymorphism & OOP

Posted by Anonymous and classified in Computers

Written on in English with a size of 10.07 KB

Q1. Inheritance in Java (10 Marks)

Inheritance is an important feature of object-oriented programming that allows one class to acquire the properties and methods of another class. The class that gives its features is called the parent class or superclass, and the class that receives them is called the child class or subclass. In Java, inheritance is implemented using the extends keyword.

There are three main types of inheritance in Java:
(1) Single-level inheritance – one parent and one child class.
(2) Multilevel inheritance – one class inherits another, and another class further inherits it.
(3) Hierarchical inheritance – one parent class is inherited by multiple child classes.

Java does not support multiple inheritance using classes to... Continue reading "Core Java Concepts: Inheritance, Polymorphism & OOP" »

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