**Год выпуска**: 2016

**Производитель**: https://frontendmasters.com/

**Сайт производителя**: https://frontendmasters.com/courses/computer-science/

**Автор**: Brian Holt

**Продолжительность**: 4:46

**Тип раздаваемого материала**: Видеоклипы

**Язык**: Английский

**Описание**: We're going to tackle some big topics in just five hours: Algorithms and Big O Analysis, Recursion, Sorting, Data Structures and Functional Programming. What? Is that even possible? We're sure as hell going to try! Since many of us are self taught and/or dropouts (myself included) we lack the advantages that a formal CS education can give. This additional theory can give us useful context to make tradeoffs in implementations and architectures.

https://btholt.github.io/four-semesters-of-cs/

Big O & Recursion

Introduction

00:00:00 - 00:06:01

Introduction

- Brian Holt begins by introducing himself and talking about why he developed this course. He also shares some recommended reading and outlines the topics he’ll be covering. The goal of this course is to provide a practical introduction to computer science concepts for those who already know JavaScript.

Big O

00:06:02 - 00:10:57

Big O

- Big O is a method for analyzing the efficiency of algorithms. In an equation, Big O may represent an exponential value since it’s the largest term in the equation. All other insignificant coefficients are ignored.

Finding Big O

00:10:58 - 00:18:42

Finding Big O

- Brian demonstrates how to calculate Big O on a few functions. When a loop is present, the Big O value is typically related to the number of iterations required by the loop or the number of nested loops. If a function simply returns a value without any iteration, the function would have a Big O value of 1 or “constant time”.

Recursion

00:18:43 - 00:22:56

Recursion

- In the context of computer science, recursion occurs when a function calls itself. Recursion is a powerful programming technique due to it’s ability to maintain state during subsequent function calls. However, problems like a stack overflow can arise if a recursive function is not implemented correctly.

Recursion Example

00:22:57 - 00:35:38

Recursion Example

- Brian walks through a few recursion examples including how to generate a Fibonacci sequence. He also stresses the beginning of any recursive function should contain the base case to prevent any stack overflow errors.

Exercise 1: Recursion

00:35:39 - 00:38:55

Exercise 1: Recursion

- In this exercise, you will make a function that computes the factorial of any number recursively. Before starting the exercise, Brian answers a few audience questions about the previous recursion example.

Exercise 1 Solution

00:38:56 - 00:42:47

Exercise 1 Solution

- Brian walks through the solution to exercise 1. He also demonstrates how to include unit testing libraries in Codepen.

Sorting Algorithms

Bubble Sort

00:42:48 - 00:49:01

Bubble Sort

- The bubble sort algorithm is typically the easiest to conceptually understand but the least efficient in execution. It continually loops through an array comparing adjacent indexes until the entire array is sorted. Brian uses a simple array of values to demonstrate the bubble sort order of execution and Big O value.

Exercise 2: Bubble Sort

00:49:02 - 00:50:59

Exercise 2: Bubble Sort

- In this exercise, you will create a bubble sort function that compares two adjacent numbers and swaps their places if the smaller indexed value is greater than the larger indexed value.

Exercise 2 Solution

00:51:00 - 00:57:53

Exercise 2 Solution

- Brian walks through the solution to exercise 2.

Insertion Sort

00:57:54 - 01:02:07

Insertion Sort

- In a worst-case-scenario, insertion sort has a similar efficiency to bubble sort. However, with data sets that are already partially sorted, insertion sort can be highly effective. It works by taking items from the unsorted portion of the list and placing them into their sorted position.

Exercise 3: Insertion Sort

01:02:08 - 01:04:56

Exercise 3: Insertion Sort

- In this exercise, you will create an insertionSort() function with two loops. The outer loop will be stepping through each item in the array. The inner loop will place the targeted item in the proper position in the sorted part of the array.

Exercise 3 Solution

01:04:57 - 01:12:58

Exercise 3 Solution

