Notes, summaries, assignments, exams, and problems for Computer science

C Implementation of Queues, Linked Lists, and Search Algorithms

Computer science17.79 KB

Circular Queue Implementation Using Linked Lists

This C program demonstrates the implementation of a circular queue using a linked list structure. The queue handles integer data.

Data Structure Definition

#include <stdio.h>
#include <stdlib.h>

typedef struct QueueType {
    int Data;
    struct QueueType *Next;
} QUEUE;

QUEUE *Front = NULL; // Pointer to the front of the queue
QUEUE *Rear = NULL;  // Pointer to the rear of the queue

// Function prototypes
void Enqueue(int Num);
int Dequeue();
void DisplayQueue();
int Menu();

Enqueue Operation

The Enqueue function inserts a number into the circular queue. It handles memory allocation and maintains the circular link by ensuring Rear->Next always points to Front.

void Enqueue(int Num)
...
Continue reading "C Implementation of Queues, Linked Lists, and Search Algorithms" »

Analyzing Algorithms: Recurrence Relations and Graph Matrix Structures

Computer science3.36 KB

Recurrence Relations in Algorithm Analysis

LHRR (Last Half Recurrence Relation) and DCRR (Divide-and-Conquer Recurrence Relation) are fundamental types of recurrence relations commonly encountered when analyzing the efficiency of divide-and-conquer algorithms.

Last Half Recurrence Relation (LHRR)

In LHRR, the recurrence relation describes the time complexity of an algorithm by recursively breaking down the problem into two subproblems of equal size, solving one, and ignoring the other. This approach implies that the work done in each step is proportional to the size of the problem being solved.

The relation is often expressed as: T(n) = T(n/2) + O(1), where T(n) represents the time complexity of the algorithm for a problem of size n. It is called...

Continue reading "Analyzing Algorithms: Recurrence Relations and Graph Matrix Structures" »

Content

Computer science9.51 KB

Javascript Continued

  1. The document.GetElementById() method returns the DOM node whose id attribute is the same as the method's parameter.
    Ex: document.GetElementById("early_languages") returns the p node in the HTML below.

  2. The document.GetElementsByTagName() method returns an array containing all the DOM nodes whose type is the same as the method's parameter.
    Ex: document.GetElementsByTagName("li") returns a list of the four li nodes from in the HTML below.

  3. The document.GetElementsByClassName() method returns an array containing all the DOM nodes whose class attribute matches the method's parameter.
    Ex: document.GetElementsByClassName("traditional") returns an array containing the ol node with the class attribute matching the word traditional.

...
Continue reading "Content" »

Essential Revit Terminology and Interface Concepts

Computer science3.67 KB

Building Information Modeling (BIM)

BIM is a complete representation or depiction of a building that aids in its design, construction, and continuous management. This is an evolving concept that changes as technological capabilities improve.

Revit Elements

An element in Revit is a discrete building block or piece of data, such as an object or drawing sheet. The four basic types of elements are:

  • Model Elements: Walls, doors, roofs.
  • Datum Elements: Levels, grids, reference planes.
  • Annotation Elements: Tags, text, dimensions.
  • View Elements: Plans, sections, schedules.

Views and Drafting

  • Detail Line: Designed to appear only in the view in which it is placed. It is treated as an embellishment to that particular view and is not added physically to the building
...
Continue reading "Essential Revit Terminology and Interface Concepts" »

MySQL Essentials: Database & Table Management Commands

Computer science5.6 KB

MySQL Essentials: Database & Table Management

Connecting to MySQL

To connect to a MySQL server, use the following command:

mysql -u [username] -p [password]

Database Operations

Viewing Databases

To see all available databases:

SHOW DATABASES;

Creating a Database

To create a new database:

CREATE DATABASE [database_name];

Selecting a Database

To select a database to work with:

USE [database_name];

Table Operations

Viewing Tables

To list all tables within the currently selected database:

SHOW TABLES;

Viewing Table Structure

To display the structure (columns, data types, etc.) of a specific table:

DESCRIBE [table_name];

Creating a Table

To create a new table within the selected database:

CREATE TABLE [table_name] (
    [field_name_1] [data_type_1] [field_definitions_
...
Continue reading "MySQL Essentials: Database & Table Management Commands" »

Operating System Free Space and File Allocation Methods

Computer science5.36 KB

Free Space Management in OS

Free Space Management is a technique used by the operating system to keep track of unused disk blocks. It helps the file system allocate space to new files and deallocate space when files are deleted.

Objective: To efficiently manage and utilize available disk space.

Need for Free Space Management

  • To identify free disk blocks quickly.
  • To allocate storage space for new files.
  • To reclaim space when files are deleted.
  • To improve disk utilization and system performance.

Methods of Free Space Management

1. Bit Vector (Bitmap) Method

In this method, each disk block is represented by a bit.

  • 0 → Free block
  • 1 → Allocated block

Example

Block Number01234567
Bitmap10110010

Here, blocks 1, 4, 5, and 7 are free.

Advantages

  • Easy to find contiguous
...
Continue reading "Operating System Free Space and File Allocation Methods" »

Memory Management and File System Architecture

Computer science12.9 KB

1. Demand Paging

In a standard virtual memory system, the operating system does not load an entire program into physical memory (RAM) at once. Instead, it uses Demand Paging—a strategy where pages are loaded into memory only when they are needed (on demand).

How It Works: The Page Fault Mechanism

  1. CPU Reference: The CPU tries to access a specific virtual address.
  2. Page Table Check: The Hardware (MMU) checks the page table entry for that page. Each entry has a Valid/Invalid (V/I) Bit:
    • Valid (1): The page is already in RAM. The address is translated, and execution continues.
    • Invalid (0): The page is currently on the disk (hard drive/SSD). This triggers a Page Fault interrupt.
  3. OS Trap: The operating system takes control to handle the page fault.
  4. Disk
...
Continue reading "Memory Management and File System Architecture" »

Understanding Binary Conversion and Computer Performance

Computer science3.88 KB

Binary Conversion

Single-Precision Floating-Point

Format: 1 sign bit, 8 exponent bits, 23 fraction bits

Bias: +127 (decimal to binary), -127 (binary to decimal)

Double-Precision Floating-Point

Format: 1 sign bit, 11 exponent bits, 52 fraction bits

Bias: +1023 (decimal to binary), -1023 (binary to decimal)

Example: -17.6875 (Single-Precision)

  1. Sign Bit: + = 0, - = 1 (In this case, 1)
  2. Integer Part to Binary: Repeatedly divide the integer part by 2 and record the remainders.
  3. Fractional Part to Binary: Repeatedly multiply the fractional part by 2 and record the integer parts.
  4. Combine and Normalize: Combine the binary integer and fractional parts. Normalize to the form 1.xxx * 2^exponent.
  5. Calculate Exponent: Add the bias to the exponent.
DivideAnswerRemainder
17
...
Continue reading "Understanding Binary Conversion and Computer Performance" »

Understanding SEO: A Comprehensive Guide to Search Engine Optimization

Computer science4.24 KB

Understanding Search Engine Optimization (SEO)

Crawling and Indexing

Web crawlers, also known as bots, robots, or spiders, are software programs designed to follow links, gather information, and send it back to search engines for indexing. This process allows search engines to understand the content and structure of websites.

Evolution of Google Search Algorithms

Over the years, Google has implemented various algorithm updates to improve search results and combat spam. Some notable updates include:

  • Google Dance (2002): Click-through rates started influencing search rankings.
  • Austin (2004): Targeted websites with keyword stuffing.
  • Google Suggest (2008) & Google Instant (2010): Introduced predictive search based on search history.
  • Hummingbird (2013)
...
Continue reading "Understanding SEO: A Comprehensive Guide to Search Engine Optimization" »

Digital Graphics and Media: Terms and Definitions

Computer science3.97 KB

Digital Graphics and Media: Key Terms

Image Fundamentals

  • Pixel: Individual dots that make up bitmap graphics.
  • Dots Per Inch (DPI): Also known as printer resolution. The number of dots of color a printer can produce in a certain amount of space.
  • Pixels Per Inch (PPI): The measurement of pixelation on an output device, such as a computer screen.
  • 300 PPI: The typical PPI needed for professional and commercial prints, such as advertising hoardings, for acceptable quality.
  • Megapixel: A unit used to measure the resolution of digital cameras, referring to one million pixels.
  • Bit Depth: Refers to the number of colors in an image.

Vector vs. Bitmap Graphics

  • Vector Graphics: Graphics stored as a series of mathematical shapes and properties that can be independently
...
Continue reading "Digital Graphics and Media: Terms and Definitions" »