In this 1 day sprint you will be implementing 2 data structures that are commonly used in computer science: stacks and queues. You have already learned about one use of stacks: for keeping track of a pile of functions that are in the process of execution. A queue data structure would be useful on occasions where you want to process tasks in the same order as they arrive, such as in a messaging application or a printer queue.
-
Research stacks and queues. Here is a good link https://en.wikibooks.org/wiki/Data_Structures/Stacks_and_Queues to get you started in your research. Make sure you understand how they operate internally and double check with us that you have a good understanding of their methods before you start.
-
Implement these two data structures using the functional pattern explained in the lecture.
-
Be sure to test your functions as you go.
-
Implement each data structure in its own file with its own test file.
You may not use JavaScript arrays or any array methods or properties to implement your stack and queue structures. Everything should be implemented with objects and custom methods.
-
Implement the set data structure. Sets have lots of potential methods you could implement so pick out a few that seem most useful/interesting and implement those.
-
Implement the tree data structure. [Trees] (https://en.wikipedia.org/wiki/Tree_(data_structure)) also have a lot of methods, many of which may come into tomorrow's sprint. Focus today on implementing methods that add and remove data (e.g. addData, removeData) or return a boolean, (e.g. isParent, isRoot, hasSiblings, isLeaf). Look through the article for ideas on the terminology to use.
-
If you finish this, have a look for other potential data structures and see if you can implement useful functions they may have.
- Fully understand the functional pattern of object creation in JavaScript, together with its pros and cons.
- Learn, throughout the sprint, about the 4 rules of
thisin JavaScript. - Introduce yourself to data structures.