Skip to content

Instantly share code, notes, and snippets.

View allen1881996's full-sized avatar

Allen Huang allen1881996

  • University of Florida
  • Gainesville
View GitHub Profile
@allen1881996
allen1881996 / QuickSelect.java
Created March 24, 2020 04:01
Randomized QuickSelect
public class QuickSelect {
public int quickSelect(int[] arr, int k) {
return quickSelect(arr, k, 0, arr.length - 1);
}
private int quickSelect(int[] arr, int k, int start, int end){
if (k > arr.length) throw new IllegalArgumentException();
if (arr.length == 0 || arr == null) return Integer.MIN_VALUE;
var pivotIndex = randomlySelect(arr);
@allen1881996
allen1881996 / DeterministicSelect.java
Created March 25, 2020 00:45
Deterministic Select Algorithm
package com.allenhuang;
import java.util.ArrayList;
import java.util.Arrays;
public class DeterministicSelect {
// store the median of each group
private ArrayList<Integer> medians = new ArrayList<>();
public int select(int[] arr, int k) {
@allen1881996
allen1881996 / GraphWithTwoHashMap.java
Created April 1, 2020 02:52
Create a graph using two HashMaps.
package com.allenhuang;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Graph {
private Map<String, Node> nodes = new HashMap<>();
private Map<Node, List<Node>> adjacencyList = new HashMap<>();
@allen1881996
allen1881996 / Graph.java
Created April 1, 2020 03:59
Create a graph using LinkedList, HashMap and Array.
package com.allenhuang;
import java.util.*;
public class Graph2 {
private Map<Node,Integer> map = new HashMap();
private List<LinkedList<Node>> adjacencyList = new ArrayList();
private int index = 0;
private class Node {
@allen1881996
allen1881996 / DirectedGraphAlgorithm.java
Created April 2, 2020 00:50
Directed Graph Algorithm: BFT, DFT, Topology Sort, Cycle Detection.
package com.allenhuang;
import java.util.*;
public class Graph {
private Map<String, Node> nodes = new HashMap<>();
private Map<Node, List<Node>> adjacencyList = new HashMap<>();
private class Node {
private String label;
@allen1881996
allen1881996 / WeightedGraph1.java
Created April 2, 2020 19:56
Create a Undirected, Weighted Graph using two HashMaps.
package com.allenhuang;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class WeightedGraph {
private Map<String, Node> nodes = new HashMap<>();
private Map<Node, List<Edge>> adjacencyList = new HashMap<>();
text = []
like = []
date = []
reply_to = []
text = []
name = []
def is_break_point(astring:str):
if 'React' in astring:
return True
def main():
df['polarity'] = df['text_prep'].parallel_apply(lambda x: round(TextBlob(x).polarity,3))
df['subjectivity'] = df['text_prep'].parallel_apply(lambda x: round(TextBlob(x).subjectivity,3))
df = subjectivity_labeling(df)
df = polarity_labeling(df)
# labeling subjectivity
def subjectivity_labeling(df,threshold=0.5):
if threshold == 0.5:
df.loc[df.subjectivity > 0.5,"subjectivity_label"] = 'subjective'