B-Tree in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 06:26:24

4K+ Views

Here we will see what are the B-Trees. The B-Trees are specialized m-way search tree. This can be widely used for disc access. A B-tree of order m, can have maximum m-1 keys and m children. This can store large number of elements in a single node. So the height is relatively small. This is one great advantage of B-Trees.B-Tree has all of the properties of one m-way tree. It has some other properties.Every node in B-Tree will hold maximum m childrenEvery node except root and leaves, can hold at least m/2 childrenThe root nodes must have at least two ... Read More

Change Plot Area Margins Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 11-Aug-2020 06:25:51

1K+ Views

While creating plots using ggplot2, the plot area is of square shape but we can change our plot area by setting plot.margin in theme function. This is helpful when we want to decrease the plot area and also when the data points are less.ExampleConsider the below data frame −> set.seed(1) > x y df library(ggplot2)Creating the scatterplot without changing the plot area margins −> ggplot(df,aes(x,y))+ + geom_point()> ggplot(df,aes(x,y))+ + geom_point()+ + theme(plot.margin = unit(c(1,1,1,1), "cm"))> ggplot(df,aes(x,y))+ + geom_point()+ + theme(plot.margin = unit(c(2,2,2,2), "cm"))

Merge Algorithms in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 06:24:45

784 Views

The Merge algorithm is used to merge two sorted list into one list. This algorithm is used in different cases. If we want to perform merge sort, then we need to merge the sorter lists into larger lists.The approach is simple. We take two lists, there will be two pointers. The first one will point to the element of the fist list, second one will point to the elements of the second list. Based on their values, the smaller element is taken from one of these two lists, then increase the pointer of that corresponding list. This operation will be ... Read More

Select Multiple Elements of a List in R

Nizamuddin Siddiqui
Updated on 11-Aug-2020 06:23:49

1K+ Views

Generally, a list in R contains a large number of elements and each element can be of different type which is a great thing about lists. Since we can store type of data as a list element therefore storage and selection to different type of data becomes easier. And we can also select single or multiple elements of the list at a time. This can be done with the help of single square brackets.ExampleConsider the below list −> list_data list_data [[1]] [1] "India" [[2]] [1] "China" [[3]] [1] 21 32 11 [[4]] [1] "a" "b" "c" "d" "e" [[5]] ... Read More

Binary Trees as Dictionaries in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 06:21:18

1K+ Views

When we try to implement abstract data type Dictionary, then the node associates with values. A dictionary is basically a set of keys, which must be elements drawn from a total ordering. There may be additional information, which are associated with each key, but it does not lead to any conceptual comprehension.If the dictionary is implemented using trees, then each node will hold unique keys. Here for each node u in the tree, every key is u.l is strictly smaller than u.k. And every key in u.r, is strictly larger than u.k. A tree is organized according to this invariant ... Read More

Robin Hood Hashing in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 06:20:11

434 Views

In this section we will see what is Robin-Hood Hashing scheme. This hashing is one of the technique of open addressing. This attempts to equalize the searching time of element by using the fairer collision resolution strategy. While we are trying to insert, if we want to insert element x at position xi, and there is already an element y is placed at yj = xi, then the younger of two elements must move on. So if i ≤ j, then we will try to insert x at position xi+1, xi+2 and so on. Otherwise we will store x at ... Read More

LCFS Hashing in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 06:18:32

530 Views

In this section we will see what is LCFS Hashing. This is one of the open-addressing strategy, that changes the collision resolution strategy. If we check the algorithms for the hashing in open address scheme, we can find that if two elements collide, then whose priority is higher, will be inserted into the table, and subsequent element must move on. So we can tell that the hashing in open addressing scheme is FCFS criteria.With the LCFS (Last Come First Serve) scheme. The task is performed exactly in opposite way. When we insert one element, that will be placed at position ... Read More

Asymmetric Hashing in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 06:18:11

292 Views

In this section we will see what is Asymmetric Hashing technique. In this technique, the hash table is split into d number of blocks. Each split is of length n/d. The probe value xi, 0 ≤ i ≤ d, is drawn uniformly from $$\lbrace\frac{i*n}{d}, ..., \frac{(i+1)*n}{d-1}\rbrace$$. As with multiple choice hashing, to insert x, the algorithm checks the length of the list A[x0], A[x1], . . ., A[xd – 1]. Then appends x to the shortest of these lists. If there is a tie, then it inserts x to the list with smallest index.According to Vocking, the expected length of ... Read More

Split Big Data Frame into Smaller Ones in R

Nizamuddin Siddiqui
Updated on 10-Aug-2020 15:38:43

1K+ Views

Dealing with big data frames is not an easy task therefore we might want to split that into some smaller data frames. These smaller data frames can be extracted from the big one based on some criteria such as for levels of a factor variable or with some other conditions. This can be done by using split function.ExampleConsider the below data frame −> set.seed(1) > Grades Age Category df head(df, 20) Grades Age Category 1 A 25 6 2 B 4 ... Read More

Create Polynomial Model in R

Nizamuddin Siddiqui
Updated on 10-Aug-2020 15:25:29

276 Views

Most of the times the explanatory variables are not linearly related to the response variable and we need to find the best model for our data. In this type of situations, we move on to polynomial models to check whether they will be helpful in determining the accuracy of the predictions. This can be done by using power of the independent variables in lm function.ExampleConsider the below data frame −> set.seed(99) > x1 x2 x3 x4 y df PolynomialModel1 summary(PolynomialModel1) Call: lm(formula = y ~ x1 + I(x1^2) + x2 + x3 + x4) Residuals: Min 1Q Median 3Q Max ... Read More

Advertisements