Giter Site home page Giter Site logo

data-structures-and-procedural-programming's Introduction

PROBLEM 1

Sum of Elements Calculator

Welcome to the Sum of Elements Calculator! This simple JavaScript function calculates the sum of distinct elements from two sets.

Table of Contents

Introduction

The Sum of Elements Calculator is a JavaScript function designed to find the sum of all distinct elements from two sets.

Function

The main function in this project is sumOfElements, which takes two sets as input and returns the sum of distinct elements from both sets.

function sumOfElements(set1, set2) {
    // Initialize sum
    let sum = 0;

    // Add elements from set1 that are not present in set2
    for (let i = 0; i < set1.length; i++) {
        if (!set2.includes(set1[i])) {
            sum += set1[i];
        }
    }

    // Add elements from set2 that are not present in set1
    for (let i = 0; i < set2.length; i++) {
        if (!set1.includes(set2[i])) {
            sum += set2[i];
        }
    }

    return sum;
}

Usage
To use the Sum of Elements Calculator, simply call the sumOfElements function with two sets:
const set1 = [3, 1, 7, 9];
const set2 = [2, 4, 1, 9, 3];
const output = sumOfElements(set1, set2);

console.log("Output:", output);


PROBLEM 2
# Vector Orthogonality Checker

This JavaScript code provides a simple utility to check the orthogonality of pairs of vectors.

## Table of Contents

- [Introduction](#introduction)
- [Usage](#usage)
- [Algorithm Overview](#algorithm-overview)

## Introduction

Orthogonality is a key concept in linear algebra. This code checks if pairs of vectors are orthogonal by calculating their dot product. The dot product of orthogonal vectors is zero.

## Usage

1. **Clone the repository:**

    ```bash
    git clone <https://github.com/Arinola23/Data-Structures-and-Procedural-programming>
    ```

2. **Navigate to the project folder:**

    ```bash
    cd vector-orthogonality-checker
    ```

3. **Run the JavaScript code:**

    Open the provided JavaScript file ( `index.js`) and include it in your project. Then, use the functions according to your requirements.

4. **Example:**

    ```javascript
    // Include the algorithm file in your project
    const vectors = [
        [1, 0, 0],
        [0, 1, 0],
        [0, 0, 1],
        [1, 1, 1]
    ];

    determineOrthogonality(2, vectors);
    ```

## Algorithm Overview

The code uses a function (`dotProduct`) to calculate the dot product of two vectors and another function (`determineOrthogonality`) to check the orthogonality of n pairs of vectors. Different parameter passing types, including passing arrays, are demonstrated.

Feel free to modify and integrate this code into your projects as needed.

data-structures-and-procedural-programming's People

Contributors

arinola23 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.