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

Sort by
Subject
Level

Ethereum Technical Deep Dive: Accounts, Smart Contracts, and PoS Consensus

Posted by Anonymous and classified in Computers

Written on in English with a size of 5.4 KB

This educational resource details Ethereum, a decentralized blockchain platform launched in 2015, focusing on its key features, accounts, smart contracts, transactions, and consensus mechanisms.

Ethereum Fundamentals

Ethereum is a blockchain platform that supports smart contracts—immutable computer programs executed on the Ethereum Virtual Machine (EVM). It uses Ether (ETH) as its native cryptocurrency to pay for transaction processing and smart contract execution.

Ethereum Accounts and Wallets

Account Types

  • Externally-Owned Accounts (EOAs): Controlled by private keys, used primarily for transactions like ETH transfers. Public keys are derived using Elliptic Curve Cryptography (ECC).
  • Contract Accounts: Controlled by smart contract code, deployed
... Continue reading "Ethereum Technical Deep Dive: Accounts, Smart Contracts, and PoS Consensus" »

How to Install NLTK and Perform Stemming in Python

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.17 KB

Install NLTK and Perform Stemming

Aim

Install the NLTK toolkit and perform word stemming.

Description

To install NLTK, use pip, Python’s package manager. Run the following command in your terminal:

pip install nltk

Once installed, you can perform stemming using various algorithms available in NLTK. The Porter stemming algorithm is one of the most popular choices.

Stemming is the process of reducing words to their root or base form. NLTK provides several algorithms, including:

  • Porter
  • Lancaster
  • Snowball

In this program, we use the Porter stemming algorithm to process sample text.

Implementation

import nltk
from nltk.stem import PorterStemmer

# Download NLTK resources if not already downloaded
nltk.download('punkt')