- Brian walks through the solution to exercise 3. He also shares the bigocheatsheet.com website which provides Big O best and worst-case scenarios for many algorithms.

Merge Sort

01:12:59 - 01:22:23

Merge Sort

- Merge sort is a divide-and-conquer algorithm that uses recursion to divide a list into smaller pieces for sorting. This division continues until you have a list of one. After introducing merge sort, Brian also explains the need for a stitching function and talks about merge sort’s Big O and spacial complexity.

Exercise 4: Merge Sort

01:22:24 - 01:27:44

Exercise 4: Merge Sort

- In this exercise, you will write a mergeSort() function that will take an array of numbers and return a sorted array of numbers.

Exercise 4 Solution

01:27:45 - 01:42:58

Exercise 4 Solution

- Brian walks through the solution to exercise 4. In the solution he creates a mergeSort() function and an accompanying stitch() function for combining the sorted array parts. He also briefly explains the ES6 Array spread operator.

Median Values

01:42:59 - 01:48:33

Median Values

- Brian spends a few minutes talking about some of the other ways sorting algorithms can be used. For example, to find the median value of two lists, a modified version of the stitch() function could be created to combine the lists until the medium index is reached.

Quick Sort

01:48:34 - 02:01:52

Quick Sort

- Quick sort is one of the most useful and powerful sorting algorithms. Like merge sort, quick sort uses recursion to divide-and-conquer. The last element in the list is used as the “pivot”. Everything smaller than the pivot is place in a “left” list. Larger values are placed in a “right” list. Quick sort is then performed again on the left and right lists.

Exercise 5: Quick Sort

02:01:53 - 02:02:44

Exercise 5: Quick Sort

- In this exercise, you will create a quickSort() function that will grab a pivot from the end of the list and create two lists of values that are greater than and lesser than the pivot. The function will then recursively execute on these subsequent lists until all values are sorted and concatenated back into a single list.

Exercise 5 Solution

02:02:45 - 02:11:35

Exercise 5 Solution

- Brian walks through the solution to exercise 5. He also shares a few final thoughts about the various sorting algorithms he covered throughout this section.

Data Structure Interfaces

Interfaces Data Structure

02:11:36 - 02:16:29

Interfaces Data Structure

- Brian introduces the concept of interfaces and how they behave like a black box. They provide details about how they can be used without exposing their implementation. Before moving into the first interface topic, Brian answers a few lingering audience questions about sorting algorithms.

Set Data Structure

02:16:30 - 02:19:15

Set Data Structure

- A set is a data structure than has four basic operations: Items can be added, items can be removed, a “contains" method can verify an item’s existence, and the set can return a list of it’s items.

Map Data Structure

02:19:16 - 02:26:32

Map Data Structure

- Maps, or dictionaries as they are sometimes referred to, are key-value sets. Maps are also very similar to an associative array. Since the keys in a map are a set, there cannot be any duplicates. When a value of a key is updated, the previous value is lost.

Stack Data Structure

02:26:33 - 02:30:46

Stack Data Structure

- A stack is an interface that adheres to the “last-in first-out” principle. You can only push (add) or pop(remove) from the stack. Stacks may also contain a “peek” method to view the current top value without modifying the stack.

Queue Data Structure

02:30:47 - 02:34:08

Queue Data Structure

- A queue is a “first-in first-out” data structure similar to a waiting line. Like a stack, queues have push/pop methods called enqueue and dequeue. They are useful for items that need to be handled in order or prioritize based on their need.

Implementing Data Structures

Array List

02:34:09 - 02:38:49

Array List

- Array lists are created from directly interacting with the allocated memory. They are simple in the way they are constructed. However, inserting and removing values can be costly since the entire list must be collapsed or expended to accommodate the updated value.

Exercise 6: Array List

02:38:50 - 02:42:31

Exercise 6: Array List

- In this exercise you will approximate an implementation of ArrayList. Brian begins the exercise by stubbing out the class and member functions needed in the implementation. He then gives the group time to complete the exercise.

