Commit 5a33f2a1 authored by Louis Maliyam's avatar Louis Maliyam
Browse files

Update README.md

parent 850b651e
# para-practice
# ForkJoin Practice
Public repo for parallel programing (ForkJoin) practice in section.
\ No newline at end of file
This project is for you to get some practice with parallel programming using ForkJoin. Clone the repo and try each exercise! We recommend going in this order:
- [LessThan7](src/main/java/LessThan7.java)
- [Parity](src/main/java/Parity.java)
- [PowMod](src/main/java/PowMod.java)
- [CountStrs](src/main/java/CountStrs.java)
- [SecondSmallest](src/main/java/SecondSmallest.java)
## LessThan7
```java
public static int lessThan7(int[] arr)
```
lessThan7 returns the number of elements in `arr` that are less than 7.
For example, if `arr` is `[21, 7, 6, 8, 17, 1]`, then `lessThan7(arr) == 2`.
Your code must have `O(n)` work, `O(lg(n))` span, where `n` is the length of `arr`.
## Parity
```java
public static boolean parity(int[] arr)
```
parity returns `true` if there are even number of even numbers and `false` otherwise.
For example, if `arr` is `[1, 7, 4, 3, 6]`, then `parity(arr) == true`. But, if `arr` is `[6, 5, 4, 3, 2, 1]`, `parity(arr) == false`.
Your code must have `O(n)` work, `O(lg(n))` span, where `n` is the length of `arr`.
## PowMod
```java
public static void powmod(int[] arr, int p, int m)
```
powMod replaces every element of `arr` with `arr[i]^p mod m`.
For example, if `arr` is `[1, 7, 4, 3, 6]`, then `powmod(arr, 2, 5)` would result in `arr = [1, 4, 1, 4, 1]`.
Your code must have `O(n)` work, `O(lg(n))` span, where `n` is the length of `arr`.
## CountStrs
```java
public static int countStrs(String str, String[] arr)
```
countStrs returns the number of elements in `arr` that equal `str`.
For example, if `arr` is `["h", "ee", "llll", "llll", "oo", "llll"]`, then `countStrs(arr, "llll") == 3` and `countStrs(arr, "h") == 1`.
Your code must have `O(n)` work, `O(lg(n))` span, where `n` is the length of `arr`.
## SecondSmallest
```java
public static int secondSmallest(int[] arr)
```
secondSmallest returns the second smallest unique element of `arr`. Assume `arr` contains at least two unique elements.
For example, if `arr` is `[1, 7, 4, 3, 6]`, then `secondSmallest(arr) == 3`. But, if `arr` is `[6, 1, 4, 3, 5, 2, 1]`, `secondSmallest(arr) == 2`.
Your code must have `O(n)` work, `O(lg(n))` span, where `n` is the length of `arr`.
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment