Main Flashcards
(48 cards)
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)