Search Results


27 matches found for 'map'

A primer on MapReduce

... very popular higher-order functions used in functional programming. Map A map is used to apply a function on each element in some container and transform them.


Square each element of a Scala list

... case, Nil. Method 2: Mapping def squareList(xs: List[Int]): List[Int] = xs map (x => x * x) In Lists, there exists a method called map which happens to be a very handy method.


Decode number of ways

Problem A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways).


Javascript Essentials

... properties. For...of loops will iterate over all values of iterable objects (i.e. an array, a map), however this is introduced only in ES6. In general, For...of is preferred. For.


NoSQL - the Radical Databases

... but we can't say the same for these NoSQL databases. Key-value store What its like: A hash map Keys are maintained in lexicographic order, allowing efficient retrieval of key ranges \(O(1)\) time lookup and writes Hash maps are pretty basic by itself, so it relies on application code if more operations are needed The basis for more complex NoSQL stores such as document stores Examples: Memcached, Redis, DynamoDB Document store What its like: A hash map but with document objects as values (i.


Misconceptions of ASCII and Unicode

... such as Unicode came along. Myth: UTF-8 takes up only 8 bits In Unicode, each letter maps to a code point which is a theoretical concept, similar to a programming pointer.


Topological Sorting

... do topological sort via BFS, you will need two things: Adjacency Lists In-degree array (or map) The N-degree (or in-degree) array is a mapping of indices (the vertex ID) to the count of incoming graph edges.


Atomic operations with Elasticsearch

... geospatial, structured, and unstructured. Key Terms: Document - Serialized JSON data. A mapping of fields. Index - Roughly equivalent to a database table. An index just contains one or more documents.


Virtual Memory

... and freed in memory. These free spaces can't be effectively used because they are usually mapped somewhere between memory contents of two different applications, and application segments have to be stored contiguously.


Java Essentials

... allow you to declare and instantiate a class at the same time. Here is a handy example with hash maps: HashMap<String, String> hashMap = new HashMap<>(){{ put("A", "0"); put("B", "1"); }}; Lambda Functions WIP Data Structures Empty array ArrayList<T> list = new ArrayList<>(); Array with values ArrayList<Integer> list = new ArrayList<>(Arrays.


Data stores in Software Architectures

... around you, given a location (latitude, longitude) and the search radius. When we talk about the map, we talk about the real world location of where you are and the geocoordinates of your current position.


Machine Learning Basics

... Regression Classification: When a function is given some input variables, which variables map to a distinct category? i.e. If \(f(x) = ax + bx+ c\) shows us the results of the cancer scan, and \(a\) represents the amount of mercury consumption in a human, does \(a\) map to 'benign' cancer or 'malignant' cancer? Examples: Image Classification Models and Training Models are systems that maps inputs (features) to outputs (labels).


Phone Number Mnemonics in Python

... - If current digit index is out of bounds, exit - Look up digit from map (3-4 possible letters) - Add current result with each possible letter - Make another call to self for the next digit - Outside of recursive function, join the combination lists into a string and add them all to one single list, then return - Track current digit with int index - Current result could just be a list, but we need to remember to add and remove elements after the recursive call.


DNS

... a phonebook for internet addresses on the Internet. Every URL with alphanumeric characters are mapped to IP addresses, either IPv4 or IPv6. That means https://google.com is actually an address like 68.


Python Essentials

... Empty array list = [] Array with values list = [1, 2, 3] Empty hash map hashmap = {} Hash map with values hashmap = {'a': 'b'} Empty set s = set() Set with values s = set([1, 2, 3]) Min heap import heapq q = [] heapq.


Perfect Squares

... the smallest perfect square to the biggest perfect square. At each total, cache it into the hash map if it does not exist in the hash map; otherwise, read off of the cache to save some performance.


RDBMS Optimization

... Server B fails? How can you rollback? You can use consistent hashing so that a key would always map to the same server.


Apache Kafka and Event Streaming

... scales these logs across multiple machines by having partitions of logs, where one machine is mapped to one log partition. This makes Kafka a highly scalable and distributed message broker with fault tolerance and replay capabilities.


Algorithm Handbook

... behave differently. A set will store distinct keys only, but a dictionary will allow you to map values to distinct keys. In general, mutable values should not be stored as hash table keys.


Rotate a 2D Matrix

... 1)\) \(A(1, 2)\) \(\rightarrow\) \(\tilde{A}(2, 1)\) We can see that \(m\) and \(n\) is mapped a certain way into \(\tilde{A}\). \(\tilde{y}\) = \(x\) \(\tilde{x}\) = \(y_\max - y\) The solutions below were written years ago and are still applicable for Pythonistas who like Python shortcuts (such as the ~ operator) to write as little code as possible.


Build a Trie in Python

... up to 26 keys (1 for each lowercase alphabet). This can be done by creating an array or hash map. Creating a static array, with a fixed size of 26 is the most optimal choice. Each index in this array should contain another Trie object, which will contain an array of its own for its own children.


What is DDD? What is CQRS?

... particular domain model If you want each bounded context to share data to each other, use context maps. Domain Model The core of DDD Captures what is valuable or unique to the business i.


Traditional Message Queues vs. Log-based Message Brokers

... of these logs across multiple machines - otherwise known as partitions, where one machine is mapped to one log partition. This makes log-based message brokers a highly scalable and distributed message broker with fault tolerance and replay capabilities.


Design Concepts

... to DB1, F-J goes to DB2, etc. Hash-Based Partitioning Hash the key to an index, where each index maps to a specific DB. What if you add more DB hosts? Or remove existing DB hosts? The validity of the hashes will break, since the increase/decrease in host size will affect the hashing algorithm.


Local Secondary Index vs. Global Secondary Index

... is partitioned by some document ID. Each partition would now have its own secondary index that is mapped to a document ID that exists in the same partition's primary index. The Document IDs that each secondary index points to are localized in its own partition The upside of this approach is that whenever you need to update a specific document by its document ID, you only need to update one of these partitions.


RDBMS Indexing

... a index data structure, which is separate from the table itself. You could think of it as a hash map that represents the values of a field you want to index on. These values would be sorted.


Paint adjacent boundaries with distinct colors

... def recursiveBacktracking(assignment, csp): """ GOAL TEST : each country should be mapped to 1 color only, meaning they are assigned """ if all(len(assignment[country]) == 1 for country in csp): return assignment """ choose a country with MRV (Minimum-Remaining Values) """ var = selectUnassignedVariable(assignment, csp) """ choose a color from all available colors.