BOOLEAN isConflicting(int T0, int T1) { int bucket; T0 = findPartition(T0); T1 = findPartition(T1); if (T0 == T1) return FALSE; return !!isset(tempInfo[T0]->conflicts, T1); }
vector<vector<string>> partition(string s) { //for the questions that need to get all the output, use backtracking vector<vector<string>> result; vector<string> current; findPartition(s, 0, current, result); return result; }
void insertConflict(int i, int j) { TEMP_INFO *ti, *tj; int bucket; i = findPartition(i); j = findPartition(j); if (i == j) return; if (isset(tempInfo[i]->conflicts, j)) return; ti = tempInfo[i]; tj = tempInfo[j]; if (maxAddr && ti->usedAsAddress != tj->usedAsAddress) return; if (ti->usedAsFloat != tj->usedAsFloat) return; setbit(ti->conflicts, j); setbit(tj->conflicts, i); }
void findPartition(string& s, int start, vector<string>& current, vector<vector<string>>& result) { if (start == s.size()) { result.push_back(current); return; } for (int i = start; i < s.size(); i++) { if (isPalindrome(s, start, i)) { current.push_back(s.substr(start, i - start + 1)); findPartition(s, i + 1, current, result); current.pop_back(); } } }
//********************************************************************* // FUNCTION: quickSort() // DESCRIPTION: performs a quick sort on a provided array // INPUT: // Parameters: unsortedArray[] - array that contains unsorted values // left - left edge of array // right - right edge of array // IMPLEMENTED BY: Neil Townsend //********************************************************************** void quickSort(int *unsortedArray, int left, int right) { int wall; //partition for current call of quickSort() //keeps sorting as long as there is more than one index in array if (left < right) { //finds partition wall = findPartition(unsortedArray, left, right); //left side of array recursion quickSort(unsortedArray, left, wall - 1); //right side of array recursion quickSort(unsortedArray, wall , right); } }