Notes, summaries, assignments, exams, and exercises for Computer science for Other courses

Essential Linux Commands & System Administration Toolkit

Computer science7.26 KB

File Operations

  • ls — List files and directories (-a for hidden, -l for detailed)
  • cd [directory] — Change directory
  • mkdir [directory] — Create directory
  • cp [source] [destination] — Copy files/directories (-r for recursive)
  • mv [source] [destination] — Move or rename files/directories
  • rm [file] — Remove files (-r for recursive)
  • chmod [permissions] [file] — Change file permissions
  • chown [user]:[group] [file] — Change file ownership

System Monitoring

  • top / htop — Monitor system processes
  • ps — List running processes
  • df -h — Display disk space usage
  • free -m — Show memory usage

Networking Commands

  • ifconfig / ip a — Display network interfaces
  • ping [host] — Test network connectivity
  • netstat -tuln — List network connections
  • nmap [IP] — Scan
...
Continue reading "Essential Linux Commands & System Administration Toolkit" »

C Code Examples: Data Structures and Algorithms

Computer science5.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" »

Software Architecture: Key Concepts and Best Practices

Computer science2.51 KB

Why the 4 + 1 Architecture?

The 4 + 1 architecture model provides different views (logical, process, development, and physical) plus scenarios. This allows for a comprehensive understanding of the system to be built. The 4 + 1 model is also generic.

How Does It Help with Design?

It aids in system design by helping to understand the system's behavior through detailed component design and specifications. This ensures that the functional requirements are met.

Choosing a Construction Methodology

The construction methodology depends on the problem or system being addressed. Therefore, the criterion is paramount when choosing a methodology. Options include:

  • Rational Unified Process
  • CMMI
  • Scrum

Importance of Documentation Standards

Documentation standards facilitate...

Continue reading "Software Architecture: Key Concepts and Best Practices" »

Understanding Computer Data Storage: Memory and Mass Storage

Computer science2.2 KB

Computer Data Storage

Computer data storage, often called storage or memory, refers to computer components, devices, and recording media that retain digital data used for computing for some interval of time. Computer data storage provides one of the core functions of the modern computer: information retention. It is one of the fundamental components of all modern computers and, coupled with a central processing unit (CPU, a processor), implements the basic computer model used since the 1940s.

In contemporary usage, memory usually refers to a form of semiconductor storage known as random access memory (RAM) and sometimes other forms of fast but temporary storage. Similarly, storage today more commonly refers to mass storage: optical discs, forms...

Continue reading "Understanding Computer Data Storage: Memory and Mass Storage" »

Connecting to SQL Server 2000 with JDBC: A Practical Example

Computer science5.03 KB

Connecting Through JDBC Driver for Microsoft SQL Server 2000

Exercise 2

import java.sql.*;

Class Home

