|
1 | 1 | # Sprint Challenge: Data Structures and Algorithms |
2 | 2 |
|
3 | | -For the data structures portion of this sprint challenge, you'll be implementing a few functions that build off of some of the data structures you implemented in the first half of the week. Then you'll be analyzing the runtimes of these functions. |
| 3 | +In this week's Sprint you explored and implemented some classic algorithmic approaches and used them to solve novel problems. You also implemented some classic and fundamental data structures and learned about how to go about evaluating their respective runtimes and performance. This Sprint Challenge aims to assess your comfort with these topics through exercises that build on the data structures you implemented and the algorithmic intuition you've started to build up. |
4 | 4 |
|
5 | | -For the algorithms portion of the sprint challenge, you'll be answering the questions posed in the `Algorithms_Questions.md` file regarding runtime complexities and algorithmic paradigms. |
| 5 | +## Instructions |
6 | 6 |
|
7 | | -## Data Structures |
| 7 | +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** |
8 | 8 |
|
9 | | -It is recommended that you allot about 2 hours for this portion of the sprint challenge. |
| 9 | +This is an individual assessment. All work must be your own. Your Challenge score is a measure of your ability to work independently using the material covered throughout this sprint. You need to demonstrate proficiency in the concepts and objectives that were introduced and that you practiced in the preceding days. |
10 | 10 |
|
11 | | -### Task 1. Implement Depth-First and Breadth-First Traversal on the Binary Search Tree Class |
12 | | -Navigate into the `ex1` directory in the `data_structures` directory. Inside, you'll see the `binary-search-tree.py` file with a complete implementation of the binary search tree class. Your first task is to implement the methods `depth_first_for_each` and `breadth_first_for_each` on the `BinarySearchTree` class: |
| 11 | +You are not allowed to collaborate during the Sprint Challenge. However, you are encouraged to follow the twenty-minute rule and seek support from your PM and Instructor in your cohort help channel on Slack. Your submitted work reflects your proficiency in the concepts and topics that were covered this week. |
| 12 | + |
| 13 | +You have three hours to complete this Sprint Challenge. Plan your time accordingly. |
| 14 | + |
| 15 | +## Commits |
| 16 | + |
| 17 | +Commit your code regularly and meaningfully. This helps both you (in case you ever need to return to old code for any number of reasons) and it also helps your project manager to more thoroughly assess your work. |
| 18 | + |
| 19 | +## Description |
| 20 | + |
| 21 | +This Sprint Challenge is split into two separate parts: a data structures portion and an algorithms portion. |
| 22 | + |
| 23 | +### Data Structures |
| 24 | + |
| 25 | +It is recommended that you allot about 1 and a half hours for this portion of the Sprint Challenge. |
| 26 | + |
| 27 | +#### Task 1. Implement Depth-First and Breadth-First Traversal on the Binary Search Tree Class |
| 28 | + |
| 29 | +Navigate into the `ex1` directory in the `data_structures` directory. Inside, you'll see the `binary-search-tree.py` file with a complete implementation of the binary search tree class. Your first task is to implement either `depth_first_for_each` or `breadth_first_for_each` on the `BinarySearchTree` class: |
13 | 30 |
|
14 | 31 | * `depth_first_for_each(cb)` receives an anonymous function as a parameter. It should then execute the anonymous function on each node in the tree in [depth-first](https://en.wikipedia.org/wiki/Depth-first_search) order. Your task is to implement the logic to traverse the tree in the desired order. Remember that the anonymous function is supplied by the caller of the method. All you have to do is ensure that the anonymous function is being called on each tree node in the desired order. |
15 | 32 |
|
16 | | - *HINT*: In order to achieve depth-first order, you'll probably want to utilize a Stack data structure. |
| 33 | + _HINT_: In order to achieve depth-first order, you'll probably want to utilize a Stack data structure. |
| 34 | + |
| 35 | + * Run `python test_depth_first_search.py` to test your depth-first search implementation. |
17 | 36 |
|
18 | 37 | * `breadth_first_for_each(cb)` receives a callback function as a parameter. It should then execute the anonymous function on each node in the tree in [breadth-first](https://en.wikipedia.org/wiki/Breadth-first_search) order. Your task is to implement the logic to traverse the tree in the desired order. Remember that the anonymous function is supplied by the caller of the method. All you have to do is ensure that the anonymous function is being called on each tree node in the desired order. |
19 | 38 |
|
20 | | - *HINT*: In order to achieve breadth-first order, you'll probably want to utilize a Queue data structure. |
| 39 | + _HINT_: In order to achieve breadth-first order, you'll probably want to utilize a Queue data structure. |
21 | 40 |
|
22 | | -NOTE: In Python, anonymous functions are referred to as "lambda functions". When passing in an anonymous function as input to either `depth_first_for_each` or `breadth_first_for_each`, you'll want to define them as lambda functions. For more information on lambda functions, check out this documentation: [https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions](https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions) |
| 41 | + * Run `python test_breadth_first_search.py` to test your breadth-first search implementation. |
23 | 42 |
|
24 | | -Run `python test_binary_search_tree.py` to run the tests for these methods to ensure that your implementation is correct. |
| 43 | +> Note that in Python, anonymous functions are referred to as "lambda functions". When passing in an anonymous function as input to either `depth_first_for_each` or `breadth_first_for_each`, you'll want to define them as lambda functions. For more information on lambda functions, check out this documentation: [https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions](https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions) |
25 | 44 |
|
26 | | -### Task 2. Implement Heapsort |
27 | | -Inside the `ex2` directory you'll find the `heap.py` file with a working implementation of the heap class. Your second task is to implement a sorting method called [heapsort](https://en.wikipedia.org/wiki/Heapsort) that uses the heap data structure in order to sort an array of numbers. Your `heapsort` function should return a new array containing all of the sorted data. |
| 45 | +> Note that it is not your job to worry about what the callback function being passed in is doing. That is up to the user of your traversal method. All you care about when implementing the traversal method is to call the passed-in callback in either depth-first or breadth-first order, depending on which traversal method you're implementing. |
28 | 46 |
|
29 | | -Run `python test_heap.py` to run the tests for your `heapsort` function to ensure that your implementation is correct. |
| 47 | +#### Task 2. Implement Heapsort |
30 | 48 |
|
31 | | -### Task 3. Analyze some runtimes |
32 | | -Open up the `Data_Structures_Answers.md` file. This is where you'll jot down your answers for the runtimes of the functions you just implemented. Be sure to also answer any other questions posed in the `Data_Structures_Answers.md` file! |
| 49 | +Inside the `ex2` directory you'll find the `heap.py` file with a working implementation of the heap class. Your second task is to implement a sorting method called [heapsort](https://en.wikipedia.org/wiki/Heapsort) that uses the heap data structure in order to sort an array of numbers. Your `heapsort` function should return a new list containing all of the sorted data. |
33 | 50 |
|
34 | | -## Algorithms |
| 51 | +Run `python test_heap.py` to run the tests for your `heapsort` function to ensure that your implementation is correct. |
35 | 52 |
|
36 | | -It is recommended that you allot about 1 hour for this portion of the sprint challenge. |
| 53 | +#### Task 3. Analyze some runtimes |
37 | 54 |
|
38 | | -For the algorithms portion of the sprint challenge, you'll be answering questions posed in the `Algorithms_Questions.md` document inside the `algorithms` directory. Add your answers to the questions in the `Algorithms_Answers.md` file. |
| 55 | +Open up the `Data_Structures_Answers.md` file. This is where you'll jot down your answers for the runtimes of the functions you just implemented. Be sure to also answer any other questions posed in the `Data_Structures_Answers.md` file! |
39 | 56 |
|
40 | | -## Rubric |
| 57 | +### Algorithms |
41 | 58 |
|
42 | | -Each test in the Data Structures portion is worth 2 points for a total of 6. |
43 | | -Each runtime analysis question in the Data Structures portion is worth 1 point for a total of 6. |
44 | | -Each question in the Algorithms portion is worth 2 points for a total of 8. |
| 59 | +It is recommended that you allot about 1 and a half hours for this portion of the sprint challenge. |
45 | 60 |
|
46 | | -In order to earn a score of 3, you'll need to score at least 90%, or 18 / 20 total possible points. |
| 61 | +For the algorithms portion of the sprint challenge, you'll be answering questions posed in the `Algorithms_Questions.md` document inside the `algorithms` directory. Write down your answer and also write down a justification for _why_ you put down that answer. This could net you some partial credit if your justification is sound but the answer you put down turns out to not be correct. Add your answers to the questions in the `Algorithms_Answers.md` file. |
47 | 62 |
|
48 | | -In order to earn a score of 2, you'll need to score at least 70%, or 14 / 20 total possible points. |
| 63 | +### Stretch Problems |
49 | 64 |
|
50 | | -Anything lower earns you a score of 1. |
| 65 | +Implement the other tree traversal algorithm that you didn't implement on the `BinarySearchTree` class. Run the appropriate test file to test your implementation's correctness. |
0 commit comments