my_list = [1,"candy",4.5]
35 | - mutable
36 | - heterogeneous
37 |
38 |
39 |
40 | ## Accessing items
41 |
42 | - Index or position
43 | - Negative indexing
44 | - Slicing
45 |
46 |
47 |
48 |
49 |
50 | ## Memory Behavior
51 |
52 | - Contiguous block of memory
53 | - Think of an array as a row of mailboxes with each having a unique integer address
54 | - Same item storage size at each index
55 |
56 |
57 |
58 |
59 | ## Let's Draw It!
60 |
61 |
62 |
63 | ## The Idea of a List
64 |
65 | - Lists are used to represent an ordered collection of objects.
66 | - There are many ways to build a list
67 | - In Python lists are actually built using dynamic arrays
68 |
69 |
70 |
71 | ## Static Arrays
72 |
73 | - Static arrays are a direct representation of how memory is organized in physical RAM
74 | - Can’t change size because their memory is allocated once as a single contiguous block
75 | - However, we often do not know or cannot predict how many items we need to store...
76 |
77 |
78 |
79 |
80 | ## Let's Draw It!
81 |
82 |
83 |
84 | ## Dynamic Arrays
85 |
86 | - Dynamic arrays can change size but still have to store their items in a static array of fixed size – indexes are marked as occupied or available
87 | - When the static array is out of space we need to allocate a larger one and copy all existing items into it before we can append a new item
88 |
89 |
90 |
91 |
92 | ## Let's Draw It!
93 |
94 |
95 |
96 | ## Shout Outs
97 |
98 |
99 |
100 | ## Lab Time
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/Lessons/Lesson5.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Linked Lists
4 |
5 | [Slides](https://make-school-courses.github.io/CS-1.2-Intro-Data-Structures/Slides/Lesson5.html)
6 |
7 |
8 |
9 | ## Annoucements
10 |
11 | - Quiz 1 next Monday
12 | - Midterms next week
13 |
14 | ## Check In
15 |
16 |
17 |
18 | ## Agenda
19 |
20 |
21 |
22 | ## Interview Question Warmup
23 |
24 | What are the key differences between a static and a dynamic array?
25 |
26 |
27 |
28 | ## Lists
29 |
30 | So far we have talked about the idea of a list and two different ways to implement one
31 |
32 | - static array
33 | - dynamic array
34 |
35 |
36 |
37 | ## Linked List
38 |
39 | A Linked List is another way to implement the idea of a list. Its key different is that it is non-contiguous in memory.
40 |
41 |
42 |
43 | ## Linked List
44 |
45 | A linked list is a lot like a scavenger hunt!
46 |
47 |
48 |
49 | ## Linked List Components
50 |
51 | - Node
52 | - data
53 | - next
54 | We can think of the data as the treasure and the next as a clue to the next Node (treasure location)
55 |
56 |
57 |
58 | ## Linked List Drawing
59 |
60 |
61 |
62 | ## Linked List Starter Code
63 |
64 | Find the starter code [here](https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures/blob/master/Code/linkedlist.py)
65 |
66 |
67 |
68 | ## Linked List vs. Arrays
69 |
70 | What are some advantages of the non-contiguous property? Some disadvantages?
71 |
72 |
73 |
74 | ## Assignment
75 |
76 | Finish the linked list starter code so that it will pass all tests in linkedlist_test.py
77 |
78 | Assignment can be found [here](Lessons/HW2.md)
79 |
80 |
81 |
82 | ## Shout Outs
83 |
84 |
85 |
86 | ## Lab Time
--------------------------------------------------------------------------------
/Lessons/Lesson6.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Algorithm Analysis
4 |
5 | ➡️ [**Slides**](https://make-school-courses.github.io/CS-1.2-Intro-Data-Structures/Slides/Lesson6.html ':ignore')
6 |
7 |
8 |
9 | # Interview Question Warmup
10 |
11 | Draw the steps for an algorithm to print out all the items in a linked list
12 |
13 |
14 |
15 | # Big O Notation
16 |
17 | - O(1): constant time
18 | - O(n): linear time, increases with the input n
19 | - O(n^2): Quadratic time, increases exponentially with input n
20 |
21 |
22 |
23 |
24 | # Let's Look At Some Examples
25 |
26 |
27 |
28 |
29 |
30 | # Big O Notation
31 |
32 | We shorten Big O notation to the most significant one
33 |
34 | O(n^2) + O(n) + O(1) ---> O(n^2)
35 |
36 |
37 |
38 | # Linked List Methods
39 |
40 | - Length: get the length of the list
41 | - Append: add a node to the end of the list
42 | - Prepend: add a node to the beginning of the list
43 | - Find: find a piece of data in the list
44 | - Insert: add an item in the middle
45 | - Delete: an item from the end of the list
46 |
47 |
48 |
49 | # Let's Analyze These Methods in Terms of Big O!
50 |
51 |
52 |
53 | # Shout Outs
54 |
55 |
56 |
57 | # Lab Time
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Lessons/Lesson7.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Hash Tables
4 |
5 | ➡️ [**Slides**](https://make-school-courses.github.io/CS-1.2-Intro-Data-Structures/Slides/Lesson7.html ':ignore')
6 |
7 |
8 |
9 | ## Interview Question Warmup
10 |
11 | 1. Draw a linked list with 3 items: "mango", "peach", "pineapple"
12 | 2. Write pseudocode for the append method from memory
13 |
14 |
15 |
16 | ## Hash Tables
17 |
18 | - Maps keys → values (any objects)
19 | - Python’s dict() / {} type is a hash table
20 | - Used because of strong average case performance (time complexity)
21 |
22 |
23 |
24 | ## Hash Table
25 |
26 | 
27 |
28 |
29 |
30 | ## Hash Table Analogy
31 |
32 | Think of coat checks...
33 |
34 |
35 |
36 | ## Hash Function
37 |
38 | - Converts a variable-size input (key) to a fixed-size integer output (hash code)
39 | - Same input → same output
40 | - Input can be many types: number (int or float), string, or immutable collection
41 |
42 |
43 |
44 | ## Hash Function
45 |
46 | 
47 |
48 |
49 |
50 | ## Which Bucket?
51 |
52 | - Hash function outputs are very large integers, but we want the index of a bucket
53 | - We can use the modulus operator %
54 |
55 | index = hash(key) % buckets
56 |
57 | index ranges from 0 to buckets-1
58 |
59 |
60 |
61 | ## Hash Collisions
62 |
63 | - It is impossible to map all possible inputs to a fixed output space without some inputs generating the same output (hash code)
64 | - Different inputs (keys) generating the same output (hash code) is called a hash collision
65 |
66 |
67 |
68 | ## Linear Probing
69 |
70 | - Each bucket contains at most one entry
71 | - On collision - find next open bucket, add entry there
72 | - To retrieve - find bucket, if that’s not entry, try next bucket until you find entry or empty bucket
73 | - Python’s dict uses probing
74 |
75 |
76 |
77 | ## Linear Probing
78 |
79 | 
80 |
81 |
82 |
83 | ## Chaining
84 |
85 | - Each bucket contains a linked list of entries
86 | - On collision - add to the bucket’s linked list
87 | - To retrieve - find bucket, find entry in linked list
88 | - We will use chaining to implement our hash table
89 |
90 |
91 |
92 | ## Chaining
93 |
94 | 
95 |
96 |
97 |
98 | ## Challenge: Draw a Hash Table Using Chaining
99 |
100 | - Our hash table will have 4 buckets
101 | - We have 3 key value pairs to add: "red": 5, "pink": 5, "blue": 4
102 | - The hash function will be len(color) % num_buckets
103 |
104 |
105 |
106 | ## Shout Outs
107 |
108 |
109 |
110 | ## Lab Time
111 |
112 | [Hash Table Worksheet](https://docs.google.com/document/d/1O8nQjC7bbKF4M5wxoelVilJo5QYC6R0a/copy)
113 |
114 |
--------------------------------------------------------------------------------
/Lessons/MarkovChains.md:
--------------------------------------------------------------------------------
1 | # Higher Order Markov Chains
2 |
3 | ## Activities
4 | - Code review implementations of hash table class instance methods
5 | - Lecture and discussion on building higher order Markov chains with larger window sizes
6 |
7 | ## Objectives
8 | After completing this class session and the associated tutorial challenges, students will be able to ...
9 | - Build higher order Markov chains based on observed frequency of *n*-grams (tuples of *n* words) in text
10 | - Generate sentences by sampling words by performing random walks on higher order Markov chain
11 | - Utilize a linked list as a queue to track words in a Markov chain's *n*-gram window
12 |
13 | ## Resources
14 | - Read Victor Powell's [visual explanation of Markov chains] and play with the interactive animated diagrams
15 | - Read Alex Dejeu's [article on how Markov chains work][Dejeu Markov article], with great examples specific to this project (especially section B, "Further Markov Model Topics" and its subsection 3, "Bigger Windows" on creating higher order Markov chains)
16 | - Read Dataiku's [article on using Markov chains with backoff][Dataiku Markov article] to generate Donald Trump and Hillary Clinton quotes
17 | - Watch Make School's [Markov chains lecture]
18 | - Review Make School's [Markov chains slides]
19 |
20 | ## Challenges
21 | These challenges are the baseline required to complete the project and course.
22 | Be sure to complete these before next class session and before starting on the stretch challenges below.
23 | - [Page 11: Markov Chains Revisited]
24 | - Build a second order Markov chain by analyzing frequency of adjacent words in text
25 | - Sample a random word from a state histogram in second order Markov chain
26 | - Generate a sentence by performing a random walk on second order Markov chain
27 | - [Page 12: Creating a Corpus]
28 | - Choose a source with at least 20,000 words (ideally, well over 100,000 words)
29 | - Collect your corpus (use Diffbot corpus collection script if needed)
30 |
31 | ## Stretch Challenges
32 | These challenges are more difficult and help you push your skills and understanding to the next level.
33 | - [Page 11: Markov Chains Revisited]
34 | - Extend code used to build second order Markov chain to build *n*-th order Markov chain for varying values of *n* (from 1 up to ~5)
35 | - Implement `MarkovChain` class to store states of word frequency histograms
36 | - Add methods for constructing state histograms and sampling words
37 | - Handle beginning and end of sentences with special start and stop tokens
38 | - Use a linked list as a queue to track words in Markov chain's *n*-gram window
39 | - Create a deque (double-ended queue) with a doubly-linked list
40 | - Implement a circular buffer (fixed-size queue) with a fixed-size array
41 |
42 |
43 | [Markov chains lecture]: https://www.youtube.com/watch?v=dNaJg-mLobQ
44 | [Markov chains slides]: https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures/blob/master/Slides/MarkovChains.pdf
45 | [visual explanation of Markov chains]: http://setosa.io/blog/2014/07/26/markov-chains/
46 | [Dejeu Markov article]: https://hackernoon.com/from-what-is-a-markov-model-to-here-is-how-markov-models-work-1ac5f4629b71
47 | [Dataiku Markov article]: https://blog.dataiku.com/2016/10/08/machine-learning-markov-chains-generate-clinton-trump-quotes
48 | [Page 11: Markov Chains Revisited]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/markov-chains-revisited
49 | [Page 12: Creating a Corpus]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/creating-a-corpus
50 |
--------------------------------------------------------------------------------
/Lessons/Probability.md:
--------------------------------------------------------------------------------
1 | # [Probability & Sampling](https://docs.google.com/presentation/d/1rX0fkg-PdG_ypu4EL_cN_dDZ96UCrZkmEXeRRdT99lI/edit#slide=id.g6e846b49fc_2_76)
2 |
3 | ## Activities
4 | - Compare code quality for histogram implementations
5 | - Refactor code to improve readability, modularity, and performance
6 | - Compare tradeoffs of different histogram implementations
7 | - Watch [video of histogram comparison whiteboard activity]
8 | - Lecture and discussion following [probability and sampling slides]
9 | - Watch [video of probability and sampling lecture]
10 |
11 | ## Objectives
12 | After completing this class session and the associated tutorial challenges, students will be able to ...
13 | - Sample words according to their observed frequencies
14 | - Compare tradeoffs with different sampling techniques
15 | - Validate sampling techniques based on relative probabilities
16 |
17 | ## Challenges
18 | These challenges are the baseline required to complete the project and course.
19 | Be sure to complete these before next class session and before starting on the stretch challenges below.
20 | - [Page 4: Stochastic Sampling]
21 | - Sample words by observed frequency weighting
22 | - Test relative probabilities to validate sampling technique
23 |
24 | ## Stretch Challenges
25 | These challenges are more difficult and help you push your skills and understanding to the next level.
26 | - [Page 4: Stochastic Sampling]
27 | - Optimize for speed of sampling (read time)
28 | - Optimize for memory (use the least amount of space)
29 | - Solve with only lists and tuples
30 | - Combine other weighting techniques
31 |
32 | ## Resources
33 | - Review Make School's [probability and sampling slides]
34 | - Consult Python's [random module] documentation, but *do not* use the `random.choices` function (the challenge is to implement this yourself)
35 | - If you're *really* stuck, read the Python Cookbook's [Randomly Picking Items with Given Probabilities], but *don't read this until you've tried to solve it yourself*
36 |
37 |
38 | [video of histogram comparison whiteboard activity]: https://www.youtube.com/watch?v=w0F7gZbSoHg
39 | [video of probability and sampling lecture]: https://www.youtube.com/watch?v=-fq36v2KjR8
40 | [probability and sampling slides]: https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures/blob/master/Slides/Probability.pdf
41 | [Page 4: Stochastic Sampling]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/stochastic-sampling-506e62a9-e8be-486f-8c72-486baa8c3454
42 | [random module]: https://docs.python.org/3/library/random.html
43 | [Randomly Picking Items with Given Probabilities]: https://www.safaribooksonline.com/library/view/python-cookbook-2nd/0596007973/ch04s22.html
44 |
--------------------------------------------------------------------------------
/Lessons/Quiz1.md:
--------------------------------------------------------------------------------
1 | # Quiz 1 Study Guide
2 |
3 | All quizzes will be taken on [gradescope](https://www.gradescope.com/courses/131138). You will have several days in which to complete the quiz and it will be open notes. Please read the instructions carefully and show all work on your quiz. If you do not pass a quiz you will have an opportunity to retake.
4 |
5 | ## Topics
6 | - Functions
7 | - Know how to write a function from a description
8 | - Know how to call and use functions
9 | - OOP
10 | - Know how to write a class from a description
11 | - Know how to instantiate objects from a class
12 | - Know fundamental OOP vocabulary such as methods and properties
13 | - Strings
14 | - Understand how to print all the characters in a string
15 | - Understand how to use basic string methods such as split()
--------------------------------------------------------------------------------
/Lessons/Quiz2.md:
--------------------------------------------------------------------------------
1 | # Quiz 2 Study Guide
2 |
3 | All quizzes will be taken on [gradescope](https://www.gradescope.com/courses/131138). You will have several days in which to complete the quiz and it will be open notes. Please read the instructions carefully and show all work on your quiz. If you do not pass a quiz you will have an opportunity to retake.
4 |
5 | ## Topics
6 | - Algorithm Analysis
7 | - Be able to analyze a code snippet in terms of time complexity (O(1), O(N), O(N^2)) and justify your answer
8 | - Linked Lists
9 | - Be able to draw how a linked list is organized in memory (refer to the [linked list worksheet](https://docs.google.com/document/d/1hdhCZtQMwFuXs6x_X5lZYjHj47cTkRnqZiFn846J-pE/copy))
10 | - Be able to explain what each linked list method does and how it works with drawings and diagrams
11 | - append
12 | - find
13 | - prepend
14 | - length
15 | - delete
16 | - Be able to explain the time complexity of each of the above methods (refer to the [linked list time complexity worksheet](https://docs.google.com/document/d/1rkQRoTs-jbn7jqo-fPgjrpXE3Rl0hqFFHUBW7QtvCBk/copy)) and justify your answer with drawings
17 | - Hash Tables
18 | - Be able to draw a hash table (refer to the [hash table worksheet](https://docs.google.com/document/d/10W1e0Ws03bMphekNKk5XN60h4GqBdcLBnhtpIHIprlM/copy))
19 | - Be able to explain what each hash table method does and how it works with drawings and diagrams
20 | - get
21 | - set
22 | - delete
23 | - keys
24 | - Be able to explain the time complexity of each of the above methods (refer to the [hash table time complexity worksheet](https://docs.google.com/document/d/1XuklcBhC5_hF1Kt8s25O4PmYdkuHxutkN_PIhe82Cx0/copy))
--------------------------------------------------------------------------------
/Lessons/RandomStrings.md:
--------------------------------------------------------------------------------
1 | # [Strings & Random Numbers](https://docs.google.com/presentation/d/137XVqxjeV0wYyxjPZwW3UKtaOR6R2uVYArw2-_5Qt7Q/edit#slide=id.p)
2 |
3 | ## Activity
4 | - Review prerequisite skills and knowledge
5 | - Watch [video of course and project kickoff]
6 | - Show examples of completed projects and similar websites
7 |
8 | ## Objectives
9 | After completing this class session and the associated tutorial challenges, students will be able to ...
10 | - Create Python scripts and modules
11 | - Access command-line arguments
12 | - Read files and extract lines of text
13 | - Remove whitespace from strings
14 | - Store and access elements in a list
15 | - Generate random integers in a range
16 |
17 | ## Challenges
18 | Visit Make School's [Online Academy] to find the [Tweet Generator tutorial].
19 |
20 | These challenges are the baseline required to complete the project and course.
21 | Be sure to complete these before next class session and before starting on the stretch challenges below.
22 | - [Page 1: Let’s Get Started]
23 | - Python scripts and modules
24 | - Rearrange words script
25 | - [Page 2: Random Dictionary Words]
26 | - Generate random dictionary words
27 | - Benchmark and optimize for speed
28 |
29 | ## Stretch Challenges
30 | These challenges are more difficult and help you push your skills and understanding to the next level. They are often found in the "Where to Go From Here" section at the bottom of most tutorial pages, although a few bonus challenges are only included here.
31 | - [Page 1: Let’s Get Started]
32 | - Reverse words/sentences
33 | - Interactive mad libs game
34 | - Simple anagram generator
35 | - [Page 2: Random Dictionary Words]
36 | - Vocabulary study game
37 | - Autocomplete program
38 | - Real word anagram generator
39 | - Bonus challenges
40 | - Write a script that imitates [`cowsay`](https://en.wikipedia.org/wiki/Cowsay) – install with `brew install cowsay`
41 | - Write your own shuffle function or implement the [Fisher–Yates shuffle](https://bost.ocks.org/mike/shuffle/)
42 |
43 | ## Resources
44 | - Make School's [OOP coding challenge](http://hr.gs/ooptest) – covers classes, inheritance, and polymorphism
45 | - Code School's [Python tutorial](https://www.codeschool.com/courses/try-python) – gentle introduction with strings and conditionals
46 | - HackerRank's [Python challenges](https://www.hackerrank.com/domains/python/py-introduction) – try the basic data types and strings sections
47 | - Interview Cake's [in-place shuffle interview problem](https://www.interviewcake.com/question/python/shuffle) – with helpful detailed hints
48 | - Google's [Python class](https://developers.google.com/edu/python/) – includes lecture videos and lots of practice exercises
49 |
50 |
51 | [video of course and project kickoff]: https://www.youtube.com/watch?v=Ka4QT1OxzdI
52 | [Tweet Generator intro slides]: https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures/blob/master/Slides/TweetGenerator.pdf
53 | [Online Academy]: https://www.makeschool.com/academy
54 | [Tweet Generator tutorial]: http://make.sc/oa-tweet-generator
55 |
56 | [Page 1: Let’s Get Started]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/let-s-get-started
57 | [Page 2: Random Dictionary Words]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/random-dictionary-words-0f05439f-f238-4cb7-9be4-535aefaf0f2f
58 |
--------------------------------------------------------------------------------
/Lessons/RegularExpressions.md:
--------------------------------------------------------------------------------
1 | # Regular Expressions
2 |
3 | ## Activities
4 | - Code review implementations of higher order Markov chains
5 | - Review structures used to build Markov chain and discuss scalability
6 | - Lecture and discussion following [regular expressions slides]
7 | - Build and test regular expressions with [RegExr] and visualize them with [RegExper]
8 |
9 | ## Objectives
10 | After completing this class session and the associated tutorial challenges, students will be able to ...
11 | - Use regular expressions to clean up and remove junk text from corpus
12 | - Use regular expressions to create a more intelligent word tokenizer
13 |
14 | ## Resources
15 | - Watch Make School's [regular expressions lecture]
16 | - Review Make School's [regular expressions slides]
17 | - Use Cheatography's [regular expressions cheat sheet] as a reference guide
18 | - Solve interactive challenges in UBC's [regular expressions lab webpage][UBC regex lab]
19 | - Use [RegExr] or [RegEx Pal] to build and test regular expression patterns on text samples
20 | - Use [RegExper] to visualize railroad diagrams of regular expression patterns
21 | - Read StackOverflow answers to questions about using regular expressions to parse HTML: first [some comedic relief][SO match HTML tags] and then [an explanation of why you shouldn't][SO why not HTML]
22 |
23 | ## Challenges
24 | These challenges are the baseline required to complete the project and course.
25 | Be sure to complete these before next class session and before starting on the stretch challenges below.
26 | - [Page 13: Parsing Text and Clean Up]
27 | - Remove unwanted junk text (e.g., chapter titles in books, character names in scripts)
28 | - Remove unwanted punctuation (e.g., `_` or `*` characters around words)
29 | - Convert HTML character codes to ASCII equivalents (e.g., `—` to `—`)
30 | - Normalize punctuation characters (e.g., convert both types of quotes – `‘’` and `“”` – to regular quotes – `''` and `""`)
31 | - [Page 14: Tokenization]
32 | - Handle special characters (e.g., underscores, dashes, brackets, `$`, `%`, `•`, etc.)
33 | - Handle punctuation and hyphens (e.g., `Dr.`, `U.S.`, `can't`, `on-demand`, etc.)
34 | - Handle letter casing and capitalization (e.g., `turkey` and `Turkey`)
35 |
36 | ## Stretch Challenges
37 | These challenges are more difficult and help you push your skills and understanding to the next level.
38 | - [Page 13: Parsing Text and Clean Up]
39 | - Make your parser code readable, then improve its organization and modularity so that it's easy to modify in the future
40 | - Modify your parser so that it can be used as both a module (imported by another script) and as a stand-alone, executable script that, when invoked from the command line with a file argument, will print out the cleaned-up version, which can be redirected into a file
41 | - [Page 14: Tokenization]
42 | - Make your tokenizer code readable, then improve its organization and modularity so that it's easy to modify in the future
43 | - Write tests to ensure that you're getting the results you've designed for, then run your tests with controlled input data
44 | - Come up with at least one other tokenization strategy and compare performance against your original strategy, then find ways to make your tokenizer more efficient
45 |
46 |
47 | [regular expressions lecture]: https://www.youtube.com/watch?v=roUtBDH3Obc
48 | [regular expressions slides]: https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures/blob/master/Slides/RegularExpressions.pdf
49 | [regular expressions cheat sheet]: https://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
50 | [UBC regex lab]: http://www.ugrad.cs.ubc.ca/~cs121/2015W1/Labs/Lab8/lab8.html
51 | [RegExr]: https://regexr.com/
52 | [RegEx Pal]: https://www.regexpal.com/
53 | [RegExper]: https://regexper.com/
54 | [SO match HTML tags]: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags
55 | [SO why not HTML]: http://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not
56 |
57 | [Page 13: Parsing Text and Clean Up]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/parsing-text-and-clean-up-969fe44d-6090-45d0-be85-c12e75cbade6
58 | [Page 14: Tokenization]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/tokenization-551b78bf-22a5-4c32-8a33-0b5f9e93a0e1
59 |
--------------------------------------------------------------------------------
/Lessons/Sentences.md:
--------------------------------------------------------------------------------
1 | # [Generating Sentences](https://docs.google.com/presentation/d/1B0cYEcEK0TIcRVZB8Gy8WcxMEUL53yl5emjJTi2_KbU/edit)
2 |
3 | ## Activities
4 | - Compare histogram functions to `Dictogram` and `Listogram` class instance methods
5 | - Discuss advantages of classes and object-oriented programming (OOP)
6 | - Lecture and discussion on building Markov chains and performing random walks
7 | - Watch [video of lecture on generating sentences with Markov chains]
8 |
9 | ## Objectives
10 | After completing this class session and the associated tutorial challenges, students will be able to ...
11 | - Build Markov chains based on observed frequency of adjacent words in text
12 | - Generate sentences by sampling words by performing random walks on Markov chain
13 |
14 | ## Challenges
15 | These challenges are the baseline required to complete the project and course.
16 | Be sure to complete these before next class session and before starting on the stretch challenges below.
17 | - [Page 7: Generating Sentences]
18 | - Build a Markov chain by analyzing frequency of adjacent words in text
19 | - Sample a random word from a state histogram in a Markov chain
20 | - Generate a sentence by performing a random walk on Markov chain
21 |
22 | ## Stretch Challenges
23 | These challenges are more difficult and help you push your skills and understanding to the next level.
24 | - [Page 7: Generating Sentences]
25 | - Implement `MarkovChain` class to store states of word frequency histograms
26 | - Add methods for constructing state histograms and sampling words
27 | - Handle beginning and end of sentences with special start and stop tokens
28 |
29 | ## Resources
30 | - Read Victor Powell's [visual explanation of Markov chains] and play with the interactive animated diagrams
31 | - Read Alex Dejeu's [article on how Markov chains work][Dejeu Markov article], with great examples specific to this project (only the "Intro To Markov Models" section; we'll cover the topics in the "Further Markov Model Topics" section later in the course)
32 |
33 | [video of lecture on generating sentences with Markov chains]: https://www.youtube.com/watch?v=NcmSugXmB-g
34 | [Page 7: Generating Sentences]: https://www.makeschool.com/academy/tutorial/tweet-generator-data-structures-probability-with-python/generating-sentences-with-markov-chains
35 | [visual explanation of Markov chains]: http://setosa.io/blog/2014/07/26/markov-chains/
36 | [Dejeu Markov article]: https://hackernoon.com/from-what-is-a-markov-model-to-here-is-how-markov-models-work-1ac5f4629b71
37 |
--------------------------------------------------------------------------------
/Lessons/graphproject.md:
--------------------------------------------------------------------------------
1 | To complete the final graph project refer to these [project specs](https://docs.google.com/document/d/1KIi-KBvGkLo6epwZ36A_37yIv7QSU7u9gKbDYgXFPyw/edit?usp=sharing) and the activities we will do in class.
--------------------------------------------------------------------------------
/Lessons/playlist.md:
--------------------------------------------------------------------------------
1 | # Music Playlist 🎶
2 |
3 |
4 | ## Description
5 |
6 | In this project, you will be building a music playlist builder using a linked list as the underlying data structure. Your playlist builder allows users to add new songs, remove songs, search for songs, and get the length of the playlist.
7 |
8 | ## Learning Outcomes
9 | By completing this project, you should be able to…
10 |
11 | - Create a linked list using an OOP approach
12 | - Identify the main components of a linked list
13 | - Read items in a linked list
14 | - Update items in a linked list
15 | - Search for items in a linked list
16 |
17 |
18 | ## Requirements
19 |
20 | ### Submission Requirements:
21 | 1. Your submitted code should be in a new (public) repo on Github.
22 | 1. Your repository should have a minimum of **5 commits**.
23 | 1. Your repo should include a README with the name of your project and a description.
24 | 1. Create a demo video. The demo should include a walkthrough of your code and demonstration of your project working.
25 | 1. [Optional] Upload your video to Google Drive and share a link if Gradescope upload speeds are too slow.
26 | 1. Submit the link to your repo and demo on [Gradescope](https://www.gradescope.com/courses/202248/assignments/803584).
27 |
28 | ### Assignment Requirements:
29 |
30 | Download the [starter code from here](https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures/tree/master/src/PlaylistLinkedList-StarterCode), which includes:
31 |
32 | 1. `main.py`
33 | 1. `Playlist.py`
34 | 1. `Song.py`
35 |
36 |
37 | Your goals are:
38 |
39 | 1. Complete the `TODO`s in `Song.py`:
40 | - Create a getter method for the `title` attribute, called `get_title()`
41 | - Create a setter method for the `title` attribute, called `set_title()`. Make sure titles are type cased to strings and are **Title Cased**.
42 | - Create a getter method for the `next_song` attribute, called `get_next_song()`
43 | - Create a setter method for the `next_song` attribute, called `set_next_song()`. Make sure titles are type cased to strings and are Title Cased.
44 | - Using the `__str___()` dunder method, return a string of the song title.
45 | - Using the `__repr__()` dunder method, return a string formatted as the following:`'Song Title -> Next Song Title'`
46 |
47 | 2. Complete the `TODO`s in `Playlist.py`:
48 | - Create a method called `add_song()` that creates a `Song` object and adds it to the playlist. This method has one parameter called `title`.
49 | - Create a method called `find_song()` that searches for whether a song exists in the playlist and returns its index. The method has one parameter, `title`, which is the title of the song to be searched for. If the song is found, return its index. If not found, return `-1`.
50 | - Create a method called `remove_song()` that removes a song from the playlist. This method takes one parameter, `title`, which is the song that should be removed.
51 | - Create a method called `length()`, which returns the number of songs in the playlist.
52 | - Create a method called `print_songs()` that prints a numbered list of the songs in the playlist.
53 | - Test your solution by running the code in `main.py` and test all of the 5 options.
54 |
55 |
56 |
57 | ### Stretch Challenges (Optional)
58 | 1. Add a `insert_song(title, index)` method to the Playlist class that creates a new song and adds it a specified index of the linked list.
59 | 1. Add a `shuffle()` method to the Playlist class that shuffles the order of the Songs in the playlist. After, add it to the options menu in main.py
60 | 1. Add a `reverse()` method that will reverse the linked list in place.
61 |
62 |
63 | ## Rubric
64 |
65 | You can find the rubric for the Playlist project [here](https://docs.google.com/document/d/18EX0UCNB2AjkeLQ4JIh2JRq7vGynZpqk4EsJyAdgX9w/edit?usp=sharing)
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Lessons/word_freq.md:
--------------------------------------------------------------------------------
1 | # Frequency Counting with a Hash Table 📊
2 |
3 |
4 | ## Description
5 |
6 | One standard use of a hash table is counting the frequency of words in a file. For this assignment, you will use a hash table to implement a word-frequency counting program.
7 |
8 |
9 | ## Setup
10 |
11 | 🚨 Before starting the assignment, watch [How to: Setup for a New Assignment](https://youtu.be/MCbDO8IpqZM).
12 |
13 | This tutorial walks you through how to set up a new repository, make commits, and push code to Github.
14 |
15 |
16 |
17 | ## Requirements
18 |
19 | ### Submission Requirements:
20 | 1. Your submitted code should be in a new (public) repo on Github.
21 | 1. Your repository should have a minimum of **5 commits**.
22 | 1. Your repo should include a README with the name of your project and a description.
23 | 1. Create a demo video. The demo should include a walkthrough of your code and demonstration of your project working.
24 | 1. [Optional] Upload your video to Google Drive and share a link if Gradescope upload speeds are too slow.
25 | 1. Submit the link to your repo and demo on [Gradescope](https://www.gradescope.com/courses/202248/assignments/803584).
26 |
27 | ### Assignment Overview:
28 |
29 | Your program will do the following:
30 | * Count the number of occurrences of each word in the file.
31 | * Print all of the words and their frequencies.
32 |
33 | For example, a text file that contains these lines:
34 |
35 | ```
36 | I write, erase, rewrite
37 | Erase again, and then
38 | A poppy blooms.
39 | ```
40 |
41 | would generate this output:
42 | ```
43 | a: 1
44 | again: 1
45 | and: 1
46 | blooms: 1
47 | erase: 2
48 | i: 1
49 | poppy: 1
50 | rewrite: 1
51 | then: 1
52 | write: 1
53 | ```
54 |
55 | Assumptions:
56 | * The starter code handles all of the file I/O and string tokenization discussed below:
57 | * Words will be counted in a case-insensitive manner (For example, in the above example, `Erase` and `erase` are counted as the same word.)
58 | * Punctuation is ignored. You can use a delimiter to ignore the following characters: `, . ; : - ? !`
59 | * Assume that the input file consists of letter-only words (That is, the file will not have words that contain apostrophes such as `isn’t` and `‘tis`).
60 |
61 |
62 | ### Assignment Requirements:
63 |
64 | Download the [starter code from here](https://repl.it/@JoiAnderson2/Frequency-Counter-Starter-Code), which includes:
65 |
66 | [Click here to download zip file](https://repl.it/@JoiAnderson2/Frequency-Counter-Starter-Code.zip)
67 |
68 | * `main.py`
69 | * `HashTable.py`
70 | * `LinkedList.py`
71 | * `Node.py`
72 | * `example.txt`
73 |
74 | Your goals are:
75 |
76 | Complete the `TODOs` in `HashTable.py`:
77 |
78 | 1. `create_arr` - Complete the `create_arr` method in `HashTable.py`. Each element of the hash table (arr) is a linked list. This method creates an array (list) of a given size and populates each of its elements with a LinkedList object. Note: Doing `[LinkedList()] * size` does not work.
79 |
80 | 1. `hash_func` - Complete the `hash_func` method in `HashTable.py`. Create your own hash function. Hash functions are a function that turns each of these keys into an index value that we can use to decide where in our list each key:value pair should be stored.
81 |
82 | 1. `insert` - Complete the `insert` method in `HashTable.py`. Should insert a key value pair into the hash table, where the key is the word and the value is a counter for the number of times the word appeared. When inserting a new word in the hash table, be sure to check if there is a Node with the same key in the table already.
83 |
84 | 1. `print_key_values` - Complete the `print_key_values` method in `HashTable.py`. Traverse through the every Linked List in the table and print the key value pairs (formatted like the above example)
85 |
86 |
87 |
88 | ### Stretch Challenges (Optional)
89 | 1. Print the total number of distinct words at the beginning of your program.
90 | 1. Offer the user a prompt to query the exact count of a particular word.
91 |
92 |
93 |
94 | ## Rubric
95 |
96 | Coming soon.
97 |
--------------------------------------------------------------------------------
/Reveal/README.md:
--------------------------------------------------------------------------------
1 | # reveal-md
2 |
3 | ## Installation:
4 |
5 | ```bash
6 | npm install -g reveal-md
7 | ```
8 |
9 | ## Usage:
10 |
11 | ### Syntax
12 |
13 | **Slide styling:**
14 |
15 | ```
16 |
17 | ```
18 |
19 | **Change background color:**
20 |
21 | ```
22 |
23 | ```
24 |
25 | **Signal a horizontal slide transition**
26 |
27 | ```
28 |
29 | ```
30 |
31 | **Signal a vertical slide transition**
32 |
33 | ```
34 |
35 | ```
36 |
37 | ### Local Presentation
38 |
39 | This starts a local server and opens any Markdown file as a reveal.js presentation in the default browser.
40 |
41 | ```bash
42 | $ reveal-md Lessons/
43 | ```
44 |
45 | ### Generate Slides
46 |
47 | Generate static HTML (for GitHub Pages):
48 |
49 | ```bash
50 | $ reveal-md Lessons/ --static Slides
51 | ```
52 |
53 | ## Resources
54 | For more information, check out the [reveal-md documentation](https://github.com/webpro/reveal-md).
--------------------------------------------------------------------------------
/Reveal/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Make-School-Courses/CS-1.2-Intro-Data-Structures/6658b7087fcbfaa19bb97e1abc780debae0350dc/Reveal/favicon.ico
--------------------------------------------------------------------------------
/Setup.md:
--------------------------------------------------------------------------------
1 | ## Repository Setup Instructions
2 |
3 | The course's *upstream* repository (located at `https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures`) contains course materials including the schedule, class topics, tutorial milestones, challenges, starter code, unit tests, slides, and links to resources.
4 | It will be updated throughout the course, so you will need to regularly *pull* from it to get new materials.
5 | (Note that you cannot *push* to the course's upstream repository.)
6 | However, you can *clone* this repo to get upstream changes and also push your code to your own repo.
7 |
8 | **Important:**
9 | Please follow these instructions *exactly* to correctly set up your clone of this repository. If you skip a step or do them out of order, it may not work.
10 |
11 | **Step 1:**
12 | Set up your local clone of this course repo on your computer.
13 |
14 | 1. **Clone** (do not *fork*) this repo from GitHub onto your local computer.
15 |
16 | - First open your terminal and navigate into the folder where you keep your course material and projects:
17 | `cd ~/MakeSchool/Courses` (or something similar for your folders)
18 |
19 | - Then run this command to *clone* the course repo:
20 | `git clone https://github.com/Make-School-Courses/CS-1.2-Intro-Data-Structures.git`
21 |
22 | - Now navigate into the new folder Git just created:
23 | `cd CS-1.2-Intro-Data-Structures`
24 |
25 | 1. [**Create a new empty repo** on GitHub](https://github.com/new) also named `CS-1.2-Intro-Data-Structures` and **do not** initialize it with a ReadMe. (Creating a *new* repo instead of a *fork* allows you to earn credit towards your GitHub commit streak.)
26 |
27 | 1. **Set the `origin` remote's URL** on your local repo to point to your new repo on GitHub:
28 | `git remote set-url origin https://github.com/