From 01c669d9140323ac8b4fe470de0283294c0f2541 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Wed, 7 Feb 2018 07:24:19 -0800 Subject: [PATCH] Start chapter 2, switch to ng-backed build. --- ods/notes/chapter1.txt | 6 ++++++ ods/notes/chapter2.txt | 15 +++++++++++++++ ods/src/build.yaml | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 ods/notes/chapter2.txt diff --git a/ods/notes/chapter1.txt b/ods/notes/chapter1.txt index 55f86d3..c99f70f 100644 --- a/ods/notes/chapter1.txt +++ b/ods/notes/chapter1.txt @@ -166,6 +166,12 @@ Run times come in three flavours: might be a doubly-linked list with the iteration direction determined by distance from the centre, though this comes at the cost of additional complexity. The same improvements would apply to remove. + + On a randomised benchmark (random operation, random value, random index), + the array-backed list still outperforms a from-scratch linked list and + an STL vector wrapper. The linked list performs the worst, with wildly + varying run times. + 2. For the sorted list, a basic improvement for find would be to pick the middle of the list and do an equality check, basically bisecting to find where the value *would* be. \ No newline at end of file diff --git a/ods/notes/chapter2.txt b/ods/notes/chapter2.txt new file mode 100644 index 0000000..f996518 --- /dev/null +++ b/ods/notes/chapter2.txt @@ -0,0 +1,15 @@ +# Chapter 2 (Array-based lists) + +These data structures have common advantages and limitations: + +* constant-time access + +* resizing the array adds potentially non-trivial complexity, both in time and + storage, as a new array generally must be created and the old array copied + over. + +* arrays aren't dynamic, which means inserting or deleting in the middle of an + array requires shifting all the following elements. + +With some careful management, the additional *amortised* complexity added by +resizing isn't too bad. \ No newline at end of file diff --git a/ods/src/build.yaml b/ods/src/build.yaml index 3cd6d15..89b0527 100644 --- a/ods/src/build.yaml +++ b/ods/src/build.yaml @@ -1,6 +1,6 @@ compilers: - cxx: clang++-5.0 - ld: clang++-5.0 + cxx: clang++ + ld: clang++ targets: cc: