B-Trees
The goal of a B-tree is to not have to load an entire tree into memory. Only a bit by bit can be loaded in for processing. The order of a B-tree means something slightly different then with a normal tree.
The goal of a B-tree is to not have to load an entire tree into memory. Only a bit by bit can be loaded in for processing. The order of a B-tree means something slightly different then with a normal tree.
A bag is a data structure that can contain the same element multiple times which is why it is often also called a multiset. The order of adding elements is not necessarily given, this depends on the implementation. Common operations on a bag are adding elements, removing elements and searching for a specific element.
A binary tree is a tree with the order of 2. Meaning that a node is either a leaf or has left and/or right child.
Collections are containers/data structures that can hold elements of the same type. Most programming languages have some basic implementations as part of their standard library. Depending on the problem to be solved certain data structures are better options than others. In Java, there is the java.util.Collections package which contains some of the most common collections.
Kotlin's Builtin Types
Trees have nodes that hold the data and edges which connect the nodes. An empty tree obviously has no nodes and therefore no data.
The goal of graph traversal is to visit each vertex in a graph. This can be done a multitude of ways.
Motivation
Priority queue
kotlin can run anywhere where java can run as uses jvm aswell. Does have native compiler tho. statically typed and object oriented like java but can also be used for functional programming.
The Iterator interface allows you to implement a class that can be used to traverse a collection that contains elements of type E. An iterator always holds the value of the next element, apart from at the beginning of an iteration, where it holds a reference to the first element. In Java, the for-each loop uses an iterator internally. This means if you want to use a for-each loop on a collection, the collection class needs to implement the iterator interface. When implementing an iterator you often do this with an internal private final class in the collection class as you then have access to the internal structure of the collection.
Arrays vs Linked Lists
A queue is as the name says like a queue of people. Meaning it follows the FIFO policy (first in first out). The most common operations on queues are:
With JDK 14 record classes were introduced, which are a new kind of type declaration. They are especially useful for passing around immutable data containers. For example consider the immutable class below.
A set is a data structure that can hold unique elements. It represents a mathematical set which in german is called a "Menge". This means that an element is either in the set or it isn't. Just like with a bag you have the common operations of adding elements, removing elements and searching for a specific element.
Before we see how to find the shortest path from vertex $a$ to vertex $b$ we need to define a few things.
A stack is as the name says like a stack of paper. Meaning it follows the LIFO policy (last in first out). The most common operations on queues are:
There are multiple ways of storing graphs. Depending on the type of graph and the requirements a certain storage method might be preferred.
The goal of a topological sort is given a list of items with dependencies, (ie. item 5 must be completed before item 3, etc.) to produce an ordering of the items that satisfies the given constraints. In order for the problem to be solvable, there can not be a cyclic set of constraints. (We can't have that item 5 must be completed before item 3, item 3 must be completed before item 7, and item 7 must be completed before item 5, since that would be an impossible set of constraints to satisfy.) Meaning we can model this problem with a directed unweighted acyclic graph. When all the vertices are topologically ordered in a row all the edges go from left to right.