Sunday, December 18, 2022

List, set, queue, map in java, python, python 3, javascript and c++

What is the list, set, queue and map in java, python, python 3, c++, and javascript? How to add, update and delete a record in them? What is the big O of these operations?

List

In Java, the List interface is a part of the Java Collection Framework and extends the Collection interface. It is an ordered collection of elements and allows duplicate elements. Some common implementations of the List interface include ArrayList, LinkedList, and Vector.

Here is an example of how to create a new ArrayList in Java:

List<String> names = new ArrayList<>();

To add an element to the list, you can use the add method:

names.add("Alice"); names.add("Bob"); names.add("Charlie");

To update an element in the list, you can use the set method, which replaces the element at the specified index with the new element:

names.set(1, "Bobby"); // Replaces "Bob" with "Bobby"

To remove an element from the list, you can use the remove method, which removes the element at the specified index:

names.remove(1); // Removes "Bobby"

You can also use the remove method with an element as an argument to remove the first occurrence of the element from the list:

names.remove("Charlie"); // Removes "Charlie"

The time complexity (or "big O") of the add, set, and remove operations for an ArrayList is O(1) on average and O(n) in the worst case when the list needs to be resized. For a LinkedList, the time complexity of these operations is O(1).


In Python, a list is an ordered collection of elements that can be of different types. Lists are created using square brackets [], with the elements separated by commas. Here is an example of how to create a new list in Python:

names = ['Alice', 'Bob', 'Charlie']

To add an element to the list, you can use the append method:

names.append('Dave')

To update an element in the list, you can simply assign a new value to the element at the desired index:

names[1] = 'Bobby' # Replaces "Bob" with "Bobby"

To remove an element from the list, you can use the remove method, which removes the first occurrence of the element:

names.remove('Charlie') # Removes "Charlie"

You can also use the pop method to remove and return an element at a specific index, or the last element if no index is provided:

names.pop(1) # Removes and returns "Bobby" names.pop() # Removes and returns "Dave"

The time complexity (or "big O") of the append, remove, and pop operations for a list in Python is O(1) on average and O(n) in the worst case when the list needs to be resized.


In Python 3, a list is an ordered collection of items that can be of any data type, including other lists. Lists are implemented as arrays in Python and allow elements to be efficiently inserted, removed, and accessed by their position (index).

Here is an example of how to create a new list in Python 3:

numbers = [1, 2, 3, 4]

This creates a list of integers.

To add an element to the list, you can use the append method to add the element to the end of the list:

numbers.append(5)

You can also use the insert method to add an element at a specific position in the list:

numbers.insert(2, -1)

This will insert the element -1 at index 2, shifting the other elements to the right.

To update an element in the list, you can simply assign a new value to the element at the desired index:

numbers[2] = 0 # Updates the element at index 2 to 0

To remove an element from the list, you can use the remove method to remove the first occurrence of the element:

numbers.remove(4) # Removes the first occurrence of 4

Alternatively, you can use the pop method to remove the element at a specific index:

numbers.pop(2) # Removes the element at index 2

The time complexity (or "big O") of the append and pop operations for a list in Python 3 is O(1). The time complexity of the insert operation is O(n) because it requires shifting the elements after the insertion point to the right. The time complexity of the remove operation is O(n) because it requires searching for the element to be removed.


In C++, a list is a sequence container that allows fast insertion and deletion of elements anywhere within the list. Lists are implemented as doubly-linked lists, so elements can be efficiently added or removed from anywhere in the list.

To use lists in C++, you need to include the <list> header file and create a list object using the list template class. Here is an example of how to create a new list of integers in C++:

#include <list> std::list<int> numbers;

To add an element to the list, you can use the push_back method to add an element to the end of the list, or the push_front method to add an element to the beginning of the list:

numbers.push_back(1); numbers.push_back(2); numbers.push_front(-1);

To update an element in the list, you can use the insert method to insert a new element at a specific position, or the assign method to replace all the elements in the list with a new value:

numbers.insert(++numbers.begin(), 0); // Inserts 0 before the second element numbers.assign(3, 5); // Replaces all elements with 3 copies of the value 5

To remove an element from the list, you can use the erase method to remove an element at a specific position, or the remove method to remove all occurrences of a specific value:

numbers.erase(++numbers.begin()); // Removes the second element numbers.remove(5); // Removes all occurrences of the value 5

The time complexity (or "big O") of the push_back, push_front, insert, erase, and remove operations for a list in C++ is O(1).


In JavaScript, a list is an ordered collection of elements that can be of different types and is implemented as an array. Lists in JavaScript are created using square brackets [], with the elements separated by commas. Here is an example of how to create a new list in JavaScript:

const names = ['Alice', 'Bob', 'Charlie'];

To add an element to the list, you can use the push method to add an element to the end of the list, or the unshift method to add an element to the beginning of the list:

names.push('Dave'); names.unshift('Eve');

To update an element in the list, you can simply assign a new value to the element at the desired index:

names[1] = 'Bobby'; // Replaces "Bob" with "Bobby"

To remove an element from the list, you can use the splice method to remove an element at a specific position, or the filter method to remove all occurrences of a specific value:

names.splice(1, 1); // Removes the second element names = names.filter(name => name !== 'Charlie'); // Removes all occurrences of "Charlie"

The time complexity (or "big O") of the push, unshift, splice, and filter operations for an array in JavaScript is O(1) on average and O(n) in the worst case when the array needs to be resized.


Set


In Java, the Set interface is a part of the Java Collection Framework and extends the Collection interface. It is an unordered collection of elements that does not allow duplicate elements. Some common implementations of the Set interface include HashSet, TreeSet, and LinkedHashSet.

Here is an example of how to create a new HashSet in Java:

Set<String> names = new HashSet<>();

To add an element to the set, you can use the add method:

names.add("Alice"); names.add("Bob"); names.add("Charlie");

Since sets do not allow duplicate elements, attempting to add an element that is already in the set will have no effect.

To update an element in a set, you would first need to remove the element and then add the new element. However, this is not possible in a set, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the set, you can use the remove method:

names.remove("Charlie"); // Removes "Charlie"

The time complexity (or "big O") of the add and remove operations for a HashSet is O(1) on average and O(n) in the worst case when the set needs to be resized. For a TreeSet, the time complexity of these operations is O(log n).


In Python, a set is an unordered collection of elements that does not allow duplicate elements. Sets are created using curly braces {} or the set function, with the elements separated by commas. Here is an example of how to create a new set in Python:

names = {'Alice', 'Bob', 'Charlie'}

To add an element to the set, you can use the add method:

names.add('Dave')

Since sets do not allow duplicate elements, attempting to add an element that is already in the set will have no effect.

To update an element in a set, you would first need to remove the element and then add the new element. However, this is not possible in a set, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the set, you can use the remove method:

names.remove('Charlie') # Removes "Charlie"

If the element is not present in the set, the remove method will raise a KeyError exception. To avoid this, you can use the discard method, which removes the element if it is present in the set, but does nothing if it is not:

names.discard('Charlie') # Does nothing

The time complexity (or "big O") of the add and remove operations for a set in Python is O(1) on average and O(n) in the worst case when the set needs to be resized.


In Python 3, a set is an unordered collection of unique elements that does not allow duplicates. Sets are implemented using the set class, which was introduced in Python 2.4.

Here is an example of how to create a new set in Python 3:

s = set([1, 2, 3, 4])

This creates a set of integers.

To add an element to the set, you can use the add method:

s.add(5)

To update an element in a set, you would first need to remove the element and then add the new element. However, this is not possible in a set, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the set, you can use the remove method:

s.remove(4) # Removes the element 4

If the element is not in the set, the remove method will raise a KeyError. To remove an element from the set without raising an error, you can use the discard method:

s.discard(4) # Removes the element 4 if it is in the set

The time complexity (or "big O") of the add, remove, and discard operations for a set in Python 3 is O(1) on average and O(n) in the worst case when the set needs to be resized.


In C++, a set is an associative container that stores elements in a sorted order and does not allow duplicate elements. Sets are implemented as balanced binary search trees, so elements can be efficiently added, removed, and searched for.

To use sets in C++, you need to include the <set> header file and create a set object using the set template class. Here is an example of how to create a new set of integers in C++:

#include <set> std::set<int> numbers;

To add an element to the set, you can use the insert method:

numbers.insert(1); numbers.insert(2); numbers.insert(-1);

Since sets do not allow duplicate elements, attempting to add an element that is already in the set will have no effect.

To update an element in a set, you would first need to remove the element and then add the new element. However, this is not possible in a set, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the set, you can use the erase method:

numbers.erase(-1); // Removes -1

The time complexity (or "big O") of the insert and erase operations for a set in C++ is O(log n).


In JavaScript, a set is a collection of unique elements and is implemented as an object. Sets in JavaScript are created using the Set constructor or the new keyword, followed by an iterable object. Here is an example of how to create a new set in JavaScript:

const names = new Set(['Alice', 'Bob', 'Charlie']);

To add an element to the set, you can use the add method:

names.add('Dave');

Since sets do not allow duplicate elements, attempting to add an element that is already in the set will have no effect.

To update an element in a set, you would first need to remove the element and then add the new element. However, this is not possible in a set, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the set, you can use the delete method:

names.delete('Charlie'); // Removes "Charlie"

The time complexity (or "big O") of the add and delete operations for a set in JavaScript is O(1).In JavaScript, a set is a collection of unique elements and is implemented as an object. Sets in JavaScript are created using the Set constructor or the new keyword, followed by an iterable object. Here is an example of how to create a new set in JavaScript:

const names = new Set(['Alice', 'Bob', 'Charlie']);

To add an element to the set, you can use the add method:

names.add('Dave');

Since sets do not allow duplicate elements, attempting to add an element that is already in the set will have no effect.

To update an element in a set, you would first need to remove the element and then add the new element. However, this is not possible in a set, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the set, you can use the delete method:

names.delete('Charlie'); // Removes "Charlie"

The time complexity (or "big O") of the add and delete operations for a set in JavaScript is O(1).


Queue


In Java, a queue is a collection that allows elements to be added to the end of the queue and removed from the front of the queue. The Queue interface is a part of the Java Collection Framework and extends the Collection interface. Some common implementations of the Queue interface include LinkedList and PriorityQueue.

Here is an example of how to create a new LinkedList-based queue in Java:

Queue<String> names = new LinkedList<>();

To add an element to the queue, you can use the add or offer methods, which add the element to the end of the queue:

names.add("Alice"); names.offer("Bob");

The add method throws an IllegalStateException if the element cannot be added to the queue due to capacity restrictions, while the offer method returns a boolean indicating whether the element was successfully added.

To update an element in a queue, you would first need to remove the element and then add the new element. However, this is not possible in a queue, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the front of the queue, you can use the poll or remove methods, which remove and return the first element in the queue:

names.poll(); // Removes and returns "Alice" names.remove(); // Removes and returns "Bob"

The poll method returns null if the queue is empty, while the remove method throws a NoSuchElementException if the queue is empty.

The time complexity (or "big O") of the add, offer, poll, and remove operations for a LinkedList-based queue in Java is O(1). The time complexity of these operations for a PriorityQueue is O(log n).


In Python, a queue is a collection that stores elements in a first-in, first-out (FIFO) manner, meaning that the first element added to the queue is also the first one to be removed. Queues are often used to store data that needs to be processed in a specific order, or to store data that will be used by multiple consumers.

There are several ways to implement a queue in Python. One option is to use the Queue class from the queue module, which provides thread-safe FIFO semantics for adding and removing elements.

Here is an example of how to create a new queue in Python using the Queue class:

from queue import Queue q = Queue()

To add an element to the queue, you can use the put method:

q.put(1) q.put(2) q.put(3)

To remove an element from the queue, you can use the get method:

x = q.get() # Removes and returns the first element in the queue

It is not possible to update an element in a queue, as the elements are removed in the same order they were added and do not have specific positions or values that can be updated.

The time complexity (or "big O") of the put and get operations for a queue in Python using the Queue class is O(1).


In Python 3, a queue is a collection that allows elements to be added to the end of the queue and removed from the front of the queue. The Queue class in the queue module provides thread-safe, FIFO semantics for adding and removing elements.

Here is an example of how to create a new queue in Python:

import queue names = queue.Queue()

To add an element to the queue, you can use the put method, which adds the element to the end of the queue:

names.put('Alice') names.put('Bob')

The put method blocks if the queue is full and waits until space becomes available.

To update an element in a queue, you would first need to remove the element and then add the new element. However, this is not possible in a queue, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the front of the queue, you can use the get method, which removes and returns the first element in the queue:

names.get() # Removes and returns 'Alice' names.get() # Removes and returns 'Bob'

The get method blocks if the queue is empty and waits until an element becomes available.

The time complexity (or "big O") of the put and get operations for a queue in Python is O(1).


In C++, a queue is a container adapter that allows elements to be added to the end of the queue and removed from the front of the queue. Queues are implemented as containers adaptors, with the underlying container required to provide a specific set of functions. Some common underlying containers for queues include deque and list.

To use queues in C++, you need to include the <queue> header file and create a queue object using the queue template class. Here is an example of how to create a new queue of integers in C++:

#include <queue> std::queue<int> numbers;

To add an element to the queue, you can use the push method, which adds the element to the end of the queue:

numbers.push(1); numbers.push(2); numbers.push(-1);

To update an element in a queue, you would first need to remove the element and then add the new element. However, this is not possible in a queue, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the front of the queue, you can use the pop method, which removes the first element in the queue:

numbers.pop(); // Removes 1

The time complexity (or "big O") of the push and pop operations for a queue in C++ is O(1).


In JavaScript, a queue is a collection that allows elements to be added to the end of the queue and removed from the front of the queue. Queues in JavaScript can be implemented using an array or a linked list.

Here is an example of how to create a new queue using an array in JavaScript:

const names = [];

To add an element to the queue, you can use the push method to add the element to the end of the array:

names.push('Alice'); names.push('Bob'); names.push('Charlie');

To update an element in a queue, you would first need to remove the element and then add the new element. However, this is not possible in a queue, as there are no specific positions for the elements and they do not have a specific value that can be updated.

To remove an element from the front of the queue, you can use the shift method to remove the first element in the array:

names.shift(); // Removes 'Alice'

The time complexity (or "big O") of the push and shift operations for a queue implemented as an array in JavaScript is O(1).

Alternatively, you can implement a queue using a linked list in JavaScript. To do this, you can create a Queue class with a head and a tail property, and methods for adding and removing elements from the queue.


Map


In Java, a map is a collection that stores key-value pairs and allows elements to be efficiently retrieved, added, and removed based on their key. Maps in Java are implemented using the Map interface, which is part of the Java Collections Framework. There are several implementations of the Map interface, including HashMap, TreeMap, and LinkedHashMap.

Here is an example of how to create a new map in Java using the HashMap implementation:

Map<String, Integer> ages = new HashMap<>();

This creates a map that maps strings (the keys) to integers (the values).

To add an element to the map, you can use the put method:

ages.put("Alice", 30); ages.put("Bob", 35); ages.put("Charlie", 25);

To update an element in the map, you can use the put method again with the same key and the new value:

ages.put("Alice", 31); // Updates Alice's age to 31

To remove an element from the map, you can use the remove method:

ages.remove("Charlie"); // Removes "Charlie"

The time complexity (or "big O") of the put, get, and remove operations for a HashMap in Java is O(1) on average and O(n) in the worst case when the map needs to be resized. The time complexity of the put, get, and remove operations for a TreeMap in Java is O(log n).


In Python, a map is a collection that stores key-value pairs and allows elements to be efficiently retrieved, added, and removed based on their key. Maps in Python are implemented using dictionaries, which are unordered collections of key-value pairs.

Here is an example of how to create a new dictionary in Python:

ages = {'Alice': 30, 'Bob': 35, 'Charlie': 25}

This creates a dictionary that maps strings (the keys) to integers (the values).

To add an element to the dictionary, you can use the assignment operator = to set the value for a new key:

ages['Dave'] = 40

To update an element in the dictionary, you can use the assignment operator = with an existing key:

ages['Alice'] = 31 # Updates Alice's age to 31

To remove an element from the dictionary, you can use the del statement:

del ages['Charlie'] # Removes "Charlie"

The time complexity (or "big O") of the get, set, and del operations for a dictionary in Python is O(1) on average and O(n) in the worst case when the dictionary needs to be resized.In Python, a map is a collection that stores key-value pairs and allows elements to be efficiently retrieved, added, and removed based on their key. Maps in Python are implemented using dictionaries, which are unordered collections of key-value pairs.

Here is an example of how to create a new dictionary in Python:

ages = {'Alice': 30, 'Bob': 35, 'Charlie': 25}

This creates a dictionary that maps strings (the keys) to integers (the values).

To add an element to the dictionary, you can use the assignment operator = to set the value for a new key:

ages['Dave'] = 40

To update an element in the dictionary, you can use the assignment operator = with an existing key:

ages['Alice'] = 31 # Updates Alice's age to 31

To remove an element from the dictionary, you can use the del statement:

del ages['Charlie'] # Removes "Charlie"

The time complexity (or "big O") of the get, set, and del operations for a dictionary in Python is O(1) on average and O(n) in the worst case when the dictionary needs to be resized.


In Python 3, a map is a collection that stores key-value pairs and allows elements to be efficiently retrieved, added, and removed based on their key. Maps in Python are implemented using dictionaries, which are unordered collections of key-value pairs.

Here is an example of how to create a new dictionary in Python 3:

ages = {'Alice': 30, 'Bob': 35, 'Charlie': 25}

This creates a dictionary that maps strings (the keys) to integers (the values).

To add an element to the dictionary, you can use the assignment operator = to set the value for a new key:

ages['Dave'] = 40

To update an element in the dictionary, you can use the assignment operator = with an existing key:

ages['Alice'] = 31 # Updates Alice's age to 31

To remove an element from the dictionary, you can use the del statement:

del ages['Charlie'] # Removes "Charlie"

The time complexity (or "big O") of the get, set, and del operations for a dictionary in Python 3 is O(1) on average and O(n) in the worst case when the dictionary needs to be resized.


In C++, a map is an associative container that stores elements in a sorted order, with keys mapped to values. Maps are implemented as associative containers, with the underlying container required to provide a specific set of functions. Some common underlying containers for maps include vector and list.

To use maps in C++, you need to include the <map> header file and create a map object using the map template class. Here is an example of how to create a new map in C++:

#include <map> std::map<std::string, int> ages;

This creates a map that maps strings (the keys) to integers (the values).

To add an element to the map, you can use the insert method, which adds the key-value pair to the map:

ages.insert(std::pair<std::string, int>("Alice", 30)); ages.insert(std::pair<std::string, int>("Bob", 35)); ages.insert(std::pair<std::string, int>("Charlie", 25));

Alternatively, you can use the [] operator to add an element to the map:

ages["Dave"] = 40;

To update an element in the map, you can use the [] operator with an existing key:

ages["Alice"] = 31; // Updates Alice's age to 31

To remove an element from the map, you can use the erase method:

ages.erase("Charlie"); // Removes "Charlie"

The time complexity (or "big O") of the insert, get, and erase operations for a map in C++ is O(log n).


In JavaScript, a map is a collection that stores key-value pairs and allows elements to be efficiently retrieved, added, and removed based on their key. Maps in JavaScript are implemented using the Map class, which was introduced in ECMAScript 6 (ES6).

Here is an example of how to create a new map in JavaScript:

const ages = new Map();

To add an element to the map, you can use the set method, which adds the key-value pair to the map:

ages.set('Alice', 30); ages.set('Bob', 35); ages.set('Charlie', 25);

To update an element in the map, you can use the set method again with the same key and the new value:

ages.set('Alice', 31); // Updates Alice's age to 31

To remove an element from the map, you can use the delete method:

ages.delete('Charlie'); // Removes "Charlie"

The time complexity (or "big O") of the set, get, and delete operations for a map in JavaScript is O(1).

From black friday toys




With magnetic beads and rods, the whole world's symmetry is under the children's finger tips.


Magnetic beads model the structure of metal, collection of beads are flexible, fluid, like metal. Beads hit each other, spread movement (heat) to each other, like metal. We can mix two different sized beads to get the model of copper and iron alloy.


The rod and beads model crystals. We notice the 3 edge, 4 edge, 5 edge and 6 edge space structure ends there. 


If we ask "(AI) expert" how many shapes we can build with rod and beads.


There are 230 different space groups that are recognized in crystallography. A space group is a set of symmetry operations that includes all of the symmetry operations of a crystal lattice. The specific symmetry operations that make up a space group depend on the symmetry of the crystal lattice it describes. The 230 space groups are organized into 32 crystal classes, which are groups of space groups that have the same symmetries. The crystal classes are further organized into seven crystal systems, which are groups of crystal classes that have the same basic symmetries. The seven crystal systems are the triclinic, monoclinic, orthorhombic, tetragonal, hexagonal, rhombohedral, and cubic systems.

The 230 space groups recognized in crystallography are not all distinct groups with unique symmetries. Some of the space groups are derived from one another by applying certain symmetry operations, such as translations or screw axes. These derived space groups can have the same symmetries as the original group, but they are considered to be different space groups because they have different sets of symmetry operations.


For example, consider the space group P4/mbm, which has a fourfold rotational symmetry (P4), a glide plane perpendicular to the fourfold axis (m), and a mirror plane perpendicular to the glide plane (bm). This space group can be derived from the space group P4/mmm by applying a screw axis along the direction of the glide plane. The resulting space group, P4/mbm, has the same symmetries as P4/mmm, but it is considered to be a different space group because it has a different set of symmetry operations. In this way, two different space groups can have the same symmetries and still be considered distinct groups.


The 32 crystal classes are groups of space groups that have the same symmetries. Each crystal class is represented by a symbol that describes its symmetries. The symbols for the 32 crystal classes are as follows:


  1. Triclinic crystal system group: P1
  2. Monoclinic crystal system group: C2, Cs, C2h
  3. Orthorhombic crystal system group: D2, D2h, C2v, C2h, D2d
  4. Tetragonal crystal system group: C4, C4h, S4, C4v
  5. Rhombohedral crystal system group: C3, C3i
  6. Hexagonal crystal system group: C6, C6h, D6
  7. Cubic crystal system group: T, Th, Td, O, Oh


These are the symbols used to represent the 32 crystal classes in crystallography. The specific symbol used to represent a crystal class depends on the symmetries of the class. For example, the crystal class C4 represents a tetragonal crystal lattice with a fourfold rotational symmetry about an axis passing through the center of the lattice. The symbol C4h represents a tetragonal crystal lattice with a fourfold rotational symmetry about an axis passing through the center of the lattice and a horizontal mirror plane perpendicular to the fourfold axis.


the list of symbols includes 23 different symbols, not 32. The 32 crystal classes are represented by a combination of these 23 symbols, as well as other symbols not listed above. For example, the symbol D2 is used to represent two different crystal classes: the orthorhombic class D2, and the hexagonal class D6. The symbol C4 is also used to represent two different crystal classes: the tetragonal class C4, and the cubic class T. In this way, the 23 symbols can be combined to represent the 32 different crystal classes.


Notice the above are are just some examples of the symbols used to represent the seven crystal system groups.


The seven crystal system groups are based on the type of symmetry and the number of axes of symmetry in the crystal lattices belonging to each group. These seven groups were chosen because they represent the seven possible combinations of symmetry and the number of axes of symmetry that can occur in a crystal lattice. They provide a comprehensive classification of the symmetries that can occur in a crystal lattice, and they allow for a systematic study of the properties of crystal lattices and their symmetry operations.



In two-dimensional (2D) space, there are 17 space groups, which are groups of symmetry operations that include all of the symmetry operations of a crystal lattice in 2D space. The 17 space groups in 2D space are organized into the three crystal system groups I mentioned earlier: monogonal, orthogonal, and circular. The specific symbols used to represent each space group depend on the type of symmetry and the number of axes of symmetry in the crystal lattices belonging to the group. Some examples of the symbols used to represent the 17 space groups in 2D space are as follows:

  1. Monogonal crystal system group: Pm, Pmn, Pmc
  2. Orthogonal crystal system group: Pmm, Pmc, Pm2, Pm3
  3. Circular crystal system group: P4, P4m, P4g

These are just some examples of the symbols used to represent the 17 space groups in 2D space. The specific symbols used to represent a given space group can vary depending on the properties of the crystal lattices belonging to the group.


In one-dimensional (1D) space, there is only one crystal system group, which is the linear crystal system group. This group includes crystal classes with one axis of symmetry, which is the only type of symmetry that can occur in a crystal lattice in 1D space.

The specific symmetries and symmetry operations of the crystal classes in the linear crystal system group in 1D space can be represented using different symbols, depending on the properties of the crystal lattices being considered. For example, the symbol P1 can be used to represent a crystal class with no symmetry, while the symbol C1 can be used to represent a crystal class with a single mirror plane.

In addition, there are only two space groups in 1D space, which are groups of symmetry operations that include all of the symmetry operations of a crystal lattice in 1D space. These two space groups are the P1 space group, which includes all of the symmetry operations of a crystal lattice with no symmetry, and the C1 space group, which includes all of the symmetry operations of a crystal lattice with a single mirror plane. These two space groups are the counterparts of the 17 space groups in 2D space and the 230 space groups in 3D space.

SQL, NOSQL and CAP theorem

Relational database


A SQL (Structured Query Language) database, also known as a relational database, is a type of database management system (DBMS) that is designed to store and manage structured data using a relational model. In a relational database, data is organized into tables, with each table consisting of rows (also known as records or tuples) and columns (also known as attributes or fields). Tables can be related to each other using foreign keys, which allow data from multiple tables to be linked and queried together.

SQL databases are characterized by their use of a structured query language (SQL) for defining and manipulating the data in the database. SQL is a standardized language that is used to create, modify, and query the data in a SQL database.

SQL databases are widely used in a variety of applications, including business applications, financial systems, and web-based applications. They are known for their support for transactions, which allow multiple updates to be made to the database as a single unit of work, and their ability to enforce data integrity constraints.

