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

Software Design Patterns: Principles and Implementation

Computer science4.92 KB

Software Design Patterns and Architecture (CSC3324)


Defining Software Design Patterns

  • A reusable solution to a recurring design problem.

  • It reuses abstract knowledge about problems and solutions.

  • Independent of specific implementations, it acts as a template.

  • It utilizes Object-Oriented Programming (OOP) features such as inheritance and polymorphism.


The Christopher Alexander Definition

“Each pattern describes a problem which occurs over and over again... and then describes the core of the solution... you can use this solution a million times over without doing it the same way twice.”


Architecture vs. Design Patterns

AspectArchitectureDesign Patterns
LevelHigh-levelLower-level (Micro-architecture)
PurposeStructure of the whole applicationSolve subproblems
...
Continue reading "Software Design Patterns: Principles and Implementation" »

PIC18 Microcontroller Architecture and Programming Fundamentals

Computer science2.31 MB

r0aTE1NVXMmzevWL58ebFjx444S5Kkv5dBLEmSJEmSJLWePbEkSZIkSZLUegaxJEmSJEmS1HoGsSRJkiRJktR6BrEkSZIkSZLUegaxJEmSJEmS1HoGsSRJkiRJktR6BrEkSZIkSZLUegaxJEmSJEmS1HoGsSRJkiRJktR6BrEkSZIkSZLUegaxJEmSJEmS1HJF8R8nijdTkdt0NQAAAABJRU5ErkJggg==

jZJ+MjVSDBwAAAABJRU5ErkJggg==

h8ptEUKkg7IZQAAAABJRU5ErkJggg==

DUnON+LR4AAAAASUVORK5CYII=

98afFzAAAAAElFTkSuQmCC

H6qI1ExVJ4g5AAAAAElFTkSuQmCC

X9yKEEEIIfeAQQgghLrJ161Y5fQoWBQr82ebJk0dOlbp8+bI4fvy4uHDhglTsTJw4URQuXFjfk5CUBaxv4IQaTsgVadOmlYrNpk2b6lsIIYQQAgIrcIT4fwcJ5tlvgQpqAAAAAElFTkSuQmCC

nlqAAAAAElFTkSuQmCC

8IHbt2iVOnz4tg8y5cuUSefPmFaVLlxa1a9cW9913n8iRI4f6FBGRGYMWRERERERERORK7IiTiIiIiIiIiFyJQQsiIiIiIiIiciUGLYiIiIiIiIjIlRi0ICIiIiIiIiJXYtCCiIiIiIiIiFyJQQsiIiIiIiIiciUGLYiIiIiIiIjIlRi0ICIiIiIiIiJXYtCCiIiIiIiIiFyJQQsiIiIiIiIiciUGLYiIiIiIiIjIhYT4P77eVJYAUUVEAAAAAElFTkSuQmCC

4f9BI30SufhNkAAAAASUVORK5CYII=

wHkdzvXXrzhLwAAAABJRU5ErkJggg==


1. PIC18 Architecture Details

  • Harvard Architecture

    Features distinct program memory and data memory. Includes the MPU, Program Memory, Data Memory, I/O Ports, and support devices like timers.

  • Microprocessor Unit (MPU)

    • ALU (Arithmetic Logic Unit)

      Performs operations such as addition, subtraction, and logical operations.

    • Registers

      Includes WREG (8-bit accumulator), Program Counter (PC), Stack Pointer (SP), and File Select Registers (FSRs).

    • Memory

      Offers 2 MB of program memory and 4 KB of data memory.

    • Bank Switching

      Data memory is divided into 16 banks, with one 256-byte access bank.

2. Data Formats and Representations

  • Unsigned Integers

    These are 8-bit values, ranging from 0 to 255.

  • Signed Integers

    Represented using 2's complement, with a range from -128 to

...
Continue reading "PIC18 Microcontroller Architecture and Programming Fundamentals" »

Mastering Software Design Principles and SOLID Patterns

Computer science206.57 KB

Core Software Design Principles

  • Abstraction: Removal or masking of detail and complexity.
  • Modularity: Software is divided into separately named and addressable components.
  • Separation of Concerns: Any complex problem can be more easily handled if it is subdivided into pieces.
  • Information Hiding / Encapsulation: Hide implementation details from client components; communicate only via controlled interfaces.
  • High Cohesion: Components provide specific functionality.
  • Low Coupling: Components have as few dependencies as possible so they can change with minimal impact on other components.

SOLID Principles

Single Responsibility Principle

The idea here is simple: Separate the code that supports different actors (i.e., users, stakeholders, or client components)...

Continue reading "Mastering Software Design Principles and SOLID Patterns" »

C Data Structures: Binary Trees, DFS, and Stack Logic

Computer science3.54 KB

7th Experiment: Binary Tree Construction

This experiment demonstrates the construction of a binary tree from an array and its in-order traversal.

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

struct node {
  struct node* left;
  char data;
  struct node* right;
};

struct node* constructTree(int index);
void inorder(struct node* root);

