Java Code Examples: Prime Numbers, Array Rotation, Tree Depth
Finding Special Prime Numbers in Java
This code finds two-digit integers where the digit ‘3’ is the most frequent digit. For example, the output will be [13, 23, 31, 37, 43, 53, 73, 83].
“`java import java.util.ArrayList; import java.util.List; import java.util.Scanner;
public class SpecialPrimeFinder {
// Method to get special prime numbers private List getSpecialPrimeNo(int digits, int frequentNo) { List resLst = new ArrayList<>(); int lowerBound = (int) Math.pow(10, digits – 1); int upperBound
Read MoreData Visualization Techniques with Diamonds Dataset in R
library(tidyverse)Visualization of Distributions
Diamonds Dataset
str(diamonds)summary(diamonds)ggplot(data = diamonds) + geom_bar(mapping = aes(x = cut))diamonds %>% count(cut)ggplot(data = diamonds) + geom_histogram(mapping = aes(x = carat), binwidth = 0.5)diamonds %>% count(cut_width(carat, 0.5))
smaller <- diamonds %>% filter(carat < 3)ggplot(data = smaller, mapping = aes(x = carat)) + geom_histogram(binwidth = 0.1)ggplot(data = smaller, mapping = aes(x = carat, color = cut)) + geom_
Network Devices: Repeaters, Hubs, Routers, Switches, Bridges
Repeaters
A repeater is an electronic device that operates on the physical layer of the OSI model. An amplifier cannot differentiate between the original signal and a noise signal. Repeaters do not amplify the signal; they regenerate it. When a repeater receives a signal affected by noise, it creates a copy, bit by bit, restoring it to its original strength.
Advantages of Repeaters
- Extend the physical distance of a network.
- Do not seriously affect network performance.
Disadvantages of Repeaters
- Cannot
