You are on page 1of 4

GITAM Vizag July 2008 Yahoo!

Section 1

Question 1
In C language, which of the following is equivalent to &2[3[a][5]]?
 (a) &a[5][3][2]
 (b) &*(*(a[2]+5)+3)
 (c) &5[*(a+3)][2]
 (d) a[5][2][3]
 (e) a[2][3][5]

Question 2
Below is a set of characters and their relative frequencies of occurrence. If we build an optimum
Huffman code for this set of characters, how many bits will it take to represent the character “g”?

Character : f g h m n p q
-------------------------------------
Frequency : 1 1 2 3 3 5 8

 (a) 8
 (b) 5
 (c) 4
 (d) 2
 (e)

Question 3
Suppose we have a binary tree T on n nodes. It is not extended, and is not required to be full. If the
first node of its postorder traversal is the same as the last node of its preorder traversal, what can we
conclude?

 (a) The left subtree of T is empty.


 (b) The right subtree of T is empty.
 (c) T contains atmost three nodes.
 (d) T has height n-1. ( Here height is defined as the maximum distance from a leaf to the root.)
 (e) (a) and (b).

Question 4
The following postfix expression containing single digit operands and arithmetic operators + and
*, is evaluated using a stack. ( consider left to right as bottom to top ).
52*34+52**+
What are the contents of the stack after the evaluation of 5 2 * 3 4 +

 (a) 10 7
 (b) 6 9
 (c) 7 10
 (d) 9 6
 (e) 7 7
GITAM Vizag July 2008 Yahoo!

 (a) O(n log(n))


 (b) O( log(n))
 (c) O( n^2)
 (d) O( n^2 * log(n))
 (e) O(2 log(n))

Question 9
Which traversal will produce output that takes maximum processing time when fed to a
randomized quick sort algorithm for a binary tree? A randomized quick sort can randomly select any
elements from the current set of elements, as pivot.
 (a) Preorder
 (b) Inorder
 (c) Postorder
 (d) All are same

Question 10
An insect sitting at coordinate (0,0) can move either one unit or two units at a time i.e. if it is at
(x,0), it can go either (x+1,0) or (x+2,0). In how many ways it can go from (0,0) to (n,0).

Question 11
Given an unsorted array of length n, what is the least no. of comparisons needed to find the
minimum and maximum of the array?
 (a) n^2
 (b) ln(n)
 (c) 2n-2
 (d) 3*floor[n/2]

Question 12
Find the postorder traversal if A,B,C,D,E,F and G are the nodes of a binary tree and the inorder
and preorder traversals of the tree is as given below
Preorder : ABEFCDG
Inorder : EFBCGDA
GITAM Vizag July 2008 Yahoo!

Question 4
What is the output of the following program?

Void main()
{

int a [] = {1,2,3,4,5};
int i;
for (i=0;i<5;i++)
*(a+i)=f ( a+i)
for( i=0;i<5;i++)
printf( “%d”, [i]a);
}
int f ( int a[] )
{
Return (*a) ++ || 0+1;
}
 (a) 1111
 (b) 22222
 (c) 222
 (d) 13513
 (e) 24135

Question 5
What is the output of the following perl code?
#!/usr/bin/perl
Sub have_fun {
My $start = shift;
Return sub { $start++ }
}
My $from_ten = have_fun (10);
My $form_five = hava_fun (5);
Print $from_five - > ();
Print $from_five - > ();
 (a) 5 5
 (b) 4 6
 (c) 5 6
 (d) 6 5
 (e) 5 10

Question 9
A hash table contains 10 buckets and uses linear probing to resolve collisions. The key values are
integers and the hash function used is key%10. If the values 43, 165, 62, 123, 142 are inserted in the table,
in what location would he key value 142 be inserted?

 (a) 2
 (b) 3
 (c) 4
 (d) 6
GITAM Vizag July 2008 Yahoo!

 (e) 10

Question 10
If f(A,B) = A’+B, what does f(f(x+y,y),f(x+y,y)) simplify to?

 (a) x’+z
 (b) 1
 (c) xy’+z
 (d) none of the above

Question 11
Your college has been assigned a Class B address of 192.55.0.0. As a network administrator, you are in
charge of sub-netting the IP address space assigned to your institution, among 48 departments. Assuming
the sub-netting is done optimally, what is the maximum number of hosts that each of the 48 departments
can have (Assume that no host can have an all 0 or all 1 address)?

 (a) 2046
 (b) 512
 (c) 1022
 (d) 254
 (e) none

Question 12
A host on a network has a Class B address of 192.168.243.5. The subnet mask used is FF.FF.F0.0
( in Hex). Which of the following address and sub-net masks identify a host in the same network?

 (a) 192.168.1.1/255.255.240.0
 (b) 192.168.239.5/255.255.240.0
 (c) 192.168.240.192/255.255.240.0
 (d) 192.168.224.240/255.255.240.0
 (e) none

You might also like