This file contains hidden or 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
Hey, | |
I am reaching out to you since you did a unit at MUIC in which I lectured. If you believe that I showed enthusiasm and an interest in your learning and helped you along the way, please nominate me for the MQ learning and teaching awards at: | |
https://mqedu.qualtrics.com/jfe/form/SV_6GaGULwwxgH4RZX | |
IMPORTANT Please use the unit codes COMP115 instead of WCOM115 and COMP125 instead of WCOM125. |
This file contains hidden or 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
Hey, | |
I am reaching out to you since you did a unit at Computing, MQ in which I lectured. | |
If you believe that I showed enthusiasm and an interest in your learning and helped you | |
along the way, please nominate me for the MQ learning and teaching awards at: | |
https://mqedu.qualtrics.com/jfe/form/SV_6GaGULwwxgH4RZX | |
It's a very short survey and you only need to fill in my name (First name: Gaurav, Last name: Gupta), unit studied and reason for nomination. Surprisingly, you are not required to fill in your details :/ |
This file contains hidden or 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
/** | |
*return true if a and b are identical. That is, they have | |
*the same items in the same order | |
* | |
*for example | |
*if a = {2, 8, 5} and b = {2, 8, 5}, return true | |
*if a = {2, 8, 5} and b = {2, 8, 5, 7, 3}, return false | |
*if a = {2, 8, 5, 7, 3} and b = {2, 8, 5}, return false | |
*/ | |
public static int identical(int[] a, int[] b) { |
This file contains hidden or 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
class Circle { | |
private double radius; | |
public double getRadius() { return radius; } | |
public void setRadius(double r) { radius = Math.max(0, r); } | |
public Circle(double r) { setRadius(r); } | |
public double area() { return Math.PI * radius * radius; } | |
public int compareTo(Circle other) { | |
//to be completed :) | |
} | |
} |
This file contains hidden or 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
class Bucket { | |
private double capacity; | |
public double getCapacity() { return capacity; } //getter | |
public void setCapactiy(double c) { //setter: min capacity 1 | |
if(c < 1) | |
capacity = 1; | |
else | |
capacity = c; | |
} | |
public Bucket() {setCapacity(1); } // default constructor |
This file contains hidden or 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
int[] a = {10, 50, 30, 80, 20}; | |
int[] b = a; | |
int[] c = {a[0], a[1], a[2], a[3], a[4]}; | |
b[0]--; | |
c[0]++; | |
//what are the contents of a, b, c? |
This file contains hidden or 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
//precondition: assume a.length > 0 | |
//return true if all items are in the range [min, max], false otherwse | |
public static boolean allInRange(int[] a, int min, int max) { | |
for(int i=0; i < a.length; i++) { | |
if(a[i] < min || a[i] > max) { | |
return true; | |
} | |
else { | |
return false; | |
} |
This file contains hidden or 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
//helper 1 | |
public static void swap(int[] a, int idx1, int idx2) { | |
if (a == null) nothing to do | |
return; | |
if (idx1 < 0 || idx1 >= a.length) //invalid index 1 | |
return; | |
if (idx2 < 0 || idx2 >= a.length) //invalid index 2 | |
return; | |
int temp = a[idx1]; | |
a[idx1] = a[idx2]; |
This file contains hidden or 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
int n = (int)random(5, 20); | |
float ps; | |
void setup() { | |
size(400, 400); | |
background(255); | |
strokeWeight(3); | |
println("number of partitions: "+n); | |
ps = width*1.0 / n; | |
println("partition size: "+ps); |
This file contains hidden or 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
class Node { | |
private Node next; | |
private int data; | |
public int getData() { | |
return data; | |
} | |
public Node getNext() { | |
return next; | |
} |