Some popular SQL databases include MySQL, Oracle, Microsoft SQL Server, and PostgreSQL.


Popular distributed systems for relational database

There are several popular distributed systems for relational databases:

  1. MySQL Cluster: MySQL Cluster is a distributed database management system designed to provide high availability and real-time performance for web, cloud, and telecommunications applications. It uses a shared-nothing architecture and utilizes synchronous replication to ensure data consistency and high availability.
  2. Oracle RAC: Oracle Real Application Clusters (RAC) is a distributed database system that enables multiple instances of Oracle to run concurrently on different servers, sharing a single database. RAC uses a shared-disk architecture and supports both synchronous and asynchronous replication.
  3. Microsoft SQL Server Always On: Microsoft SQL Server Always On is a high availability and disaster recovery solution that provides multiple copies of a database on different servers. It uses synchronous replication to ensure data consistency and supports both active-passive and active-active configurations.
  4. PostgreSQL BDR: PostgreSQL BDR (Bi-Directional Replication) is a set of extensions to PostgreSQL that enables multi-master replication between PostgreSQL databases. BDR uses logical decoding and triggers to replicate data and supports both synchronous and asynchronous replication.

These are just a few examples of distributed systems for relational databases. There are many other options available, each with their own unique features and capabilities.



There are several popular cloud-based distributed systems for relational databases:

  1. Amazon Aurora: Amazon Aurora is a fully managed, MySQL and PostgreSQL-compatible, relational database engine that is designed to be highly available, scalable, and fault-tolerant. It uses a distributed, shared-nothing architecture and automatically replicates data across multiple availability zones to ensure high availability.
  2. Google Cloud Spanner: Google Cloud Spanner is a fully managed, horizontally scalable, distributed database that is designed to be highly available and consistent. It uses a shared-nothing architecture and uses a combination of Paxos-based replication and lock server architecture to ensure data consistency and high availability.
  3. Azure SQL Database: Azure SQL Database is a fully managed, cloud-based, relational database service that is designed to be highly available and scalable. It supports both active-passive and active-active configurations and uses a combination of synchronous and asynchronous replication to ensure data consistency.
  4. Oracle Cloud Infrastructure Database: Oracle Cloud Infrastructure Database is a fully managed, cloud-based, relational database service that is designed to be highly available, scalable, and secure. It supports both Oracle RAC and Oracle Database In-Memory and uses synchronous replication to ensure data consistency.

These are just a few examples of cloud-based distributed systems for relational databases. There are many other options available, each with their own unique features and capabilities.


Nosql database

NoSQL databases (short for "not only SQL") are a category of databases that are designed to handle large volumes of data that is distributed across a wide number of servers. They are typically used in situations where traditional relational databases may not be suitable, such as when dealing with very large datasets, high levels of data volatility, or complex relationships between data elements.

NoSQL databases are characterized by their ability to handle unstructured or semi-structured data, their horizontal scalability, and their use of distributed architectures. They offer a variety of data models, including key-value stores, document databases, column-family databases, and graph databases.

Some popular NoSQL databases include MongoDB, Cassandra, Redis, and Couchbase.

NoSQL databases are often used in big data and real-time web applications, as well as for storing large amounts of unstructured data, such as log files and social media data. They are also sometimes used as a data store for microservices architectures.

Some NoSQL databases do support the ability to perform joins, although the way in which joins are implemented can vary depending on the specific database and data model being used.

For example, some document databases, such as MongoDB, support the use of embedded documents and arrays to store related data in a single document, which can then be queried using the database's aggregation framework. This can provide a way to perform "joins" between documents in a way that is similar to how joins are performed in a relational database.

Other NoSQL databases, such as Cassandra, do not support traditional SQL-style joins, but do provide other ways to perform related data queries, such as using denormalized data models or materialized views.

It's important to note that the way in which NoSQL databases handle related data can be quite different from how relational databases do it, and as such, the concept of a "join" may not be directly applicable in all cases.


There are several popular NoSQL databases:

  1. MongoDB: MongoDB is a document-oriented database that uses JSON-like documents to store data. It is designed to be scalable, flexible, and easy to use.
  2. Cassandra: Cassandra is a distributed database that is designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure.
  3. Redis: Redis is an in-memory data structure store that is often used as a database, cache, and message broker. It is known for its high performance and versatility.
  4. Couchbase: Couchbase is a document-oriented database that is designed to be scalable, flexible, and easy to use. It offers support for multiple data models, including key-value, document, and graph.
  5. DynamoDB: DynamoDB is a fully managed, cloud-based NoSQL database service that is designed to be scalable, highly available, and flexible. It offers a variety of data models, including key-value and document.

