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

Hash Table Telephone Book: Collision Handling Comparison in C++

Computer science8.12 KB


Telephone Book Database Using Hash Table in C++

/*
Author - Shantanu Wable

Consider a telephone book database of N clients. Make use of a hash table implementation to quickly look up a client's telephone number. Make use of 2 collision handling techniques and compare them using the number of comparisons required to find a set of telephone numbers.
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

class Client {

char name[20];
ll ph1;

public:

Client() {
strcpy(name, "----");
ph1 = 0;
}

void printDetails() {
cout.width(20);
cout << name << " ";
cout.width(20);
cout << ph1 << "\n";
}

Client(char n[], ll teleph1) {
strcpy(name, n);
...

Continue reading "Hash Table Telephone Book: Collision Handling Comparison in C++" »

painlessMesh and namedMesh Arduino Examples for ESP Networks

Computer science3.14 KB

painlessMesh and namedMesh Examples

The following two sketches demonstrate how to build a wireless mesh network with the painlessMesh library on ESP8266 and ESP32 boards.

Example 1: Broadcasting with painlessMesh

#include "painlessMesh.h"

#define MESH_PREFIX "whateverYouLike"

#define MESH_PASSWORD "somethingSneaky"

#define MESH_PORT 5555

Scheduler userScheduler;

painlessMesh mesh;

void sendMessage();

Task taskSendMessage(TASK_SECOND * 1, TASK_FOREVER, &sendMessage);

void sendMessage() {
  String msg = "Hello from node ";
  msg += mesh.getNodeId();
  mesh.sendBroadcast(msg);
  taskSendMessage.setInterval(random(TASK_SECOND * 1, TASK_SECOND * 5));
}

void receivedCallback(uint32_t from, String &msg) {
  Serial.printf("startHere: Received from...

Continue reading "painlessMesh and namedMesh Arduino Examples for ESP Networks" »

Software Development Principles and Design Patterns

Computer science697.56 KB

Key Concepts in Software Development

Complexity: Involves abstraction and decomposition into smaller, manageable problems.

Changeability: Requires effective management and a well-defined Software Development Life Cycle (SDLC).

Testing Before Implementation: Identifies defects early, saving time and resources.

Microsoft SDL: Emphasizes security considerations throughout all phases of the development cycle, including security and privacy risk assessment.

Understanding UML Diagrams

Sequence Diagram: Provides a time-based view of object interactions through function calls, illustrating the interaction among objects.

State Chart: Depicts the sequence of states an object goes through in response to external events, focusing on the state changes of a single

...

Continue reading "Software Development Principles and Design Patterns" »

Arduino Obstacle-Avoiding Robot with Servo Motors and Ultrasonic Sensor

Computer science3.03 KB

Arduino Obstacle-Avoiding Robot Code

#include <Servo.h>


Servo myservo; // crea el objeto servo
Servo rDerecha;
Servo rIzquierda;


#define irDerecho 3
#define irIzquierdo 2
#define ruedaD 9
#define ruedaI 8
#define echoPin 5
#define triggerPin 4



void setup() {
// put your setup code here, to run once:
pinMode(echoPin, INPUT);
pinMode(triggerPin, OUTPUT);
pinMode(irDerecho, INPUT);
pinMode(irIzquierdo, INPUT);
rDerecha.attach(ruedaD);
rIzquierda.attach(ruedaI);
myservo.attach(13); // vincula el servo al pin digital 13
}


void loop() {
// put your main code here, to run repeatedly
int valor;


valor = ping(triggerPin, echoPin);


if (valor < 10) {
parar(rDerecha, rIzquierda);
} else {
if (digitalRead(irDerecho) == LOW && digitalRead(
...
Continue reading "Arduino Obstacle-Avoiding Robot with Servo Motors and Ultrasonic Sensor" »

Oracle SQL Practice Questions: Savepoints, Roles, Functions and Triggers

Computer science3.25 KB

set pagesize 200
set linesize 200
Vraag 1:
ALTER TABLE afspraken MODIFY duur DEFAULT 30;
SAVEPOINT save_before;
INSERT INTO afspraken (datum, uur, pat) VALUES ('30-JAN-19', 14.15, 'p5');
INSERT INTO afspraken (datum, uur, pat) VALUES ('12-FEB-19', 9.10, 'p2');
INSERT INTO afspraken (datum, uur, pat) VALUES ('05-MAY-19', 13.30, 'p5');
ROLLBACK TO SAVEPOINT save_before;
COMMIT;
Vraag 2:
CREATE TABLE tarieven (code NUMBER(3) NOT NULL, bedrag NUMBER(4));
INSERT INTO tarieven VALUES (&code, &bedrag);
INSERT INTO tarieven VALUES (&code, &bedrag);
INSERT INTO tarieven VALUES (&code, &bedrag);
INSERT INTO tarieven VALUES (&code, &bedrag);
INSERT INTO tarieven VALUES (&code, &bedrag);
UPDATE behandelingen b
SET...

Continue reading "Oracle SQL Practice Questions: Savepoints, Roles, Functions and Triggers" »

Tic-Tac-Toe Game Functions in C

Computer science7.68 KB

#include <stdio.h>


// Name: Riya Patel, UWin No: 105159179
void printMenu()

{

printf("\n\nPress 'p' to print the tic-tac-toe board\n");


printf("Press 'c' to create a tic-tac-toe with some x and o cells\n");


printf("Press 't' to test if a tic-tac-toe board is valid or invalid\n");


printf("Press 'w' to predict winning cell for player x or o\n");


printf("Press 'e' to exit\n");


printf("Enter your choice: ");

}

void InitializeBoard(int m, int n, char board[][n])

{

int c = 1;
for (int i = 0; i < m; i++)

{

for (int j = 0; j < n; j++)

{

board[i][j] = c + '0';
c++;

} } }

void PrintBoard(int m, int n, char board[][n])

{

for (int i = 0; i < n; ++i)

{

for (int j = 0; j < n; j++)

{

j != 2 ? printf("%c |", board[i][j]) : printf("%c", board[i][j]
...
Continue reading "Tic-Tac-Toe Game Functions in C" »

Core Concepts in Computing: Hardware, Software, and Networking Fundamentals

Computer science4 KB

Understanding Data, Processing, and System Components

  1. Data Input and Storage

    Text, numbers, graphics, videos, and sounds entered into a computer's memory during input operations are referred to as ________.

    Data

  2. Information Output

    Data that has been processed and converted into information is known as ________.

    Output

  3. High-Capacity Computing Systems

    A ________ is a computer found in large businesses, organizations, and government agencies where thousands of users must simultaneously use the data and resources of their institution.

    Mainframe

  4. Example of an Input Device

    A ________ is an example of an input device.

    Keyboard

  5. Converting Physical to Digital Files

    A ________ is a device that converts documents or photos into digital files so they can be saved on

...

Continue reading "Core Concepts in Computing: Hardware, Software, and Networking Fundamentals" »

Librerías en Lenguaje C: Funciones Estándar y Sintaxis

Computer science5.29 KB

Librerías Estándar del Lenguaje C

A continuación se detallan las cabeceras principales de la biblioteca estándar de C (ANSI C) junto con sus funciones más representativas.

stdio.h: Entrada y Salida Estándar

La cabecera <stdio.h> provee capacidades esenciales para operaciones de entrada, salida y manejo de archivos.

  • clearerr
  • fclose
  • feof
  • ferror
  • fflush
  • fgetc
  • fgetpos
  • fgets
  • fopen
  • formato
  • fprintf
  • fputc
  • fputs
  • fread
  • freopen
  • fscanf
  • fseek
  • fsetpos
  • ftell
  • fwrite
  • getc
  • getchar
  • gets
  • perror
  • printf
  • putc
  • putchar
  • puts
  • remove
  • rename
  • rewind
  • scanf
  • setbuf
  • setvbuf
  • sprintf
  • sscanf
  • tmpfile
  • tmpnam
  • ungetc
  • vfprintf
  • vprintf
  • vsprintf

stdlib.h: Utilidades Generales y Memoria

La librería <stdlib.h> contiene funciones para gestión dinámica de memoria, control de procesos y conversiones numéricas.

  • abort
  • abs
  • atexit
  • atof
  • atoi
  • atol
  • bsearch
  • calloc
  • div
  • exit
  • free
  • getenv
  • labs
  • ldiv
  • malloc
  • mblen
  • mbstowcs
  • mbtowc
  • qsort
  • rand
  • realloc
  • srand
  • strtod
  • strtol
  • strtoul
  • system
  • wctomb

string.

...
Continue reading "Librerías en Lenguaje C: Funciones Estándar y Sintaxis" »

Exercício de Herança em Java: Conta Bancária, Corrente e Poupança

Computer science4.32 KB

Exercício - Banco

Classe abstrata ContaBancaria

package ExercicioHeranca;

import java.util.Scanner;

public abstract class ContaBancaria {

protected int senha;

protected int numero;

protected double saldo;

public ContaBancaria(int senha) {

this.senha = senha;

}

public abstract void saca(double valor);

public abstract void deposita(double valor);

public abstract double tiraExtrato();

public void alteraSenha(int senha_nova) {

Scanner in = new Scanner(System.in);

System.out.println("Entre a senha atual: ");

int senha_digitada = in.nextInt();

if (senha_digitada == this.senha) {

this.senha = senha_nova;

System.out.println("Senha trocada");

} else {

...

Continue reading "Exercício de Herança em Java: Conta Bancária, Corrente e Poupança" »

Java AWT Age Calculator: Build a Birthdate Age App

Computer science3.69 KB

Calculadora de Edad en Java con AWT

Este programa en Java utiliza la biblioteca AWT para crear una ventana que permite ingresar una fecha de nacimiento y calcular la edad.

Código fuente

import java.awt.event.*;
import java.util.*;

public class Awtedades {
    static Frame ventana = new Frame();
    static Label label1 = new Label("Digite su fecha de nacimiento: ");
    static Label label11 = new Label("");
    static Label label2 = new Label("Año:");
    static TextField txtanio = new TextField(12);
    static Label label3 = new Label("Mes:");
    static TextField txtmes = new TextField(12);
    static Label label4 = new Label("Día:");
    static TextField txtdia = new TextField(12);
    static Button btncalcular = new Button("Calcular");
...
Continue reading "Java AWT Age Calculator: Build a Birthdate Age App" »