Main Flashcards
Frequency Counter
Uses objects or sets to compare values or frequency of values. (Ex: Check if two strings are anagrams of one another.)
The difference between justify-content: space-between and justify-content: space-around
space-between aligns items with an even space between them while space-around does the same thing, but with a half space added on each end
The difference between justify-content and align-items
justify-content aligns items on the horizontal axis and align items on the cross (vertical) axis
How does flex-direction column affect justify-content and align-item?
Flex-direction: column causes justify-content to align items vertically and align-items to align items horizontally. (Opposite of their normal behavior)
The difference between align-items and align-content
align-content determines the spacing between lines, while align-items determines how the items as a whole are aligned within the container.
Server Side Rendering
Server-side rendering (SSR) is an application’s ability to convert HTML files on the server into a fully rendered HTML page for the client. The web browser submits a request for information from the server, which instantly responds by sending a fully rendered page to the client.
Client Side Rendering
With a client-side rendering solution, you redirect the request to a single HTML file and the server will deliver it without any content (or with a loading screen) until you fetch all the JavaScript and let the browser compile everything before rendering the content.
Linear Search
Searches through a set of data (i.e. an array) one element at a time.
Time Complexity O(n).
Binary Search
Searches through an ordered data set (i.e. an array of numbers in ascending order) by finding a midpoint between the start and end of a data set, then removing half the set on each iteration. (I.e. if looking for a number and array[midpoint] is greater than that value, move the start to midpoint and find a new midpoint, effectively removing the first half of the array from the search).
Time Complexity: O(log n)
Bubble Sort
A sorting algorithm where the largest values “bubble up” to the top. (i.e. end of the array). Iterates through array and checks each two value pair to see which is greater, then swaps them if necessary. Can be optimized by tracking swaps and breaking loop if no swaps are made during an iteration.
Time Complexity: O(n^2), unless optimized and array is nearly sorted, in which case it’s O(n)
Selection Sort
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.
1) The subarray which is already sorted.
2) Remaining subarray which is unsorted.
Time Complexity: O(n^2)
Insertion Sort
Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands. The array is virtually split into a sorted and an unsorted part. Values from the unsorted part are picked and placed at the correct position in the sorted part.
Time Complexity: O(n^2), but can be more like O(n) if array is nearly sorted
Merge Sort
A sorting algorithm that uses a divide & conquer strategy to recursively halve an array into 1 or 0 element long arrays, then merges each each half (series of halves) back into a sorted array
Time Complexity: O(n log n), Space Complexity: O(n)
Asymptote
A line that continually approaches a given curve but does not meet it at any finite distance.
Tree
In computer science, a tree is a widely used abstract data type that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.
Binary Tree
A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right child.
Binary Search Tree
Binary Search Tree is a node-based binary tree data structure which has the following properties:
The left subtree of a node contains only nodes with keys lesser than the node’s key.
The right subtree of a node contains only nodes with keys greater than the node’s key.
The left and right subtree each must also be a binary search tree.
Stack
Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
Queue
A Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO). A good example of a queue is any queue of consumers for a resource where the consumer that came first is served first.
Stack vs Queue
The difference between stacks and queues is in removing. In a stack we remove the item the most recently added; in a queue, we remove the item the least recently added.
Breadth First Search
Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next depth level. Extra memory, usually a queue, is needed to keep track of the child nodes that were encountered but not yet explored.
Depth First Search
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking.
Binary Heap
A Binary Heap is a Binary Tree with following properties.
1) It’s a complete tree (All levels are completely filled except possibly the last level and the last level has all keys as left as possible). This property of Binary Heap makes them suitable to be stored in an array.
2) A Binary Heap is either Min Heap or Max Heap. In a Min Binary Heap, the key at root must be minimum among all keys present in Binary Heap. The same property must be recursively true for all nodes in Binary Tree. Max Binary Heap is similar to MinHeap.
Hash Table
Hashing is a technique or process of mapping keys, values into the hash table by using a hash function. It is done for faster access to elements. The efficiency of mapping depends on the efficiency of the hash function used.
On average:
Insertion: O(1)
Deletion: O(1)
Access: O(1)
Separate Chaining
Method for handling collisions in a hash table. Each element of hash table stores another nested data structure, such as an array or linked list.
Linear Probing
Method for handling collisions in a hash table. When a collision occurs, the colliding element is placed in the next empty slot. (Can look forwards or backwards). Max one element per slot.
Graph
A collection of vertices (nodes) and connections (edges)
Vertex
Node in a graph
Edge
Connection between vertices in a graph
Undirected Graph vs Directed Graph
All edges in an undirected graph go both ways. In a directed graph, some edges may go both ways, while others go only one way. Edges are assigned specific directions.
Weighted Graph
A graph where edges are assigned values.
Adjacency Matrix vs Adjacency List
An adjacency matrix stores every possible edge between vertices and whether that edge exists or does not. An adjacency list stores only the existing edges for each vertex. AM takes more space and is slow to iterate over, but is fast for finding specific edges. AL takes less space and is faster to iterate over, but is slower for finding specific edges.
Open-Closed Principled
In object-oriented programming, the open–closed principle states “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification”
Encapsulation
Encapsulation is one of the fundamentals of OOP (object-oriented programming). It refers to the bundling of data with the methods that operate on that data. Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties’ direct access to them. Publicly accessible methods are generally provided in the class (so-called getters and setters) to access the values, and other client classes call these methods to retrieve and modify the values within the object.[1]
Abstraction
Abstraction is the concept of object-oriented programming that “shows” only essential attributes and “hides” unnecessary information. The main purpose of abstraction is hiding the unnecessary details from the users.
Inheritance
Inheritance is one of the core concepts of object-oriented programming (OOP) languages. It is a mechanism where you can to derive a class from another class for a hierarchy of classes that share a set of attributes and methods.
Polymorphism
Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.
The beauty of polymorphism is that the code working with the different classes does not need to know which class it is using since they’re all used the same way. A real world analogy for polymorphism is a button. Everyone knows how to use a button: you simply apply pressure to it. What a button “does,” however, depends on what it is connected to and the context in which it is used — but the result does not affect how it is used. If your boss tells you to press a button, you already have all the information needed to perform the task.
In the programming world, polymorphism is used to make applications more modular and extensible. Instead of messy conditional statements describing different courses of action, you create interchangeable objects that you select based on your needs. That is the basic goal of polymorphism.
Factory Function vs Constructor Function
A constructor returns an instance of the class you call it on. A factory function can return anything. You would use a factory function when you need to return arbitrary values or when a class has a large setup process.
https://bit.ly/34KE9Ys
new operator
the new operator in JavaScript is used to create new object instances. It binds the ‘this’ of the new object to itself.
call()
The call() method calls a function with a given this value and arguments provided individually.
bind()
The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.
apply()
The apply() method calls a function with a given this value, and arguments provided as an array (or an array-like object).
Primitives
number string boolean undefined null symbol
Reference Values
anything that is “typeof” “object”
objects
arrays
functions
Primitives vs Reference Values
Primitives store an individual value. References store a reference to a place in memory.
let x = 10; let y = x; x = 20; console.log(y); // 10
let x = { value: 10 }; let y = x; x.value = 20; console.log(y); // { value: 20 }
Scope vs Closure
When you declare a variable in a function, you can only access it in the function. These variables are said to be scoped to the function.
If you define any inner function within another function, this inner function is called a closure. It retains access to the variables created in the outer function.
Function vs Method
Function is a set of logic that can be used to manipulate data. While, Method is function that is used to manipulate the data of the object where it belongs.
Constructor Pattern
A class-based pattern that uses the constructors present in the class to create specific types of objects.
https://www.educative.io/collection/page/5429798910296064/5725579815944192/5920633608208384