char array[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', '\0', '\0', 'H' };
int leftcount[] = { 1, 3, 5, -1, 9, -1, -1, -1, -1, -1 };
int rightcount[] = { 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 };

int main() {
  struct node* root = constructTree(0);
  printf("In-order Traversal: \n");
  inorder(root);
  return 0;
}

struct node* constructTree(int index) {
  struct node* temp = NULL;
  if (index != -1) {
    temp
...
Continue reading "C Data Structures: Binary Trees, DFS, and Stack Logic" »

C++ Algorithms: 0-1 Knapsack and LCS Implementation

Computer science2.52 KB

Knapsack Problem: Recursive Approach

The following code demonstrates a naive recursive implementation of the 0-1 Knapsack problem in C++.

/* A Naive recursive implementation of 0-1 Knapsack problem */
#include <bits/stdc++.h>
using namespace std;

// A utility function that returns the maximum of two integers
int max(int a, int b) { return (a > b) ? a : b; }

// Returns the maximum value that can be put in a knapsack of capacity W
int knapSack(int W, int wt[], int val[], int n)
{
    // Base Case
    if (n == 0 || W == 0)
        return 0;

    // If weight of the nth item is more than Knapsack capacity W,
    // then this item cannot be included in the optimal solution
    if (wt[n - 1] > W)
        return knapSack(W, wt, val, n
...
Continue reading "C++ Algorithms: 0-1 Knapsack and LCS Implementation" »

Fixed C Programming Examples: Calendar, Stack, Queue, Linked List, Tree

Computer science27.31 KB

Fixed C Programming Examples

1. Weekly Calendar Program

This program creates, reads, displays and frees a weekly calendar using a structure.

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

#define NUM_DAYS_IN_WEEK 7

typedef struct {
    char *acDayName;
    int iDate;
    char *acActivity;
} DAYTYPE;

void fnFreeCal(DAYTYPE *);
void fnDispCal(DAYTYPE *);
void fnReadCal(DAYTYPE *);
DAYTYPE *fnCreateCal();

int main()
{
    DAYTYPE *weeklyCalendar = fnCreateCal();
    fnReadCal(weeklyCalendar);
    fnDispCal(weeklyCalendar);
    fnFreeCal(weeklyCalendar);
    return 0;
}

DAYTYPE *fnCreateCal()
{
    DAYTYPE *calendar = (DAYTYPE *)malloc(NUM_DAYS_IN_WEEK * sizeof(DAYTYPE));
    for (int i =
...
Continue reading "Fixed C Programming Examples: Calendar, Stack, Queue, Linked List, Tree" »

Frame Relay क्या है? फायदे और नुकसान (हिंदी में पूरी जानकारी)

Computer science5.48 KB

Network Protocols (नेटवर्क प्रोटोकॉल)

Frame Relay क्या है? (What is Frame Relay in Hindi)

Frame Relay एक तेज गति का packet switching प्रोटोकॉल है जिसका प्रयोग Wide Area Networks (WANs) में किया जाता है। इसके अलावा, यह दो या दो से अधिक Local Area Networks (LANs) के बीच data को transfer करता है।

Frame Relay एक packet switched टेक्नोलॉजी है। इसे Local Area Networks के बीच कम खर्च में data transfer करने के लिए design किया गया था। साथ ही,...

Continue reading "Frame Relay क्या है? फायदे और नुकसान (हिंदी में पूरी जानकारी)" »

Digital Image Processing Tutorial for Beginners and Professionals

Computer science3.19 KB

Digital Image Processing Tutorial

Digital Image Processing Tutorial provides basic and advanced concepts of image processing. Our Digital Image Processing Tutorial is designed for beginners and professionals both.

Digital image processing is used to manipulate digital images by the use of algorithms. For processing digital images, the most common software that is used widely is Adobe Photoshop.

Our digital image processing tutorial includes all topics of digital image processing such as introduction, computer graphics, signals, photography, camera mechanism, pixel, transaction, types of images, etc.

What Is Digital Image Processing (DIP)?

Digital Image Processing (DIP) is a software which is used to manipulate digital images by the use of a computer...

Continue reading "Digital Image Processing Tutorial for Beginners and Professionals" »

Gender Disparities in Mortality Rates and Immune System Function

Computer science2.03 KB

EXT2018.OA´WOMEN REALLY´

1.a-P1: A recent study found that women tend to live longer than men. b-P3: The academics also discovered that women have a stronger immune system.

  • a-harsh
  • b-hardship
  • c-underpinnings
  • d-outlive

4.p1: Danish researchers analyzed 19th-century data. p2: Research showed that women outlive men. p3: Males have a higher mortality rate even if...

ORD2018.OB·`Shop hires...`

1.a-P2: But it is important for businesses to understand their customers. b-P4: We thought it was an emotional and exciting experience.

  • a-actually
  • b-aware
  • c-stressful
  • d-understanding

4.p1: At the shop, Fabio performed. p2: When Fabio, the staff. p3: The staff had become...

ORD2017.OB`The victorian...`

1.a-P2: People would gather to observe. b-P3: The tableaus were a frozen...

Continue reading "Gender Disparities in Mortality Rates and Immune System Function" »

MPEG Audio Compression: Understanding the Fundamentals

Computer science2.71 KB

Introduction

The principle of MPEG audio compression is quantization. However, the values being quantized are not the audio samples themselves, but rather numbers (called signals) taken from the frequency domain of the sound.

Encoding Process

  1. Bit Allocation: The encoder knows the compression ratio (or bit rate), allowing it to determine how many bits to allocate to the quantized signals. The adaptive bit allocation algorithm uses the bitrate and frequency spectrum of recent audio samples to minimize audible quantization noise (the difference between the original and quantized signal).
  2. Discrete Fourier Transform: Psychoacoustic models, which determine the quantization coarseness, rely on sound frequency. Since the input is audio samples, the first
...
Continue reading "MPEG Audio Compression: Understanding the Fundamentals" »