Exercise 6 Solution

02:42:32 - 02:50:39

Exercise 6 Solution

- Brian walks through the solution to exercise 6.

Linked List

02:50:40 - 03:02:14

Linked List

- Brian spends a few minutes diagramming linked lists and comparing their specifications with array lists. Linked lists are composed of nodes which point to the next node in the list. While item retrieval is slower with a linked list, adding and removing is much faster.

Exercise 7: Linked List

03:02:15 - 03:08:37

Exercise 7: Linked List

- In this exercise, you will implement a linked list. Like the previous exercise, Brian begins by stubbing out the the two classes necessary for his implementation.

Exercise 7 Solution Part 1

03:08:38 - 03:17:49

Exercise 7 Solution Part 1

- Brian begins walking through the solution to exercise 7.

Exercise 7 Solution Part 2

03:17:50 - 03:25:45

Exercise 7 Solution Part 2

- Brian finishes the solution to exercise 7.

Binary Search Tree

03:25:46 - 03:31:57

Binary Search Tree

- Trees are useful middle ground between array lists and linked lists. Brian introduces the Binary Search Tree which is composed of nodes with 0, 1, or 2 subtrees. Elements in the left subtree are lesser than the node value. Elements in the right subtree are greater than the node value.

Exercise 8: Binary Search Tree

03:31:58 - 03:38:20

Exercise 8: Binary Search Tree

- In this exercise, you will create a binary search tree. The Tree class will keep track of a root which will be the first item added. From there, if the item is less than the value of that node, it will go into its left subtree and if greater it will go to the right subtree.

Exercise 8 Solution

03:38:21 - 03:46:52

Exercise 8 Solution

- Brian walks through the solution to exercise 8.

AVL Tree

03:46:53 - 03:52:24

AVL Tree

- AVL trees are a specialized binary search tree. When values are added to an AVL tree, a recursive call will check to see if any rebalancing is necessary. A tree is considered out of balance if the difference in height of any two subtrees is greater that one.

Single Rotation

03:52:25 - 04:02:55

Single Rotation

- Brian demonstrates how rotations are performed. They are necessary when one side of the tree is too heavy and needs rebalancing. Single rotations can take the form of either a right rotation or a left rotation.

Double Rotation

04:02:56 - 04:09:03

Double Rotation

- A double rotation is necessary when the opposite child is heavy during a rotation. For example, if the execution of a right rotation causes the left side to be heavy, a left rotation should be performed first on the child node.

Exercise 9 Solution Part 1

04:09:04 - 04:16:06

Exercise 9 Solution Part 1

- Brian begins walking through the solution to exercise 9. In this first part, he creates the Node class and implements the add() method which handles creating left and right child nodes.

Exercise 9 Solution Part 2

04:16:07 - 04:25:07

Exercise 9 Solution Part 2

- Brian finishes the solution to exercise 9. He implements the balance() method in the Node class. He also looks at the left and right rotation code.

Hash Table

04:25:08 - 04:33:53

Hash Table

- Hash tables are key-value stores used to implement maps or sets. With hash tables, the key is used as the index for where to find the value in memory. This is done by passing the key through a hashing function which converts it to an addressable space. After introducing hash tables, Brian talks through some of the code from the hash table exercise.

Functional Programming 101

Functional Programming Concepts

04:33:54 - 04:38:38

Functional Programming Concepts

- Brian explains the foundations of functional programming and talks about why using functional programming will help you create code that it’s more maintainable, composeable, and easier to reason about. He also talks about using higher order functions and how to avoid side effects.

Map Function

04:38:39 - 04:42:58

Map Function

- Map is a higher order function that has similarities to forEach. It takes a function as a parameter and applies that function individually to each element in an array. It returns a new array of the values without modifying the original list.

Reduce Function

04:42:59 - 04:47:57

Reduce Function

- The reduce function combines a list into a single meaningful value. It takes a reducer function as a parameters. Each time the reducer function is called, it is passed an accumulator, which is an the interim value, along with the current value from the list.

