This article is about how I used my computer science knowledge to create a fun, yet efficient way of organising a notebook.
The Problem
This Christmas I received a lovely new notebook as a gift. I have never had a notebook before, but as soon as I started writing in it, I realised I had an issue that I'm sure all of you notebookers have also encountered; How much space should I leave between each of my topics? How many pages of notes will I make about the book I am reading? How much space will I need for my journal? And worst of all, what if I don't leave enough room?
Computerisation
Fortunately for you and me, I had an idea. When writing my personal statement for university, I discussed how computer scientists can and should take inspiration from how humans solve problems they encounter every day to find solutions to their abstract computer science problems.
However after reading Algorithms to Live By by Tom Griffiths and Brian Christian, I became increasingly aware of how we can use solutions to computer science problems in real life. For example, caching theory tells us how we should best organise our wardrobes, and sorting theory tells us we shouldn't bother sorting our emails.
Paging
Computers face the exact same problem as you or I with our notebooks. They have a fixed sized memory, and have to store multiple topics (files or programs) without knowing how much space each one will end up taking. In response to this problem, computer scientists realised that data doesn't need to be stored contiguously (next to each other in memory).
"Data doesn't need to be stored contiguously"
Instead, they divided the memory up into fixed sized chunks called pages (directly comparable to the pages in our notebooks), and whenever a topic needed more memory, they simply assign it the next available page.
Surely one page is too small?
Yes, you are right, it would be a nightmare to assign each topic only a single page every time. It would be extremely hard to keep track of. Here it is important to define some key terms. We can say that a 'physical page' in a notebook is exactly that, a single, physical page. Then, we can define that a 'logical page' is a number of contiguous physical pages.
"A logical page is a number of contiguous physical pages"
Logical pages are then the 'divisions' that can be assigned to a topic. You can decide how many physical pages you would like in a logical page, but I would advise trying to choose a number that reduces the number of physical pages left blank (by decreasing the number of physical pages in a logical page), while also reducing the number of times you overrun a logical page and have to move into a new one.
I admit that this is a bit of a guessing game, but I have found that a logical page containing two physical pages works well for me, as most of my topics take one to two physical pages. Any larger logical pages would have resulted in my leaving lots of physical pages blank.

For the rest of this article, when I refer to a page, I am referring to a logical page.
That still sounds hard to keep track of...
What happens when one topic fills its page? Won't my notebook just be really disorganised? Currently, our notebook is a mess of sections of topics all over the place, making it really hard to read a topic from start to end. Here, we can once again take inspiration from another Computer Science topic: Linked Lists.
Linked Lists
Computer Scientists often need to store lots of similar pieces of data in ordered lists. But how can you navigate a list in order if the items are stored in random places in memory? Simple, along with storing the item, you also store a 'pointer' to where the next item is stored.
Consider the example below:

If we traverse the list from top to bottom, then the names are not in alphabetical order. However, if we start at Alice (index 1), and use the pointers to determine which index to check next, then then we can traverse the list Alice -> Bob -> Charlie -> Darren.
What does this have to do with our notebook?
We can implement this in our notebook quite easily. Simply, our 'value' is our topic for a page, and our 'pointer' is the number of the page where the topic continues. If we were to be reading that topic, when we reach the end of a page, we look at the pointer, and head to the page specified.
Here is a diagram of how I set up each page using this method:

As you may have noticed, I added something that linked lists do not, a link to the previous page. This allows me to traverse a topic both forwards and backwards.
Adding Preceding pages
The beauty of using linked lists, is that it is extremely easy to insert a new page into the middle or start of a topic. For example, if we really wanted to add an introduction to a topic after writing multiple pages about it, all we need to do is create the page, and point to the previous first page as the next page.
Start Index
Now we have established what to do when we finish a page, and how to traverse through a topic from start to end. However, this poses one final question. How do we find the first page of a topic? Our topics are all over the place, and as we just discussed, our first page for a topic may not even be the one with the lowest page number!
The solution I propose for this is simple: store a list of all the topics and keep an updated record of the page that that topic starts on. We can also work out the maximum amount of space needed for this start index, using the following steps:
Count the total number of pages - this is the maximum number of topics our book could contain.
Count the number of lines on a page.
Divide the number of pages by the number of lines on a page to get the number of pages needed for the start index.
To make the start index easy to locate, we can then leave that number of pages free at the back of the book to be the start index (otherwise we would need a start index to find the start of the start index - I think you see the problem).
Now, if we wish to read through a topic, we look up its first page in the start index, head to that page, and begin reading. Easy as that.
Conclusion
Computer science is often pictured as a very abstract topic, where 1s and 0s magically generate human sounding speech, or allow us to store our important files. However, it can also be applied to how we live our lives, as at its core, computer science is about making decisions and tradeoffs, which humans encounter every second of every day.
"At its core, computer science is about making decisions and tradeoffs"
Even if you don't have a notebook, or would rather continue guessing at how many pages you need to leave when starting a new topic, I hope you at least had fun learning about some key computer science topics, and how we can use computer science in our every day lives.
For me, I am going to continue enjoying myself, turning my notebook ever more into a computer - I already have plans for what to do when I run out of room in my current notebook, and I hope that I have convinced at least one of you to turn your notebook into a computer, now!
Comments