From 3a64d0f5b6aafd7aaefcb393964ca6a8db74abd3 Mon Sep 17 00:00:00 2001 From: Alex Hyett Date: Fri, 4 Oct 2024 14:20:48 +0100 Subject: [PATCH] Add big o notation code --- .gitignore | 287 +++++++++++++++++++++++++++++++++ Constant/Constant.csproj | 11 ++ Constant/Program.cs | 23 +++ Exponential/Exponential.csproj | 11 ++ Exponential/Program.cs | 21 +++ Linear/Linear.csproj | 11 ++ Linear/Program.cs | 25 +++ Quadratic/Program.cs | 24 +++ Quadratic/Quadratic.csproj | 11 ++ README.md | 7 +- 10 files changed, 429 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Constant/Constant.csproj create mode 100644 Constant/Program.cs create mode 100644 Exponential/Exponential.csproj create mode 100644 Exponential/Program.cs create mode 100644 Linear/Linear.csproj create mode 100644 Linear/Program.cs create mode 100644 Quadratic/Program.cs create mode 100644 Quadratic/Quadratic.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a80b2c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,287 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.svclog +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.azurePubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +packages/ +## TODO: If the tool you use requires repositories.config, also uncomment the next line +!packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +![Ss]tyle[Cc]op.targets +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml + +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +_NCrunch* \ No newline at end of file diff --git a/Constant/Constant.csproj b/Constant/Constant.csproj new file mode 100644 index 0000000..0a53fc4 --- /dev/null +++ b/Constant/Constant.csproj @@ -0,0 +1,11 @@ + + + + Exe + net7.0 + Constant + disable + enable + + + diff --git a/Constant/Program.cs b/Constant/Program.cs new file mode 100644 index 0000000..2225b2d --- /dev/null +++ b/Constant/Program.cs @@ -0,0 +1,23 @@ +using System; + +namespace Constant +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Constant Example"); + Console.WriteLine("Another Line"); + Console.WriteLine("Another Line"); + Console.WriteLine("Another Line"); + + for (int i = 0; i < 10; i++) + { + Console.WriteLine(i); + } + } + } +} + + + diff --git a/Exponential/Exponential.csproj b/Exponential/Exponential.csproj new file mode 100644 index 0000000..4ddf2a8 --- /dev/null +++ b/Exponential/Exponential.csproj @@ -0,0 +1,11 @@ + + + + Exe + net7.0 + Exponential + disable + enable + + + diff --git a/Exponential/Program.cs b/Exponential/Program.cs new file mode 100644 index 0000000..ddcbf18 --- /dev/null +++ b/Exponential/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace Exponential +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine(fib(6)); + } + + static int fib(int num) + { + if (num <= 1) return num; + return fib(num - 2) + fib(num - 1); + } + } +} + + + diff --git a/Linear/Linear.csproj b/Linear/Linear.csproj new file mode 100644 index 0000000..04708b2 --- /dev/null +++ b/Linear/Linear.csproj @@ -0,0 +1,11 @@ + + + + Exe + net7.0 + Linear + disable + enable + + + diff --git a/Linear/Program.cs b/Linear/Program.cs new file mode 100644 index 0000000..17b62b2 --- /dev/null +++ b/Linear/Program.cs @@ -0,0 +1,25 @@ +using System; + +namespace Linear +{ + internal class Program + { + static void Main(string[] args) + { + var n = 10; + + for (int i = 0; i < n; i++) + { + Console.WriteLine(i); + } + + for (int i = 0; i < n; i++) + { + Console.WriteLine(i); + } + } + } +} + + + diff --git a/Quadratic/Program.cs b/Quadratic/Program.cs new file mode 100644 index 0000000..f4eeedd --- /dev/null +++ b/Quadratic/Program.cs @@ -0,0 +1,24 @@ +using System; + +namespace Quadratic +{ + internal class Program + { + static void Main(string[] args) + { + var n = 10; + + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= i; j++) + { + Console.Write("0 "); + } + Console.WriteLine(); + } + } + } +} + + + diff --git a/Quadratic/Quadratic.csproj b/Quadratic/Quadratic.csproj new file mode 100644 index 0000000..926ec16 --- /dev/null +++ b/Quadratic/Quadratic.csproj @@ -0,0 +1,11 @@ + + + + Exe + net7.0 + Quadratic + disable + enable + + + diff --git a/README.md b/README.md index f9fa867..b463dac 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ -# big-o-notation +# Big O Notation -Code for my video on Big O Notation \ No newline at end of file +Code for my video on [Big O Notation](https://youtu.be/aIG48ldbpRI). + +> [!NOTE] +> [This repository](https://code.alexhyett.com/alexhyett/big-o-notation) is also mirrored on [Codeberg.org](https://codeberg.org/alexhyett/big-o-notation) if you want to raise an issue. \ No newline at end of file