Filter Function

04:47:58 - 04:51:18

Filter Function

- The filter function takes a list of items and decides which items should stay in the list and which items should be removed by returning either true or false each time it is called. The result is a new list containing only the items that returned true.

Introduction

00:00:00 - 00:06:01

Introduction

- Brian Holt begins by introducing himself and talking about why he developed this course. He also shares some recommended reading and outlines the topics he’ll be covering. The goal of this course is to provide a practical introduction to computer science concepts for those who already know JavaScript.

Big O

00:06:02 - 00:10:57

Big O

- Big O is a method for analyzing the efficiency of algorithms. In an equation, Big O may represent an exponential value since it’s the largest term in the equation. All other insignificant coefficients are ignored.

Finding Big O

00:10:58 - 00:18:42

Finding Big O

- Brian demonstrates how to calculate Big O on a few functions. When a loop is present, the Big O value is typically related to the number of iterations required by the loop or the number of nested loops. If a function simply returns a value without any iteration, the function would have a Big O value of 1 or “constant time”.

Recursion

00:18:43 - 00:22:56

Recursion

- In the context of computer science, recursion occurs when a function calls itself. Recursion is a powerful programming technique due to it’s ability to maintain state during subsequent function calls. However, problems like a stack overflow can arise if a recursive function is not implemented correctly.

Recursion Example

00:22:57 - 00:35:38

Recursion Example

- Brian walks through a few recursion examples including how to generate a Fibonacci sequence. He also stresses the beginning of any recursive function should contain the base case to prevent any stack overflow errors.

Exercise 1: Recursion

00:35:39 - 00:38:55

Exercise 1: Recursion

- In this exercise, you will make a function that computes the factorial of any number recursively. Before starting the exercise, Brian answers a few audience questions about the previous recursion example.

Exercise 1 Solution

00:38:56 - 00:42:47

Exercise 1 Solution

- Brian walks through the solution to exercise 1. He also demonstrates how to include unit testing libraries in Codepen.

Sorting Algorithms

Bubble Sort

00:42:48 - 00:49:01

Bubble Sort

- The bubble sort algorithm is typically the easiest to conceptually understand but the least efficient in execution. It continually loops through an array comparing adjacent indexes until the entire array is sorted. Brian uses a simple array of values to demonstrate the bubble sort order of execution and Big O value.

Exercise 2: Bubble Sort

00:49:02 - 00:50:59

Exercise 2: Bubble Sort

- In this exercise, you will create a bubble sort function that compares two adjacent numbers and swaps their places if the smaller indexed value is greater than the larger indexed value.

Exercise 2 Solution

00:51:00 - 00:57:53

Exercise 2 Solution

- Brian walks through the solution to exercise 2.

Insertion Sort

00:57:54 - 01:02:07

Insertion Sort

- In a worst-case-scenario, insertion sort has a similar efficiency to bubble sort. However, with data sets that are already partially sorted, insertion sort can be highly effective. It works by taking items from the unsorted portion of the list and placing them into their sorted position.

Exercise 3: Insertion Sort

01:02:08 - 01:04:56

Exercise 3: Insertion Sort

- In this exercise, you will create an insertionSort() function with two loops. The outer loop will be stepping through each item in the array. The inner loop will place the targeted item in the proper position in the sorted part of the array.

Exercise 3 Solution

01:04:57 - 01:12:58

Exercise 3 Solution

- Brian walks through the solution to exercise 3. He also shares the bigocheatsheet.com website which provides Big O best and worst-case scenarios for many algorithms.

Merge Sort

01:12:59 - 01:22:23

Merge Sort

- Merge sort is a divide-and-conquer algorithm that uses recursion to divide a list into smaller pieces for sorting. This division continues until you have a list of one. After introducing merge sort, Brian also explains the need for a stitching function and talks about merge sort’s Big O and spacial complexity.

Exercise 4: Merge Sort

01:22:24 - 01:27:44