def perform_stemming(text):
    """
... Continue reading "How to Install NLTK and Perform Stemming in Python" »

Implementing Lexical and Syntax Analysis with Lex and Yacc

Classified in Computers

Written on in English with a size of 2.73 KB

Lexer Implementation (lexer.l)

%{ #include "y.tab.h" %} %%% "+" { return PLUS; } "-" { return MINUS; } "*" { return MULTIPLY; } "/" { return DIVIDE; } "%" { return MODULUS; } "(" { return LPAREN; } ")" { return RPAREN; } [0-9]+ { yylval.num = atoi(yytext); return NUMBER; } [a-zA-Z][a-zA-Z0-9]* { yylval.id = strdup(yytext); return IDENTIFIER; } [ \t\n] { /* ignore whitespace */ } . { return yytext[0]; } %%%

Parser Implementation (parser.y)

%{ #include <stdio.h> #include <stdlib.h> #include <string.h> void yyerror(const char *s); int yylex(); int temp_count = 0; int label_count = 0; void gen(char op, int arg1, int arg2, int result) { printf("%d: %c, %d, %d, %d\n", label_count++, op, arg1, arg2, result); } int new_temp() { return
... Continue reading "Implementing Lexical and Syntax Analysis with Lex and Yacc" »

Efficient AVL Tree Implementation in C++

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.53 KB

Node Class Structure

The Node class defines the structure for each element in the AVL tree, storing a key, its corresponding meaning, and pointers to child nodes.

class Node {
public:
    string key, meaning;
    Node *lft, *right;
    int h8;
    Node(string k, string m) {
        key = k;
        meaning = m;
        lft = right = NULL;
        h8 = 1;
    }
};

AVL Tree Class Definition

The AVL class contains the logic for maintaining a self-balancing binary search tree.

Helper Functions for Balancing

These utility functions manage node height (h8), calculate the balance factor, and determine the maximum of two values.

class AVL {
    Node* root;
    int h(Node* n) { if (n == NULL) return 0; return n->h8; }
    int bal(Node* n) { if (n == NULL)
... Continue reading "Efficient AVL Tree Implementation in C++" »

John Doe — Software Engineer Resume | JavaScript & React

Classified in Computers

Written on in English with a size of 1.43 KB

John Doe

Software Engineer

Contact Information

Email: [email protected]

Phone: (123) 456-7890

LinkedIn: linkedin.com/in/johndoe

GitHub: github.com/johndoe

Experience

Software Engineer at XYZ Corp

Jan 2020 - Present

  • Developed and maintained web applications using JavaScript, HTML, and CSS.
  • Collaborated with cross-functional teams to define, design, and ship new features.
  • Wrote unit and integration tests to ensure code quality.

Junior Developer at ABC Inc.

Jul 2018 - Dec 2019

  • Assisted in the development of web applications using React and Node.js.
  • Participated in code reviews and provided constructive feedback.
  • Contributed to the maintenance and improvement of existing codebases.

Education

Bachelor of Science in Computer Science

University of Somewhere, 2014 -

... Continue reading "John Doe — Software Engineer Resume | JavaScript & React" »

Android Development Concepts: UI Components and Architecture

Posted by Anonymous and classified in Computers

Written on in English with a size of 11.09 KB

1. ListView vs RecyclerView Comparison

ListView

ListView is an older Android UI component used to display a scrollable list of items vertically. Each item is displayed one below another.

  • Uses Adapter to bind data.
  • Uses convertView for view reuse.
  • Only supports vertical scrolling.
  • Less efficient for large datasets.
  • No built-in animations.
  • ViewHolder pattern is optional.
  • Simple to use.
  • Suitable for small lists.

Example:

ListView listView = findViewById(R.id.listview); 
// ArrayAdapter<String> adapter = 
// new ArrayAdapter<>(this, 
// android.R.layout.simple_list_item_1, data); 
///listView.setAdapter(adapter);

RecyclerView

RecyclerView is an advanced and flexible version of ListView, introduced in Android.

  • Uses ViewHolder pattern by default.
  • Highly
... Continue reading "Android Development Concepts: UI Components and Architecture" »

Prolog Implementation of Traveling Salesperson Problem

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.75 KB

This document presents two distinct approaches to solving the Traveling Salesperson Problem (TSP) using Prolog: an exact, brute-force method and a heuristic-based Nearest Neighbor algorithm. Both implementations are demonstrated with code and sample queries.

Exact Solver: Brute-Force TSP Algorithm

This section details a Prolog program that finds the optimal (shortest) path for the Traveling Salesperson Problem by generating and evaluating all possible tours. This method guarantees the optimal solution but can be computationally intensive for larger sets of cities.

Defining City Distances in Prolog

The distances between cities are defined using dist/3 facts. The predicate is made symmetric to ensure that dist(X,Y,D) implies dist(Y,X,D).

dist(a,b,
... Continue reading "Prolog Implementation of Traveling Salesperson Problem" »

LEGv8 Architecture and Assembly Language: Key Concepts

Classified in Computers

Written on in English with a size of 239.58 KB

Performance Metrics

  • Elapsed Time: Represents overall system performance. It is the total time taken to complete a task.
  • User CPU Time: Indicates CPU performance. It is the time the task actively runs on the CPU, excluding idle time.
  • CPU Time: The time the CPU spends executing instructions, either from the task or the operating system, excluding idle time.
  • Clock Speed: 1 MHz equals 1 million clock cycles per second. 1 GHz equals 1 billion clock cycles per second.
  • Response Time: Equivalent to execution time.
  • Throughput: Equivalent to bandwidth.
  • Performance Comparison: (PerfA) / (PerfB) = (ExecTimeB) / (ExecTimeA) = n

Impact of Processor Upgrades

  • Replacing a processor with a faster one decreases response time and increases throughput.
  • Adding an additional
... Continue reading "LEGv8 Architecture and Assembly Language: Key Concepts" »

Implementando 4x4 Matriz Transposta em Linguagem C

Classified in Computers

Written on in English with a size of 2.66 KB

Implementação da Transposição de Matriz 4x4 em C

Este programa em C demonstra como calcular e exibir a matriz transposta (B) de uma matriz quadrada de ordem 4 (A). A transposição é realizada trocando as linhas pelas colunas, ou seja, o elemento na posição A[i][j] é copiado para B[j][i].

Código Fonte em C para Transposição de Matriz

O código utiliza as bibliotecas padrão stdio.h para entrada/saída e conio.h (comum em ambientes legados) para controle de console.

#include <stdio.h>
#include <conio.h>

int main()
{
    int i, j, A[4][4], B[4][4];

    // 1. Entrada de Dados
    printf("Insira os elementos da Matriz A (4x4):\n");
    for(i = 0; i < 4; i++)
    {
        for(j = 0; j < 4; j++)
        {
            printf(
... Continue reading "Implementando 4x4 Matriz Transposta em Linguagem C" »

Java AWT GUI Development and OOP Inheritance

Posted by Anonymous and classified in Computers

Written on in English with a size of 7.41 KB

Building Java GUI Applications with AWT

Creating GUI applications using Abstract Window Toolkit (AWT) involves setting up a top-level container, adding components, arranging them with a Layout Manager, and making the container visible.

Steps to Create an AWT Application

1. Choose a Top-Level Container

The application needs a primary window to hold all components. The most common choice is the Frame class, which provides a title bar, borders, and window controls.

import java.awt.*;

// Class extends Frame to be the application window itself
public class AWTExample extends Frame {
    // Constructor and other methods
}

2. Initialize the Container (The Frame)

Inside the constructor, you set up the basic properties of the window:

  • Title: Set the window
... Continue reading "Java AWT GUI Development and OOP Inheritance" »