These are just a few examples of popular NoSQL databases. There are many other options available, each with their own unique features and capabilities.



Deciding whether to use a SQL or a NoSQL database depends on the specific needs of your application. Here are some general guidelines for when each type of database might be more suitable:

  • Use a SQL database when:
    • You need to store structured data with a well-defined schema
    • You need to support transactions and ACID (atomicity, consistency, isolation, durability) guarantees
    • You need to perform complex queries using SQL
    • You need to enforce referential integrity using foreign keys
  • Use a NoSQL database when:
    • You need to store large volumes of data that does not have a fixed schema
    • You need to scale horizontally to support large numbers of concurrent users or high levels of data ingestion
    • You need to support flexible and agile development by allowing changes to the data model without requiring schema updates
    • You need to work with unstructured or semi-structured data, such as log files or social media data

It's worth noting that SQL and NoSQL databases are not mutually exclusive, and it's often possible to use a combination of both in a single application. For example, you might use a SQL database for storing structured data and a NoSQL database for storing large volumes of unstructured data. The choice of database should be based on the needs of the application and the data it needs to store and manage.


CAP theorem

In mathematics, the cap theorem, also known as Brewer's theorem, states that it is impossible for a distributed computer system to simultaneously provide more than two of the following three guarantees:

  1. Consistency: Every read receives the most recent write or an error
  2. Availability: Every request receives a response, without guarantee that it contains the most recent write
  3. Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes

The theorem states that a distributed system can satisfy any two of these guarantees at the same time, but not all three. This means that in a distributed system, it is impossible to achieve strong consistency (guaranteeing that every read receives the most recent write) and availability (guaranteeing that every request receives a response) while also being able to tolerate network partitions (meaning that the system can continue to operate even when some nodes are disconnected).

The cap theorem has important implications for the design of distributed systems, as it means that trade-offs must be made between consistency, availability, and partition tolerance.


Here are some popular SQL databases, grouped by the type of consistency, availability, and partition tolerance (CAP) guarantees they provide:

  • Strong consistency and high availability:
    • Amazon RDS (cloud)
    • Google Cloud SQL (cloud)
    • Microsoft SQL Server (non-cloud)
    • Oracle Database (non-cloud)
    • PostgreSQL (non-cloud)
  • High availability and partition tolerance:
    • Amazon Aurora (cloud)
    • Google Cloud Spanner (cloud)
    • Microsoft SQL Server Always On (non-cloud)
    • Oracle Real Application Clusters (RAC) (non-cloud)
    • PostgreSQL BDR (non-cloud)
  • Strong consistency and partition tolerance:
    • Amazon RDS (cloud)
    • Google Cloud SQL (cloud)
    • Microsoft SQL Server (non-cloud)
    • Oracle Database (non-cloud)
    • PostgreSQL (non-cloud)

It's worth noting that the CAP theorem is a general guideline, and the specific CAP guarantees provided by each database may vary depending on the specific configuration and usage patterns. Some SQL databases, such as Microsoft SQL Server and Oracle Database, offer tunable consistency options that allow users to choose the level of consistency they need for their application.


Here are some popular NoSQL databases, grouped by the type of consistency, availability, and partition tolerance (CAP) guarantees they provide:

  • Strong consistency and high availability:
    • Amazon DynamoDB (cloud)
    • Google Cloud Bigtable (cloud)
    • Azure Cosmos DB (cloud)
    • MongoDB (non-cloud)
    • Couchbase (non-cloud)
  • High availability and partition tolerance:
    • Amazon Cassandra (cloud)
    • Google Cloud Bigtable (cloud)
    • Azure Cosmos DB (cloud)
    • Cassandra (non-cloud)
  • Strong consistency and partition tolerance:
    • Amazon Neptune (cloud)
    • Google Cloud Bigtable (cloud)
    • Azure Cosmos DB (cloud)
    • Redis (non-cloud)

It's worth noting that the CAP theorem is a general guideline, and the specific CAP guarantees provided by each database may vary depending on the specific configuration and usage patterns. Some NoSQL databases, such as Azure Cosmos DB, offer tunable consistency options that allow users to choose the level of consistency they need for their application.







MarketAxess

MarketAxess: The Leader in e-Trading for Global Fixed Income MarketAxess Holdings Inc. (MarketAxess) is an international financial technol...