Exercise 4: Merge Sort

- In this exercise, you will write a mergeSort() function that will take an array of numbers and return a sorted array of numbers.

Exercise 4 Solution

01:27:45 - 01:42:58

Exercise 4 Solution

- Brian walks through the solution to exercise 4. In the solution he creates a mergeSort() function and an accompanying stitch() function for combining the sorted array parts. He also briefly explains the ES6 Array spread operator.

Median Values

01:42:59 - 01:48:33

Median Values

- Brian spends a few minutes talking about some of the other ways sorting algorithms can be used. For example, to find the median value of two lists, a modified version of the stitch() function could be created to combine the lists until the medium index is reached.

Quick Sort

01:48:34 - 02:01:52

Quick Sort

- Quick sort is one of the most useful and powerful sorting algorithms. Like merge sort, quick sort uses recursion to divide-and-conquer. The last element in the list is used as the “pivot”. Everything smaller than the pivot is place in a “left” list. Larger values are placed in a “right” list. Quick sort is then performed again on the left and right lists.

Exercise 5: Quick Sort

02:01:53 - 02:02:44

Exercise 5: Quick Sort

- In this exercise, you will create a quickSort() function that will grab a pivot from the end of the list and create two lists of values that are greater than and lesser than the pivot. The function will then recursively execute on these subsequent lists until all values are sorted and concatenated back into a single list.

Exercise 5 Solution

02:02:45 - 02:11:35

Exercise 5 Solution

- Brian walks through the solution to exercise 5. He also shares a few final thoughts about the various sorting algorithms he covered throughout this section.

Data Structure Interfaces

Interfaces Data Structure

02:11:36 - 02:16:29

Interfaces Data Structure

- Brian introduces the concept of interfaces and how they behave like a black box. They provide details about how they can be used without exposing their implementation. Before moving into the first interface topic, Brian answers a few lingering audience questions about sorting algorithms.

Set Data Structure

02:16:30 - 02:19:15

Set Data Structure

- A set is a data structure than has four basic operations: Items can be added, items can be removed, a “contains" method can verify an item’s existence, and the set can return a list of it’s items.

Map Data Structure

02:19:16 - 02:26:32

Map Data Structure

- Maps, or dictionaries as they are sometimes referred to, are key-value sets. Maps are also very similar to an associative array. Since the keys in a map are a set, there cannot be any duplicates. When a value of a key is updated, the previous value is lost.

Stack Data Structure

02:26:33 - 02:30:46

Stack Data Structure

- A stack is an interface that adheres to the “last-in first-out” principle. You can only push (add) or pop(remove) from the stack. Stacks may also contain a “peek” method to view the current top value without modifying the stack.

Queue Data Structure

02:30:47 - 02:34:08

Queue Data Structure

- A queue is a “first-in first-out” data structure similar to a waiting line. Like a stack, queues have push/pop methods called enqueue and dequeue. They are useful for items that need to be handled in order or prioritize based on their need.

Implementing Data Structures

Array List

02:34:09 - 02:38:49

Array List

- Array lists are created from directly interacting with the allocated memory. They are simple in the way they are constructed. However, inserting and removing values can be costly since the entire list must be collapsed or expended to accommodate the updated value.

Exercise 6: Array List

02:38:50 - 02:42:31

Exercise 6: Array List

- In this exercise you will approximate an implementation of ArrayList. Brian begins the exercise by stubbing out the class and member functions needed in the implementation. He then gives the group time to complete the exercise.

Exercise 6 Solution

02:42:32 - 02:50:39

Exercise 6 Solution

- Brian walks through the solution to exercise 6.

Linked List

02:50:40 - 03:02:14

Linked List

- Brian spends a few minutes diagramming linked lists and comparing their specifications with array lists. Linked lists are composed of nodes which point to the next node in the list. While item retrieval is slower with a linked list, adding and removing is much faster.

Exercise 7: Linked List

03:02:15 - 03:08:37

Exercise 7: Linked List

