This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//THIS CLASS USES A BINARY SEARCH TREE TO IMPLEMENT A DICTIONARY | |
//THIS CLASS MUST IMPLEMENT THE FOLLOWING METHODS | |
//ADD(K KEY, V VALUE) - INSERTS THE SPECIFIED KEY-VALUE PAIR INTO THE DICTIONARY, SHOULD REPLACE THE KEYS VALUE IT KEY ALREADY EXISTS | |
//GETVALUE(K KEY) - RETURNS THE VALUE ASSOCIATED WITH THE SPECIFIED KEY | |
//CONTAINS(K KEY) - RETURNS WHETHER THE SPECIFIED KEY EXISTS IN THE DICTIONARY | |
//ITERATOR() - RETURNS AN ITERATOR OVER THE ELEMENTS IN THE DICTIONARY | |
// i am not sure if my iterator method is correctly coded | |
// also i am not sure about the entry class in this. In the genKey class i am trying to use the enhanced for loop to read through the ntries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
import java.util.Scanner; | |
public class Infix { | |
public static int evaluate(String expression) { | |
//char[] nextItem = expression.toCharArray(); | |
String[] nextItem = expression.split(" "); | |
Stack<Integer> operands = new Stack<>(); | |
Stack<String> operators = new Stack<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inverse(A, B, f): | |
x = [] | |
for i in range(len(f)): | |
x.append(f[i][::-1]) | |
return x | |
A = [1, 2, 3] | |
B = [1, 5, 6] | |
f = [[1, 4], [2, 5], [3, 6]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isOnto(A,B,f): | |
x = [] | |
for i in range(len(f)): | |
x.append(f[i][1]) | |
#print(x) | |
i+=1 | |
B = sorted(B) | |
x = list(set(x)) | |
if B == x: | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isOneToOne(A, B, f): | |
x = [] | |
i = 0 | |
for i in range(len(f)): | |
x.append(f[i][1]) | |
i+=1 | |
x = sorted(x) | |
#print(x) | |
seen = set() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def image(f): | |
x = [f[0][1], f[1][1], f[2][1]] | |
x = sorted(x) | |
return list(set(x)) | |
f = [[1,4],[2,5],[3,4]] | |
print(image(f)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isFunction(A, B, f): | |
x = [] | |
for i in range(len(f)): | |
x.append(f[i][0]) | |
#print(x) | |
if len(x) != len(A): | |
return False | |
else: | |
for s in A: | |
#print(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ArrayList<E> implements List<E> { // The type parameter E is a placeholder for what kind of data will be stored in this list | |
private E[] data = (E[])(new Object[3]); // The array where the data is stored -- Java doesn't allow generic array creation, so we just create an array of Objects and cast it to E[] | |
private int size = 0; // The number of elements actually stored in the list | |
// Returns the item stored at the specified list index | |
// Big-O: O(1) | |
public E get(int index) { | |
if (index >= 0 && index < size) | |
return data[index]; | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Chase Floyd | |
* | |
* This class serves as the main client program for the game | |
* | |
* This class should include at least these instance varibales | |
* a GameBoard object to store the state of the game | |
* a Scanner object to read user input | |
* | |
* This class should contain the main method that is executed to start the game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
creditHour=int(input("How many total hours are you taking? ")) | |
advancedHour=int(input("How many of those hours are from engineering/science classes? ")) | |
tuition = creditHour * 350 | |
specialTuition = advancedHour * 25 | |
reducedTuition = creditHour * 40 | |
if creditHour >= 0 and creditHour <= 12: | |
print(tuition + specialTuition) | |
else: |