Skip to content

Repo to test assumption that linear approach is better than recursive in one coding task

Notifications You must be signed in to change notification settings

kyrylo-hrechykhin/remove-match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

remove-match

Description

In this repo I tried to investigate what kind of solution is better (performance-wise): iterative or recursive on a specific task. This repo is public, feel free to run it yourself, check results with other tests or algorithms.

Problem description

  • string input given that is contained with only for letters: A, B, C, D.
  • algorithm should remove all occurances of following substrings: AB, BA, CD, DC

Problem to prove

Main assumption is that recursive algorithm may perform better than iterative solution with runtime complexity O(n) on certain inputs. That assumption is backed with recursive algorithm memoization approach. If hash function for the input works with expected O(1) runtime complexity, recursive calls for input with known result will not be processed. To prove that I need to write iterative and recursive algos so that iterative perform better on all inputs.

Prerequisites

  • CMake
  • C++ compiler with support of C++17 (duh!)

Project is supposed to be cross-platform, but it is tested on Windows onlz. Feel free to check it by yourself on other platforms.

How to build

Generate build file

mkdir build
cd build
cmake ..

It will generate project with default project generator on your platform. You can specify any project generator by passing -G parameter with generator name.

cmake -G "Ninja" ..

Check list of available generators by running cmake --help

Build it

Build it as usual project generated by CMake

About

Repo to test assumption that linear approach is better than recursive in one coding task

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published