public class Jdbc_sqls3 {

private Connection con = null;

Constants for PLS USE chain link

private final String url = "jdbc:microsoft:sqlserver://";

private final String server = "localhost";

private final String port = "1433";

private final String db = "pubsSQL";

private final String user = "sa";

private final String pass = "spark";

The password is easily found; it is recommended to request the user for the final application.

Make the driver use cursor on the server side, allowing more than one active SQL statement per connection.

private final String method = "cursor";

Main Method of Entry Program

public static void main(String[] args) throws Exception {

Jdbc_

...
Continue reading "Connecting to SQL Server 2000 with JDBC: A Practical Example" »

Essential Computer Expansion Cards and Peripherals

Computer science3.33 KB

1. Expansion Cards

Utility

Expansion cards add new features or improve existing ones in a computer. They facilitate communication between internal and external peripheral devices and the system bus.

Disk Controller Card

Disk controller cards, once used to manage hard disks, CD-ROMs, DVDs, and floppy drives, are now integrated into the motherboard.

Video Card

The video card is crucial for displaying text, images, and graphics on the monitor.

Components

  • Video Processor: Receives, processes, and stores information in video memory, transmitting it to the monitor via the VGA connector.
  • Memory Chips: Hold information needed to display pixels on the screen.
  • AGP: Allows the card to be inserted into the AGP slot.
  • Port for the Monitor: Connects the card to the
...
Continue reading "Essential Computer Expansion Cards and Peripherals" »

Android and iOS Mobile App Development Solutions

Computer science11.74 KB

RecyclerView Features and GridView Implementation

1. List and explain any three features of RecyclerView. Develop an Android application to display any five programming languages in GridView.

  • View Recycling: Reuses views to improve performance and reduce memory usage.
  • ViewHolder Pattern: Stores item views to avoid repeated findViewById() calls.
  • Flexible Layout: Supports LinearLayoutManager, GridLayoutManager, and StaggeredGridLayoutManager.

Example: XML and Java

Java Code:

GridView gridView = findViewById(R.id.gridView);
String[] languages = {"C", "C++", "Java", "Python", "Kotlin"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, languages);
gridView.setAdapter(adapter);

API Types and Data Passing

...
Continue reading "Android and iOS Mobile App Development Solutions" »

Internet Fundamentals: Protocols, Web Browsers, and Network Architecture

Computer science7.49 KB

Internet vs. World Wide Web (WWW)

  • Internet: A global network infrastructure that uses TCP/IP to connect devices worldwide.
  • WWW (World Wide Web): A multimedia service built upon the Internet, utilizing HTML, CSS, web browsers, and hyperlinks.
  • Webpage: A single document accessible via the WWW. | Website: A collection or group of related webpages.

History and Evolution of the Internet

  • 1960s: Development of ARPANET (Advanced Research Projects Agency Network).
  • 1983: Adoption of the TCP/IP protocol suite (developed by Vint Cerf and Bob Kahn).
  • 1989: Invention of the World Wide Web (WWW) by Tim Berners-Lee.
  • 1992: Release of the Mosaic browser (developed at UIUC), popularizing the graphical web.

Understanding the Client-Server Model

  • Client: Initiates a request
...
Continue reading "Internet Fundamentals: Protocols, Web Browsers, and Network Architecture" »

Network Fundamentals: Protocols, Addressing, Security

Computer science17.78 KB

TCP Reliable Transfer and Connection Management

TCP Reliable Transfer

  1. Sequence Numbers

    • Each byte of data is assigned a sequence number. This number is used by the receiver to correctly order the data and ensure there are no missing segments.
  2. Acknowledgements

    • The receiver sends back an ACK to the sender for the sequence number of the next expected byte. If the sender receives the ACK before its timer expires, it knows everything up to that byte was received correctly.
  3. Retransmission

    • If the ACK is not received before the timer expires, the sender retransmits the data.

TCP Connection Management

Managing a TCP connection begins with a three-way handshake, which establishes a connection before any actual data is transmitted.

Steps in Three-Way Handshake

  1. SYN
    • The
...
Continue reading "Network Fundamentals: Protocols, Addressing, Security" »

CUDA Matrix Multiplication: Shared Memory

Computer science3.23 KB

CUDA Matrix Multiplication Using Shared Memory

This code demonstrates matrix multiplication in CUDA, leveraging shared memory for optimization. It includes two examples: a kernel using shared memory and a host-side implementation using the Thrust library.

CUDA Kernel with Shared Memory

The following CUDA kernel performs matrix multiplication using shared memory to optimize data access:


__global__ void matMulShared(int *A, int *B, int *C, int rowsA, int colsA, int colsB) {
    __shared__ int tile_A[TILE_SIZE][TILE_SIZE], tile_B[TILE_SIZE][TILE_SIZE];
    int row = blockIdx.y * TILE_SIZE + threadIdx.y, col = blockIdx.x * TILE_SIZE + threadIdx.x, temp = 0;
    for (int i = 0; i < (colsA + TILE_SIZE - 1) / TILE_SIZE; ++i) {
        if (row <
...
Continue reading "CUDA Matrix Multiplication: Shared Memory" »