DSA-Assignments

Log | Files | Refs | README

commit 5bdd04f44568b818464d8f809ddec48c20bfe1fd
parent e6f8b2cc5be1a9deec1b05e0315f15e5c0dd80c3
Author: TranLili <tranlili96@gmail.com>
Date:   Wed, 29 Nov 2023 14:50:48 +0100

Starting problem 4

Diffstat:
MProblem4/Problem4.cpp | 38++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/Problem4/Problem4.cpp b/Problem4/Problem4.cpp @@ -1,20 +1,30 @@ -// Problem4.cpp : This file contains the 'main' function. Program execution begins and ends there. +// Problem 1: Bucket Sort +// Description: Sort a vector using a modified version of bucket sort. +// Course: IT405G - Datastructures and Algorithms +// Authors: William Lindholm, Lili Tran, Victor Adamson +// Date: 29-11-2023 // #include <iostream> +#include <cmath> -int main() -{ - std::cout << "Hello World!\n"; -} +using namespace std; + +// Temp +// Från labbanvisningarna +// T(n) = T(n-1)+T([n/2])+n +// T(1) = 1 +// Recursive function to calculate T(n) +int T(int n) { + int result = T(n - 1) + T(ceil(n / 2.0)) + n; -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu + return result; +} -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file +int main() { + int n; + cout << "Enter a value for n: "; + cin >> n; + cout << "T(" << n << ") = " << T(n) << endl; + return 0; +}