Notes, summaries, assignments, exams, and exercises for Computer science for University

Bisection and Regula Falsi Methods in C Programming

Computer science2.07 KB

Bisection Method Implementation

#include <stdio.h>
#include <math.h>

#define f(x) (cos(x) - (x * exp(x)))

int main() {
    float x0, x1, x2, f0, f1, f2, e;
    int step = 1;

    /* Inputs */
    up:
    printf("\nEnter two initial guesses:\n");
    scanf("%f%f", &x0, &x1);
    printf("Enter tolerable error:\n");
    scanf("%f", &e);

    f0 = f(x0);
    f1 = f(x1);

    if (f0 * f1 > 0.0) {
        printf("Incorrect Initial Guesses. Try again.\n");
        goto up;
    }

    printf("\nStep\t\tx0\t\tx1\t\tx2\t\tf(x2)\n");
    do {
        x2 = (x0 + x1) / 2;
        f2 = f(x2);
        printf("%d\t\t%f\t%f\t%f\t%f\n", step, x0, x1, x2, f2);

        if (f0 * f2 < 0) {
            x1 = x2;
            f1 = f2;
...
Continue reading "Bisection and Regula Falsi Methods in C Programming" »

Essential Database Management System Concepts Explained

Computer science3.28 KB

Core Goals of a DBMS

A robust database management system (DBMS) provides software tools for the efficient storage, retrieval, manipulation, security, and administration of data. Key objectives include:

  • Ensuring data integrity and security
  • Supporting concurrent access
  • Providing data abstraction
  • Optimizing query processing

Entity Relationships and Cardinality

Strong vs. Weak Entities

An entity denotes a distinct object, while an entity type defines its category and an entity set aggregates objects belonging to that category. A strong entity has its own primary key, whereas a weak entity lacks its own and depends on a foreign key from a strong entity (e.g., order items for an order).

Cardinality

Cardinality represents the uniqueness and number of elements...

Continue reading "Essential Database Management System Concepts Explained" »

Web Protocols, P2P Networking, and Data Transmission

Computer science2.27 KB

Client and Server Web Interaction

Steps for a Client (Browser)

  • Determine the protocol (HTTP).
  • Ask DNS for the IP address of the server.
  • Make a TCP connection to the server.
  • Send a request for the page; the server sends it back.
  • Fetch other URLs as needed to display the page.
  • Close idle TCP connections.

Steps for a Server

  • Accept a TCP connection from the client.
  • Get the page request and map it to a resource (e.g., file name).
  • Get the resource (e.g., file from disk).
  • Send the contents of the resource to the client.
  • Release idle TCP connections.

Challenges in P2P Networking

  1. How do peers find each other?
  2. How do peers support rapid content downloads?
  3. How do peers encourage each other to upload?

BitTorrent Protocol Download Steps

  1. Start with the torrent description.
...
Continue reading "Web Protocols, P2P Networking, and Data Transmission" »

Essential Networking Concepts: TCP, UDP, and Congestion

Computer science2.5 KB

Differences Between TCP and UDP

  • TCP: Connection-oriented, bytes delivered in order, arbitrary length content, flow control matches sender to receiver, and congestion control matches sender to network.
  • UDP: Connectionless, messages may be lost, limited message size, can send regardless of receiver state, and can send regardless of receiver network.

TCP Connection Management

Explain using figures where and how the 3-way handshaking is used. Explain using figures how TCP releases connections (refer to the other side of this paper).

  • Normal case
  • Simultaneous connect

Computing Adaptive Timeout

Keep smoothed estimates of the RTT and variance in RTT. Update estimates with a moving average. Set timeout to a multiple of estimates to estimate the upper RTT in...

Continue reading "Essential Networking Concepts: TCP, UDP, and Congestion" »

Essential Java Design Patterns: Implementation Examples

Computer science2.99 KB

Memento Pattern

The Memento pattern allows you to capture and externalize an object's internal state so that the object can be restored to this state later.

public class MementoDemo {
    public static void main(String[] args) {
        Caretaker caretaker = new Caretaker();
        Originator originator = new Originator();
        originator.setState("State1");
        caretaker.addMemento(originator.save());
        originator.restore(caretaker.getMemento());
    }
}

Composite Pattern

The Composite pattern is used to compose objects into tree structures to represent part-whole hierarchies.

public class CompositeDemo {
    public static void main(String[] args) {
        Box root = initialize();
        int[] levels = new int[args.length];
...
Continue reading "Essential Java Design Patterns: Implementation Examples" »

Effective Interface and Report Design Strategies

Computer science2.96 KB

Designing Forms and Reports

  • Process of designing forms and reports
  • General guidelines for formatting forms and reports

Designing Interfaces and Dialogues

  • Process of designing interfaces and dialogues
  • General guidelines for interface design
  • Guidelines for the design of human-computer dialogues

Designing Web and Mobile Interfaces

  • General guidelines
  • Principles of mobile interface design

Understanding Forms and Reports

What is a Form?

A form is a business document that contains predefined data and may include areas where additional data is to be filled in. Traditionally, forms are paper-based. Today, the layout of almost any paper-based form can be displayed on a video display. Form interaction is a standard method for gathering and displaying information...

Continue reading "Effective Interface and Report Design Strategies" »

MPEG Multimedia Standards and Descriptors Quiz

Computer science2.4 KB

1. Which of the following statements about MPEG is not correct?

  • a. MPEG-1/2/4 are multimedia standards related to video and audio compression.
  • b. MPEG-7 is a multimedia content description standard that standardizes the extraction process and usage of audiovisual descriptors.
  • c. MPEG-7 is a multimedia content description standard that standardizes the syntax and semantics of audiovisual descriptors.

2. The Dominant Color Descriptor (DCD) captures…

  • a. The spatial distribution of the colors in an image using by default the YUV color space.
  • b. A maximum of eight representative colors using by default the RGB color space.
  • c. All the colors in the RGB color space with a larger percentage than 10.

3. The Color Structure Descriptor (CSD)…

  • a. Does not capture
...
Continue reading "MPEG Multimedia Standards and Descriptors Quiz" »

Operating System Fundamentals: File Systems and Data Security

Computer science2.18 KB

1. Functions of the File System

File systems structure information stored in a storage unit (typically a hard disk), which is then represented textually or graphically using a file manager. Most operating systems manage their own file system.

2. Operating System Responsibilities

The operating system performs several critical tasks, including:

  • Sending commands to hardware devices.
  • Detecting and managing system interrupts.
  • Monitoring and checking for errors.

3. Understanding File System Architecture

A hard drive consists of several circular disks rotating around an axis. The tracks (concentric areas written on both sides of the disc) are divided into segments called sectors, each containing 512 bytes.

4. Definition of a Computer File

A file is a set of...

Continue reading "Operating System Fundamentals: File Systems and Data Security" »

Network Routing and Switching Fundamentals

Computer science3.49 KB

Network Routing and Switching

Switching: The process of moving packets from a router's input to the appropriate router output.

Routing: The process of determining the specific route taken by packets across a network.

Ethernet Frames and IP Datagrams

Ethernet frames: These typically have a Maximum Transmission Unit (MTU) of 1500 bytes.

IP Datagram: Key components include the identification flag (where the last fragment has the bit set to zero) and travel/offset (which specifies the exact location of the fragment).

Address Resolution Protocol (ARP)

ARP: IP ARP is used to determine the physical address (MAC) of the next hop. It sends ARP requests for the destination MAC in broadcast mode, receives the response in unicast mode, and then forwards the packet...

Continue reading "Network Routing and Switching Fundamentals" »