Algo 3 Flashcards

1
Q

What is the relationship between data structure and algorithm?

A

Data structures are the way to arrange data so that some kind of operations on them get facilitated. Algorithm is the way to do something with the data in the most efficient way, so as most answers here indicate - Data structures help algorithms achieve their goals in the most efficient way.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

compare the triplets

A

docs - Coding algorithms 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Leet Code Symmetric Tree

A

https://www.youtube.com/watch?v=ta0mwKYLtmQ&t=767s

WORD PROCESSED - Algorithm Practices: The Coding Interview Bootcamp on Udemy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

binary search tree

A

Binary Search Tree - Beau teaches JavaScript
* binary search tree uses the principle of binary search - on average operations are able to skip about half the tree
* runtime complexity
rewatch and learn the rest
A “binary search tree” (BST) or “ordered binary tree” is a type of binary tree where the nodes are arranged in order: for each node, all elements in its left subtree are less-or-equal to the node (<=), and all the elements in its right subtree are greater than the node (>).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Add 2 arrays together, so that first item in the new array is sum of 2 first items in the 2 arrays

A

Array.from([11, 21, 3], x=> x + x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to replace part of the string?

The following example will show you how to replace all underscore (_) character in a string with hyphen (-).

var myStr = ‘quick_brown_fox’;

A

You can use the JavaScript replace() method to replace the occurrence of any character in a string. However, the replace() will only replace the first occurrence of the specified character. To replace all the occurrence you can use the global (g) modifier.

myStr.replace(/_/g, “-“);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

.slice
.subst
.substring

A

string.slice(start,end)
string.substr(start,length)
string.substring(start,end)
Note #1: slice()==substring()

The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified. If you provide only one value it’ll return that index to end. Substring does the same.

What it does?
The slice() method extracts parts of a string and returns the extracted parts in a new string.
The substr() method extracts parts of a string, beginning at the character at the specified position, and returns the specified number of characters.
The substring() method extracts parts of a string and returns the extracted parts in a new string.
Note #2:slice()==substring()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is linear search?

A

Sometimes referred to as sequential search
An unordered list is searched for a particular value
Each value in the list is compared to the target value
Linear search implemented with a simple loop.

see graph PROCESSED - Coding Interview Algorithms 1 on word

Time taken is directly proportional to the amount of data
Linear search complexity
For n data items the time taken is equal to some constant multiplied by n.
The big time complexity is linear O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Linked list cycle

A

https://www.youtube.com/watch?v=O7C6PlovZC8&list=PL5KO4h_e6La18s6O9BLqsN_kyaZ6oI5vW&index=9

3 methods

take notes on PROCESSED - Coding algorithms 3 - word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Leetcode Valid Parentheses

A

https://www.youtube.com/watch?v=q6-Dd_9d0e4&list=PL5KO4h_e6La18s6O9BLqsN_kyaZ6oI5vW&index=8
What is a hash map?
Didn’t understand this

take notes on PROCESSED - Coding algorithms 3 - word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Leetcode flipping image

A

https://www.youtube.com/watch?v=4dgYf8ozjmQ&list=PL5KO4h_e6La18s6O9BLqsN_kyaZ6oI5vW&index=7

Matrix = nested arrays that represent your rows and columns

take notes on PROCESSED - Coding algorithms 3 - word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the big O of simple nested loop

A

n^2 or quadratic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Binary Search (Javascript)

A

https://www.youtube.com/watch?v=tkip3psTLQI&list=PL5KO4h_e6La18s6O9BLqsN_kyaZ6oI5vW&index=6
If it says array is sorted is a good hint at the solution

take notes on PROCESSED - Coding algorithms 3 - word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

JavaScript Interview Problem - Range Sum Of Binary Search Tree

A

Depth first search vs breadth first search
Bbq - use queue vs the other one uses stack or something else
https://www.youtube.com/watch?v=bnRYpOf61Pk&list=PL5KO4h_e6La18s6O9BLqsN_kyaZ6oI5vW&index=5

take notes on PROCESSED - Coding algorithms 3 - word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Lets Solve Leetcode Problems - 917 Reverse String Only

A

https://www.youtube.com/watch?v=YTaSgWyNSU0&list=PL5KO4h_e6La18s6O9BLqsN_kyaZ6oI5vW&index=4

take notes on PROCESSED - Coding algorithms 3 - word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Leetcode Problem - 53 Maximum Subarray - Kadanes Algorithm

A

https://docs.google.com/document/d/1ctw3bQWc1rDUyp2O-86FCH9RjO5C_Ebf7NHi_iC59jo/edit#

Kadanes algorithm
Dynamic programming

https://medium.com/@rsinghal757/kadanes-algorithm-dynamic-programming-how-and-why-does-it-work-3fd8849ed73d

take notes on PROCESSED - Coding algorithms 3 - word