Considered the father of theoretical computer science and artificial intelligence
Alan Turing
JAVA
public static void main(String args) {
//I have a comment here*/
}
String[] args
if(!!!!!true)
Output("False");
else
Output("True");
{Output = cout or System.out.println()}
True
What is my favorite data structure?
Best answer wins, be it efficient, funny, or my actual preference :)
Probably a HashMap or Set, it's quick but not space efficient.
Who created C?
Dennis Ritchie
Who created C?
Dennis Ritchie
Java
String s = "hello";
Stack<Character> chars = new Stack<Character>();
for (int i = 0; i < s.length(); i++) {
chars.push(s.charAt(i));
System.out.println(chars.pop());
}
C++
string s = "hello";
stack<char> chars;
for (int i = 0; i < s.size(); i++)
{
chars.push(s.at(i));
cout << chars.top() << endl;
chars.pop();
}
h
e
l
l
o
You pop it right off
What is the O(n) of searching in an AVL Tree?
When was TCP (Transmission Control Protocol) invented? By who?
In May 1974, Vint Cerf and Bob Kahn.
C++
vector<int> path = graph.bfsPath();
for (int i :: path)
{
cout << i << endl;
}
Java
ArrayList<Integer> list = new ArrayList<>();
for (Integer integer :: list) {
System.out.println(integer);
}
The :: must be :
:)
int test = 31;
System.out.println(test >> 2);
or
cout << (test >> 2) << endl;
7
:)
0001 1111
becomes
00000111
What is the right child of the 3rd element if this array resembles a heap?
9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1
:)
Name of the AI Bot which beat world's best Go player.
AlphaGo
Java: What does the body of an abstract method contain?
C++: What does a pure virtual function contain?
Nothing, it has no body.
;)
Java-specific:
String string = "hiii";
String test = "hiii";
if(string == test)
System.out.println("Same");
else
System.out.println("Different");
Same
The JVM checks if there is already a string literal in the "String Literal Pool" to increase efficiency.
Which data structure would you use to store students if a student object contains a [name, id, email address, and gender] and you don't need to worry about memory?
Set
As opposed to map, the Set structure does not need a key-value pair, it just needs a key which can be the student ID
How were programs written in the mid-1970s as the programming languages were invented?
Find the syntax error:
Java: System.out.println("Hello World!'');
C++: cout << "Hello World'' << endl;
" vs ''
;)
Run the code, what will be counter?
int counter = 7;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; i++) {
counter++;
j++;
}
}
//What is counter here?
17
;)
What sorting algorithm is out-of-place, time complexity is O(nlogn) and space complexity is O(n)?
Merge-sort