Category: C++

  • Need a clear step-by-step explanation for solving a basic C+…

    I am currently learning programming and I am working with the C++ language. I am having some difficulty understanding how to solve certain programming and logic exercises.

    I would like a clear, step-by-step explanation of how to solve a programming problem using C++. I also want to understand how each part of the code works so that I can apply the same logic to similar exercises in the future.

    I am using the standard C++ compiler and working with basic programming concepts such as variables, conditional statements, loops, and functions.

    A detailed explanation with commented code examples would be very helpful so I can fully understand the solution and improve my programming skills.

  • Write a C++ program using recursion to find the sum of digit…

    #include <iostream>

    using namespace std;

    int sumDigits(int n) {

    if(n == 0) // base case

    return 0;

    return (n % 10) + sumDigits(n / 10);

    }

    int main() {

    int n;

    cout << “Enter number: “;

    cin >> n;

    cout << “Sum of digits = ” << sumDigits(n);

    return 0;

    }

  • CSCE 2110: Project 1 ( parking)

    you will be designing and implementing a system in C or C++, that will simulate part of the management of a valet parking system called QParking. Specifically, you will be simulating the registration of customers, assigning parking spaces, and locating cars

  • How does a hash table improve search efficiency in Java or C…

    Explain in context of Java or C++ data structures.

    Requirements:

  • C++ Question

    You need to develop the decoder for a new compression algorithm to evaluate the effectiveness of Elias-Gamma encoding for larger integer values. The proposed compression algorithm works as follows:

    1. Determine the frequency of symbols in the message.

    2. Sort the alphabet symbols in descending order based on their frequency. If two or more symbols have the same frequency, sort them according to lexicographical order (ascending based on ASCII value).

    3. Create the encoded message by appending the positions of the symbols (based on the sorted alphabet) in the original message. Since Elias-Gamma encoding is used to represent the positions, the values for the positions start from one.

    Given the following original message: AACABDDADABC

    The alphabet is sorted as A, D, B, and C, and the positions in the encoded message are: 1, 2, 4, 8, 10, 6, 7, 9, 5, 11, 3, and 12 (represented as Elias-Gamma codes).

    Your decoder takes the following information as input from the standard input (STDIN):

    1. An integer representing the alphabet size (m).

    2. m symbols. Each symbol is represented by a single character and an integer value indicating its frequency.

    3. A binary string with positions encoded using Elias-Gamma code. The position values are stored according to the order of symbols in the sorted alphabet.

    For this assignment, you will create a multithreaded program to find the positions of the symbols in the original message, reconstruct the original message (based on the encoded message), and determine the number of bits required to represent the positions using Elias-Gamma encoding.

    Given the following input:

    4
    A 5
    C 2
    B 2
    D 3
    10100010000010000001010001100011100010010010100010110110001100

    The expected output is:

    Symbol: A, Frequency: 5
    Positions: 0 1 3 7 9
    Bits to represent the position(s): 23

    Symbol: D, Frequency: 3
    Positions: 5 6 8
    Bits to represent the position(s): 17

    Symbol: B, Frequency: 2
    Positions: 4 10
    Bits to represent the position(s): 12

    Symbol: C, Frequency: 2
    Positions: 2 11
    Bits to represent the position(s): 10

    Decoded message: AACABDDADABC

    Process:

    Your solution must execute the following steps:

    • Read the input lines from STDIN.

      • Create m POSIX threads (where m is the alphabet size). Each child thread performs the following tasks:

    – Receives the encoded message, the symbol to decode, and the memory location to store the decoding results.

    – Determines the positions of the assigned symbol in the original message.

    – Calculates the number of bits used to represent the symbol’s position using Elias Gamma encoding.

    – Stores the assigned symbol’s information in a memory location accessible by the main thread.

    – Stores the assigned symbol, using the determined positions, into the memory address shared with the main thread that contains the decoded message.

    • Print the information for each symbol to STDOUT (sorted according to the compression algorithm rules).

    • Print the decoded message.

    Notes:

    • The position values for the symbols must start from one (not from zero), because Elias Gamma encoding can only represent positive integers starting from one.

    • You can safely assume that the input will always be in the proper format.

    • You must use the output statement format shown in the example above.

    • You can define additional functions if needed.

    • You must take full advantage of multithreading.

    • You must present code that is readable and has comments explaining the logic of your solution. A 10% penalty will be applied to submissions that do not follow this guideline.

    • You cannot use global variables. A 100% penalty will be applied to submissions using global variables.

    • Not using multiple POSIX threads (the pthread.h library) to implement your solution will result in a 100% penalty. DO NOT USE THE THREAD LIBRARY FROM C++.

    • A penalty of 100% will be applied to solutions that do not compile.

    • A penalty of 100% will be applied to solutions that hardcode the output.

    Assignment rubric:

    • Correct output: 10 points per test case (20 points total).

    • Correct implementation of the thread function: 30 points.

    • Taking full advantage of multithreading (no pthread_join or sleep in the same loop as pthread_create): 30 points.

    • Creating the correct number of threads: 10 points.

    • Having clean and commented code: 10 points.

    Penalties:

    1. Presenting a solution that does not compile: -100 points.

    2. Not using POSIX threads: -100 points.

    3. Hardcoding the output: -100 points.

    4. Using global variables: -100 points.

    5. Using AI tools without following the rules stated in the syllabus: -100 points.

      the rules in the syllabus mention that you are only allowed to use AI tools to help understand why your solution isn’t working, and you must include a comment in the AI-generated code section explaining the problem the tool addressed.

    Requirements:

  • C# Question

    You are tasked with designing and deploying a scalable, secure, and maintainable RESTful Web API for managing tourism data (regions and walking trails) using ASP.NET Core Web API and .NET 7.

    Explain how you would architect this system from development to deployment by addressing the following:

    1. Design the API using domain-driven principles, clearly distinguishing between Domain Models and DTOs, and justify how the Repository Pattern and Dependency Injection improve maintainability and testability.
    2. Implement database integration using Entity Framework Core, including migrations, connection configuration, and database creation, while ensuring smooth version control and schema evolution.
    3. Configure authentication and authorization using Microsoft Identity and JWT tokens, and explain how role-based authorization can be enforced across endpoints and integrated into Swagger UI for secure testing.
    4. Demonstrate how Automapper can be used to efficiently map between models, and evaluate its impact on performance and code readability in large-scale APIs.
    5. Apply asynchronous programming (async/await) to improve API responsiveness and scalability under high request loads, and analyze potential pitfalls such as deadlocks or improper async usage.
    6. Integrate logging and monitoring using Serilog to track application behavior, errors, and security events, and explain how structured logging improves debugging and production maintenance.
    7. Enhance API usability by implementing filtering, sorting, and pagination, and justify how these features improve performance and user experience for large datasets.
    8. Propose a testing and documentation strategy using Swagger UI and Postman, ensuring the API is easy to consume, secure to test, and ready for deployment in multiple environments.

    Finally, critically evaluate how all these components work together to create a production-ready enterprise Web API, and identify potential scalability, security, and maintainability challenges that may arise over time.

    Requirements: complete

  • C++ Question

    Class Assignment 2-

    Completed the two programs and submit your source code and output for pointsimage.png

    Requirements: as needed