what does this print?
int a = 5;
int b = 6;
printf("a is %d b is %d, ++a, b++);
a is 6 b is 6
100
What are the three tenants of Object Oriented Programming?
Encapsulation, Inheritance, Polymorphism
100
What is the height of a binary tree?
log(n)
100
What is average case performance big-O for bubble sort?
O(n^2)
100
How many rows appear in a truth table for the compound proposition (p v -r) ^ (q v -s)?
4
200
what does this print out?
what does this print out?
void swap(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int a = 6
int b = 7
swap(a, b)
printf("a = %d b = %d", a, b);
a = 6 b = 7
200
What part of the MVC design pattern is a collection of methods and listeners? Give the full name (answering M, V, or C doesn't give any points).
Controller
200
What's the height of a complete binary tree with n nodes?
log n
200
What's the lower bound for comparision sorting algorithms?
n log n
200
For the list of integers, provide a simple formula that generates the terms of an integer sequence that begins with the list: 2, 3, 7, 25, 121.
E.g. For 2, 3, 5, 9, 17, A_n = n^2 + 1
A_n = n! + 1
300
what does this print out?
#define MAX(x, y) x > y ? x : y
int a = 4;
int b = 6;
int c = MAX(x++, y++);
printf("The max is %d\n", c);
printf("a = %d b = %d", a, b);
The max is 7
a = 5 b = 8
300
This specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes.
Class template (not a template class).
300
In tree construction which is the suitable efficient data structure? (E.g. Array, Stack, Queue, etc)
Linked list
300
What's the preorder, inorder and post order traversal of this tree...
Preorder: F, E, B,A, D, C, I, H, G
In order: A, B, E, D, C, F, I , H, G,
Post order: A, B, D, C, E, G, H, I, F
300
Give a big-O estimate for (n log n + n^2)(n^3 + 2).
O(n^5)
400
What does the following print:
char *s = "QUALCOMM";
int end = sizeof(s) - 1;
print("This letter is %c!", s[end]);
This letter is L!
400
What is the process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.
Stack unwinding.
400
If you are using C language to implement the heterogeneous linked list, what pointer type will you use?
The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.
400
Number of edges in a complete graph.
n(n-1)/2
400
How many ways are there to distribute 5 balls into 3 boxes if each box must have at least one ball in it and the call and boxes are labeled?
150
500
What does this print out?
unsigned int a = 0x1000;
printf("This is now %x\n", ((char *)a) + 4); printf("And this is now %x\n", ((unsigned int *)a) + 4);
This is now 1004
And this is now 1010
500
class Sample
{
public:
int *ptr;
Sample(int i)
{
ptr = new int(i);
}
~Sample()
{
delete ptr;
}
void PrintVal()
{
cout << "The value is " << *ptr;
}
};
void SomeFunc(Sample x)
{
cout << "Say i am in someFunc " << endl;
}
int main()
{
Sample s1 = 10;
SomeFunc(s1);
s1.PrintVal();
}
In the above example when PrintVal() function is
called it is called by what?
It's called by the pointer that has been freed by the destructor in SomeFunc.
500
In an AVL tree, at what condition is the balancing done?
When the 'pivotal value' (or the 'Height factor') is greater than 1 or less than -1.
500
What is the minimum spanning tree of this graph...
...
500
A spanning forest of a graph G is a forest that contains every vertex of G such that two vertices are in the same tree of the forest when there is a path in G between these two vertices.
How many edges must be removed to produce the spanning forest of a graph with n vertices, m edges, and c connected components?