PREVIOUS QUESTIONS: SET-2

SET-1         SET-2       SET-3      SET-4       Coding  MCQs

SET 2:
1. Advanced: Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.
a. 10
b. 7
c. 6
d. 5
Answer: 10
2. #define is used to
a. Define a variable
b. Define a macro
c. Define a function
d. Define a constant

Answer: Define a macro

3. What type of data structures are queues?
a. First in last out
b. First in first out
c. Last in first out
d. Last in last out

Answer: First in first out
4. Which of the following is NOT a valid storage class in C language?
a. Extern
b. Dynamic
c. Register
d. Auto
Answer: Dynamic
5. Eesha is developing a word processing software in which she wants to provide undo feature.the software will maintain all the sequential changes and at any point of time pressing control z will undo the latest change,what data structure should Eesha use for this?
a. Stack
b. Queue
c. Linked list
d. Array
Answer: Stack



6. #include
Main(int argc,char**argv)
{
printf(“%s\n”,argv[--argc]);
Return 1;
}
The above program was run with the following command line parameters
Asha usha nisha easha
What was the output?
a. Nisha
b. Unable to run due to compilation error
c. No output,run time error
d. Eesha

Answer: Eesha

7. Considering a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions? (NOTE:100 ^ 3 means 100 raised to the power 3)
a. (97 * 96 * 95) / 100 ^ 3
b. (97 * 96 * 95) / (6 * 100 ^ 3)
c. (97 * 97 * 97 ) / 100 ^ 3
d. (99 * 98 * 97) / 100 ^3
Answer: (97 * 97 * 97 ) / 100 ^ 3
8. Advanced Consider the following graph starting at node A. In what order will the nodes be visited using a breadth first search?
NOTE 1 : Is there is ever a decision between multiple neighbour nodes in the algorithm, assume we always choose the letter closest to the beginning of the first alphabet
NOTE 2: Enter the answer as a sequence of nodes separated by a comma. Please do NOT enter any blanks anywhere in the response. For example, is the answer (order of nodes) is A followed by C, followed by X, followed by D. the answer should be A,C,X,D.
Answer: A,B,D,E,G,C,H,F
9. This function is called with A and 7 as parameters where the array A initially contains the elements 34,14,65 be the value of the elements in A after 3 iterations of the outer loop?

a. 14 12 22 5 34 65 71
b. 14 34 22 12 65 5 71
c. 14 22 12 34 5 65 71
Answer: 14 12 22 5 34 65 71
Coding
Consider the below series :
0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8
This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even terms is derived from the previous term using the formula (x/2)
Write a program to find the nth term in this series.
The value n in a positive integer that should be read from STDIN the nth term that is calculated by the program should be written to STDOUT. Other than the value of the nth term no other characters /strings or message should be written to STDOUT.
For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT.
You can assume that the n will not exceed 20,000.
Code:
#include<stdio.h>
int main()
 { //code 
int n;
 scanf("%d", &n); 
if(n % 2 == 1)
 {
 int a = 1; 
int r = 2;
 int term_in_series = (n+1)/2; int res = 2 * (term_in_series - 1); 
printf("%d ", res); 
}
 else
 { 
int a = 1; 
int r = 3; 
int term_in_series = n/2;
int res = term_in_series - 1; 
printf("%d ", res); 
}
return 0;
 }

No comments:

Post a Comment

CTS Written test results of Vijayawada, Guntur, Ongole, Godarvari Districts were out.  Tentative dates of TR and HR are 24th and 25th Nov...