- In this exercise, you will implement a linked list. Like the previous exercise, Brian begins by stubbing out the the two classes necessary for his implementation.

Exercise 7 Solution Part 1

03:08:38 - 03:17:49

Exercise 7 Solution Part 1

- Brian begins walking through the solution to exercise 7.

Exercise 7 Solution Part 2

03:17:50 - 03:25:45

Exercise 7 Solution Part 2

- Brian finishes the solution to exercise 7.

Binary Search Tree

03:25:46 - 03:31:57

Binary Search Tree

- Trees are useful middle ground between array lists and linked lists. Brian introduces the Binary Search Tree which is composed of nodes with 0, 1, or 2 subtrees. Elements in the left subtree are lesser than the node value. Elements in the right subtree are greater than the node value.

Exercise 8: Binary Search Tree

03:31:58 - 03:38:20

Exercise 8: Binary Search Tree

- In this exercise, you will create a binary search tree. The Tree class will keep track of a root which will be the first item added. From there, if the item is less than the value of that node, it will go into its left subtree and if greater it will go to the right subtree.

Exercise 8 Solution

03:38:21 - 03:46:52

Exercise 8 Solution

- Brian walks through the solution to exercise 8.

AVL Tree

03:46:53 - 03:52:24

AVL Tree

- AVL trees are a specialized binary search tree. When values are added to an AVL tree, a recursive call will check to see if any rebalancing is necessary. A tree is considered out of balance if the difference in height of any two subtrees is greater that one.

Single Rotation

03:52:25 - 04:02:55

Single Rotation

- Brian demonstrates how rotations are performed. They are necessary when one side of the tree is too heavy and needs rebalancing. Single rotations can take the form of either a right rotation or a left rotation.

Double Rotation

04:02:56 - 04:09:03

Double Rotation

- A double rotation is necessary when the opposite child is heavy during a rotation. For example, if the execution of a right rotation causes the left side to be heavy, a left rotation should be performed first on the child node.

Exercise 9 Solution Part 1

04:09:04 - 04:16:06

Exercise 9 Solution Part 1

- Brian begins walking through the solution to exercise 9. In this first part, he creates the Node class and implements the add() method which handles creating left and right child nodes.

Exercise 9 Solution Part 2

04:16:07 - 04:25:07

Exercise 9 Solution Part 2

- Brian finishes the solution to exercise 9. He implements the balance() method in the Node class. He also looks at the left and right rotation code.

Hash Table

04:25:08 - 04:33:53

Hash Table

- Hash tables are key-value stores used to implement maps or sets. With hash tables, the key is used as the index for where to find the value in memory. This is done by passing the key through a hashing function which converts it to an addressable space. After introducing hash tables, Brian talks through some of the code from the hash table exercise.

Functional Programming 101

Functional Programming Concepts

04:33:54 - 04:38:38

Functional Programming Concepts

- Brian explains the foundations of functional programming and talks about why using functional programming will help you create code that it’s more maintainable, composeable, and easier to reason about. He also talks about using higher order functions and how to avoid side effects.

Map Function

04:38:39 - 04:42:58

Map Function

- Map is a higher order function that has similarities to forEach. It takes a function as a parameter and applies that function individually to each element in an array. It returns a new array of the values without modifying the original list.

Reduce Function

04:42:59 - 04:47:57

Reduce Function

- The reduce function combines a list into a single meaningful value. It takes a reducer function as a parameters. Each time the reducer function is called, it is passed an accumulator, which is an the interim value, along with the current value from the list.

Filter Function

04:47:58 - 04:51:18

Filter Function

- The filter function takes a list of items and decides which items should stay in the list and which items should be removed by returning either true or false each time it is called. The result is a new list containing only the items that returned true.

**Файлы примеров**: не предусмотрены

**Формат видео**: MP4

**Видео**: H264, 1280x720, 16:9, 23.98 fps, 2400 kb/s

**Аудио**: AAC, 48kHz, 160kbps, stereo