Mock (8)

19
MOCK-2011 B.Tech CS/IT/MCA Time Limit: 2 hrs 45 minutes M.Tech CS/IS/SW/GIS C 1. int main() { char str[] = "Mock"; str[0]='R'; printf("%s", str); str = "Rock"; printf("%s", str+1); return 0;} a) Rock Rock b) Mock Rock c) Rock ock d) Compilation Error 2. #define MACRO 10 void modifyMacro(void); int main() { printf("%d\n",MACRO); modifyMacro(); printf("%d\n",MACRO); return 0;} void modifyMacro() { #define MACRO 20 printf("%d\n",MACRO);} a) 10 20 20 b) 20 20 20 c) 10 20 10 d) ERROR: cannot define macro inside function 3.int f(int * a, int n){ if (n<=0)return 0; else if(*a% 2==0) return * a + f(a+1,n-1); else return * a-f(a+1, n-1);} int main ( ){ int a[ ]={12, 7, 13, 4, 11, 6}; pr int f ("%d", f(a,6)); return 0;} a) -9 b) 5 c) 15 d) 19 4. int main() { enum shape{circle,square,triangle,rectangle}; printf("%d\n",sizeof(enum shape)); if(-1L>1UL) printf("Failed in Mock\n"); else printf("Passed in Mock\n");} a) 16 b)4 c) 16 d) 4 Failed in Mock Failed in Mock Passed in Mock Passed in Mock 5.#define fun int main(){ #ifdef fun printf("mock"); #elif

Transcript of Mock (8)

Page 1: Mock (8)

MOCK-2011 B.Tech CS/IT/MCATime Limit: 2 hrs 45 minutes M.Tech CS/IS/SW/GIS

C1. int main() { char str[] = "Mock"; str[0]='R'; printf("%s", str); str = "Rock"; printf("%s", str+1); return 0;}a) Rock Rock b) Mock Rock c) Rock ock d) Compilation Error 2. #define MACRO 10void modifyMacro(void);int main() { printf("%d\n",MACRO); modifyMacro(); printf("%d\n",MACRO); return 0;}void modifyMacro() {#define MACRO 20 printf("%d\n",MACRO);}a) 10 20 20 b) 20 20 20 c) 10 20 10 d) ERROR: cannot define macro inside function 3.int f(int * a, int n){if (n<=0)return 0;else if(*a% 2==0) return * a + f(a+1,n-1);else return * a-f(a+1, n-1);}int main ( ){int a[ ]={12, 7, 13, 4, 11, 6};pr int f ("%d", f(a,6));return 0;} a) -9 b) 5 c) 15 d) 19 4. int main() { enum shape{circle,square,triangle,rectangle}; printf("%d\n",sizeof(enum shape)); if(-1L>1UL) printf("Failed in Mock\n"); else printf("Passed in Mock\n");}a) 16 b)4 c) 16 d) 4Failed in Mock Failed in Mock Passed in Mock Passed in Mock 5.#define funint main(){ #ifdef fun printf("mock"); #elif

Page 2: Mock (8)

printf("technical"); Will this be executed?; //Line 1 #endif printf("This is simple question\n");}a) Syntax error at line1 b) Runtime error c) mock This is simple question d) None of These 6. extern int i;int main() { printf("%d\n",sizeof(i));}a) Compile Error b) Linkage Error c) Runtime Error d) No error 7. int main() { char ch; if((ch=printf(""))) printf("Mock\n"); else printf("Technical\n"); return 0;}a) Mock b) Technical c) Compile Error d) None of these 8.#define PRINTIFLESS(x,y) if((x) < (y)) printf("First is smaller"); elsemain() { int i = 2, k =1; if(i>0 && k>0)

PRINTIFLESS(i,k); else printf("Numbers not greater than 0\n");}a) First is smaller b) Numbers not greater than 0 c) No output d) Parse Error before else 9.int *i = (int *)malloc(sizeof(int)); int main() { i= (int *)malloc(sizeof(int)); *i=4; printf(“%d”,*i);}a) 0 b)Segmentation Fault c)4 d)Compile Error 10. typedef int IG, * IGP; //Line 1typedef long L;int main() {

IG a = 5, b = 10;IGP c = &a; //Line 3L int d = 20; //Line 4}

Which of the above lines contain the error?a) line 1 b) line 3 c) line 4 d) None of these 11. int fun(int a) { if( (a=10) && (a==20) ) pritnf("Good question\t."); (a>=20)?return(10):return(20);}int main() {

Page 3: Mock (8)

int i = fun(20); printf("%d",i);}a) 10 b) 20 c) Compile Error d) Good Question 20 12.int main() { char str[10]; FILE * fptr = fopen("file1", "r"); fgets(str,5,fptr); printf("%s\n",str); fptr = fopen("file2", "r"); fgets(str,5,fptr); printf("%s\n",str);}file1 contains ''Hello'' and file2 contains ''Hell''. What will be output ?a) Hello Hell b) Hell Hell c) garbage Hell d) Runtime Error 13.#define SIZE 10void size(int arr[SIZE]) {printf("size of array is:%d\n",sizeof(arr));}int main() {int arr[SIZE];size(arr);}Considering size of integer is 4 bytes and size of pointer is 8 byte, what will be output of above program?a) Size of array is: 40 b) Size of array is: 4 c) Size of array is: 8 d) Compile error 14. main() {

abc((200,100),(300,400));}abc(int i) {

printf(“%d\n”,i);}a) 100 b) 200 c) 300 d) 400 15. #include <stdio.h>int main() { struct s1 { char *str ; struct s1 *ptr; } ; static struct s1 arr[] ={{"Hyderabad",arr+1},{"Bangalore",arr+2},{"Chennai",arr}}; struct s1 *p[3]; int i; for(i=0;i<=2;i++) p[i]=arr[i].ptr; printf("%s\t",(*p)->str);printf("%s\t",(++*p)->str); printf("%s\t",((*p)++)->str); return 0;}a) Hyderabad Bangalore Chennai b) Hyderabad Bangalore Bangalorec) Bangalore Chennai Chennai d) Chennai Bangalore Hyderabad 16. #define scanf “%s is a string” main(){ printf(scanf,scanf);} A. Compiler error B. scanf is a string C. %s is a string is a string D. %s is a string 17. main() {

char buf1[5];

Page 4: Mock (8)

char buf2[5];gets(buf2); //input is given as mocksexamprintf(“%s”,buf1);}

a) garbage b) Segmentation Fault c) exam d) mocksexam 18. void main(){

static char s[]="Hi Goodie";int i=4;char ch;ch=s[i++];printf("\t %c",ch);ch=++i[s];printf("\t %c",ch);ch=++i[s];printf("\t %c",ch);ch=i++[s];printf("\t %c",ch);ch=s[++i];printf("\t %c",ch);ch=i[s]++;printf("\t %c",ch);}

a) o p q q d d b) o p q q i i c) o d i e d) Compile Error 19) void main(){

int i=0100;printf("\n%d",i);}

a) 4 b) 100 c) 64 d) None of these 20. #pragma pack(2) //Line 1struct A{ unsigned a : 1; unsigned b : 1; int c; /* 4 bytes */ unsigned d : 4; unsigned : 4; unsigned e : 1; unsigned : 0; unsigned f : 1;};int main(){ printf("%d\n",sizeof(struct A));}Output on commenting line 1 and if not commented then output? [Write the answer in the space provided] OOPS(C++)1.class A {

static int num;public:

A(){num++;};~A(){num--;}};

int A::num=0;A f(A a){return(a);};main(){

A a;A b=f(a);}

What is the value of num at the end of the program ?a) 1 b) 0 c) -2 d) -1 2.class A{};class B: <keyword> A{};int main(){

Page 5: Mock (8)

A * a = new B();}Which of the following keywords can be used so that the code works perfectly?a) public, protected b) private, public c) protected, private d) none of these 3. template <class T>class A { private: T i;};class B { private: A<int> b;};int main() { A<B> c;}a) Syntax error b)Runtime error c)Code is perfectly correctd) Template cannot be instantiated with User-defined types 4. class A { int i; public: void fun(int i) { cout<<"fun"<<endl; }};class B: A { public: using A::i; //Line 1 using A::fun; //Line 2 };int main() { B d; d.fun(1); }a)Using directive cannot be used like above b)Error in line1c)Error in line2 d)Code works perfectly 5. Which of the following information is correct about header files?a) Providing definitions in header is syntax error and not allowed.b) Header files cannot be included more than once.c) Problem related to multiple declarations of class or structures in header files cannot be avoided by any way.d) none of these. 6. class A { int a; public: A(int i=0){a=i;} ~A(){cout<<a<<" ";}};class D {

int a; public: D(int i=0){a=i;} ~D(){cout<<a<<" ";}};class B: public A,public D { A b; D d; int a; public: B(int i=0):D(0),A(i){a=i;} ~B(){cout<<a<<" ";}};A a(1);

Page 6: Mock (8)

void fun(){ static A a(0); }int main() { B d(1); fun(); }a) 1 0 0 0 1 0 1 b) 0 1 0 0 1 0 1 c) 0 1 0 1 0 0 1 d) 1 0 0 0 1 1 0 7.union A { private: int a; float f; public: A(int i){a=i;} A(float j){f=j;} int read_int(){return a;} float read_float(){return f;}};class B: protected A { public: B(int i):A(i){} B(float j):A(j){} int read_int(){ return A::read_int();} float read_float(){ return A::read_float();}};int main() { B c(1), d(1.23f); cout<<c.read_int()<<" "<<c.read_float();}a) Union cannot be inherited using protective inheritance but public inheritance can be doneb) If public or private inheritance is used in above case, output will be 1 and 1.23c) Both a) and b) are incorrect d) Both a) and b) are correct 8. namespace A { void fun(){cout<<"In fun A"<<endl;}};namespace B { void fun(){cout<<"In fun B"<<endl;}};int main() { using namespace A; using B::fun; fun(); A::fun();}a) In fun A b) In fun B c) In fun A d) Ambiguity In fun B In fun A in fun A 9. class complexNo { int real; int imaginary; public: complexNo() {} complexNo(int a,int b):real(a),imaginary(b) {} friend complexNo & operator + (const complexNo &, const complexNo &); void print();};complexNo & operator + (const complexNo &a, const complexNo &b) { return a+b;}

Page 7: Mock (8)

void complexNo::print() { cout << real <<"+i"<<imaginary<<endl;}int main() { complexNo a(2,3),b(4,5); complexNo c; c=a+b; c.print(); return 0;}a) 6+i8 b) 2+i3 c)Compile Error d) Runtime error 10.class A { int i; public: A(int a = 0){this->i=a;} A operator+(const A & b) { A c; return c(this->i + b.i); } void show() { cout<<i<<endl; } };int main() { A a1(1); A a2(2); A a3; a3 = a2+a1; a3.show();}a) 3 b) Error: copy constructor definition not providedc) Error: in operator function d) Error: = operator definition not provided 11. class A { public: A(int){} };class B { int i; public: B(int x=0):i(x){} operator A()const{return A(i);} };int main() { B b; A a=b;}a) Error : definition of = operator is not provided b) Error : definition of copy constructor of A is not providedc) Error: assignment operation in main function is incompatible d) Code works perfectly 12. Which of the following statements are correct related to pure virtual function?a) Objects of the class having pure virtual function cannot be createdb) Definition of the pure virtual function cannot be provided in the same classc) both a and b d) none of these 13. class base {

int i;public: virtual void f(){cout<<''base'';}};

class derived:public base {int j;

Page 8: Mock (8)

public: void f(){cout<<''in derived'';}}:template <class T>class test {

public: test(T d) { d.f(); cout<<'' ''<<sizeof(d);}};main() {

base b; derived d;test<derived> t(b); }

a) derived 12 b) derived 8 c) base 8 d) error 14. class amazon {

public : operator netapp () const { cout<< "operator”; } } ; class netapp {

public :netapp (amazon &x ){cout<<”constructor “;} }; void f(netapp o) {

cout<<"function can accept only netapp "; } int main() { amazon a; f(a); }

a)operator function can accept only netapp b)constructor function can accept only netapp c)function can accept only netapp d)compile time error 15. class Pet { public: virtual void speak() const = 0; virtual void eat() const = 0; }; void Pet::eat() const { cout << "Pet::eat()" << endl; } class Dog : public Pet { public: void eat() const { Pet::eat(); } }; int main() { Dog simba; simba.eat(); } a)segmentation fault b)run time error c)Pet::eat() d) none of these DS and Algorithms1) A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below

0 1 2 3 4 5 6 7 8 9

42 23 34 52 46 33 How many different insertion sequences of the key values using the same hash function and linear probing will result in the hash table shown above?a) 10 b) 20 c) 30 d) 40 2) Given a character array of length n, where each character in the array is ‘0’ or ‘1’. The array can be seen as a binary number with a[0] the most significant bit. The function increment for the array is given as followsvoid increment(char *integer) { int i=strlen(integer)-1; while ((i>=0) && integer[i]=='1') { integer[i]='0';

Page 9: Mock (8)

i--; } if(i >=0) integer[i]='1'; return; }The tightest bound on the complexity of the above algorithm is (n is the length of the string) a) O(n) b) O(1) c) O(log n) d) Cannot be determined 3) Consider the following pseudocode. x := 1; i := 1; while (x <= 1000) begin x := pow(2,x) i := i + 1; end; What is the value of i at the end of the pseudocode? a) 5 b) 6 c) 10 d) 11 4) In each step of insertion sort algorithm, a new element has to be inserted into an already sorted subarray. Instead of using sequential search to determine the location of new element which takes O(n) time( Which makes the overall complexity O(n^2) ), We can use binary search since the subarray is sorted, which will take O(logn) time. By using this technique, we can reduce the complexity of insertion sort from O(n^2) to a). O(nlogn) b). O(n) c). O(logn) d). O(n^2) 5) An large array[1…N] with N slots is filled only up to positions n for the n very less than N. To start with we do not know n. To locate an empty slot, we check A[j] for j=2^[2^i] in step i. What is the fewest number of steps in which we are guaranteed to find an empty slot? a). O(log n) b)O(logN) c)O(loglog n) d)O(loglogN) 6) A hypercube of dimension 0 has only a vertex. To construct a hypercube of N dimentions, take two N-1 dimentional hypercubes, and attach edges between corresponding nodes of each of these hypercubes. How many colors will you need to color the EDGES of an N dimentional hypercube such that no two edges of the same color share a common vertex? a). 2 b). 2^N c). N d). N^2 7) Find the complexity of the function F(n)=2F(n/2)+10n, if n>1 F(n)=1, if n=1 a). O(n^2) b). O(n) c) O(nlogn) d)O(n^2) 8) Consider the following procedure: f(n) for i=1 to n do

j=n while j>i do

j=j-1 end while

end for Assume the above procedure are only an integer n>0; What is the time complexity in n for the procedure above: a).O(nlogn) b)O(n) c)O(n^2) d) n(logn)^2 9) Two matrices M1 And M2 are to be stored in an Array A and B respectively. Each Array can be stored either in row major or column major order in contiguous memory locations. The time complexity to compute M1*M2 (Matrix Multiplication) will be

Page 10: Mock (8)

a) Best if A is in row-major and B is in Column Major Order. b)Best if both are in row major c) Best if both are in column major d)Independent of the storage scheme. 10) Find the complexity of the following function:int mem[1000] = {1,2,3,4};int func( int i ) {

if( i < 0 || i>=1000 ) return 0 ;if( mem[i] ) return mem[i] ;else return func(i-1) + func(i-2) + func(i-3) + func(i-4) ; }

a. O(n^4) b. O(2^n) c. O(n) d. O(n!) 11) Consider a Binary Tee represented as a 1-indexed array(where the children of an element L are at indexes 2*L and 2*L+1, elements at index 1 is the root), with elements 1,2,3,4,5,6,7 in that order. If the post order traversal of the array gives ab-cd*+, the the label on the nodes 1,2,3,4,5,6,7 can be a). +,-,*,a,b,c,d b). a,-,b,+,c,*,d c). a,b,c,d,-,*,+ d). -, a,b,+,*,c,d 12) What will be the ordering of the vertices produced by TOPOLOGICAL SORT when it runs on the directed acyclic graph as shown below.

a) v0,v3,v2,v5,v1,v4 b) v0,v1,v4,v2,v5,v3 c) v4,v1,v5,v2,v4,v0 d) Topological sort is not possible in this case 13) Let zeros(string,a,b) counts number of 0's in string in the interval (a,b) a and b inclusive and ones(string,a,b) counts number of 1's in string in the interval (a,b) a and b inclusive.How many permutations of a string of length n(n=8) containing 1's and 0's exists such that for every interval [1,i] { i = 1,2....10 } such that zeros(An,1,i) <= ones(An,1,i) and zeros(An,1,n)=ones(An,1,n). a) 5040 b) 4862 c) 1432 d) 1430 14) Let a,b,c,d..... are addresses of structures which are shown below by boxes, each structure has data part and an address part, where xor means bitwise xor operation.

With above information, the list can be traverseda) only left to right b) only right to left c) in both directions d) in no direction 15) In hashing load factor α is defined as n/m where n is the no. of elements and m is the no. of slots. IN a hash table in which collisions are resolved by chaining, what is the expected time for an unsuccessful search and a successful search under the assumption of simple uniform hashing ?a) Θ(log α), Θ(log α) b) Θ(nα),Θ(log α)c) Θ(log α),Θ(1 + α) d) Θ(1 + α), Θ(1 + α)

Page 11: Mock (8)

16) Given followingCharacter a b c d e fFrequency(in thousands) 45 13 12 16 9 5What would be the Huffman codes for the above letters ?a) 000,001,010,011,100,101 b) 0,101,111,100,1100,1101c) 0,101,100,111,1101,1100 d) None of these 17) A binary search tree has the following key values: A,B,C,D,E,F,G,H,I and J with the smaller elements on the left side and greater elements on the right side. The preorder traversal for the tree isA B D C H E F G I JThe post order traversal is: [Write the answer in space provided in answer sheet] 18) Which one is faster ?

for(i=0;i<10;i++) {for(j=0;j<100;j++) {

//do something }}

for(i=0;i<100;i++) {for(j=0;j<10;j++) {

//do something}}

a) 1 b) 2 c) both are same d) cannot be determined 19) What is the lowest tight bound for finding shortest distance between two nodes in a graph with unit distance edges.a. V+E b. (V+E)log(V) c. V d. E DBMS1) A transaction schedule is serializable if its effect is equivalent to that of some serial schedule. Consider a bookkeeping operation consisting of two transactions —T1 and T2 — that are required to keep the sum A + B + C unchanged. Which of the following pairs of transactions will always result in a serializable schedule?

I. T1 T2 Lock A; Lock B; A = A - 10; B = B - 20; Unlock A; Unlock B; B = B + 10; C = C + 20;

II. T1 T2 A = A - 10; Lock B; Lock B; B = B - 20; B = B + 10; Unlock B; Unlock B; C = C + 20;

III. T1 T2 Lock A; Lock A; A = A - 10; B = B - 20; Unlock A; Unlock A; B = B + 10; C = C + 20;

a) I only b) II only c) III only d) I and II 2) TRUNCATE works faster than DELETE in SQL. This is becausea)In DELETE the action is logged in a file whereas in TRUNCATE no such log is maintained.b)TRUNCATE de-allocates whole data pages and removes pointers to indexes whereas DELETE physically removes data.c)The user firing the query must be the owner of the table in the case of DELETE. In TRUNCATE there is no such restriction.d)The entire statement under consideration is wrong i.e. DELETE works faster than TRUNCATE

Page 12: Mock (8)

3) Which of the following isolation levels have the Phantom type of violationi)Read Committed ii)Repeatable Readiii)Serializable iv)Read Uncommitteda) iii only b) ii and iii only c) i,ii and iv only d) I,ii, iii and iv 4) An audit traila).is used to make backup copies b) is the recorded history of operations performed on a filec) can be used to restore lost information d) none of the above 5) What should be done to make the given schedule recoverableT1 T2READ(A)WRITE(A)

READ(A)READ(A)a)Commit operation of T2 must happen before the commit operation of T1b)Commit operation of T1 must happen before the commit operation of T2c) Commit operation of T1 must happen before the read operation of T2d) Read operation of T2 must happen before the write operation of T1 6) Consider the following scenario:There are two tablesTab1: name(char20)) Tab2: name(varchar(20))Both tables have 1000 records.Now two queries are executedQ1: select name from tab1 Q2: select name from tab2Which query runs faster?a) Q1 b) Q2c) Both take the same amount of time since both basically have the same implication.d) None of these. 7) Which of the following is true about normalizationa) It helps avoid lossy decompositions.b) It frees the collection of relations from undesirable insertion, update and deletion dependencies.c) It helps to minimize redesign when extending the database structured) All of the above 8) A table has fields F1, F2, F3, F4, F5 with the following functional dependenciesF1 -> F3 F2 -> F4 (F1 . F2) -> F5In terms of Normalization, this table is inA) 1 NF B) 2 NF C) 3 NF D) None of these 9) R(A,B,C,D) is a relation, Which of the following does not have a lossless join dependency preserving BCNF decompositiona) A->B, B->CD b) A->B, B->C, C->D c) AB->C, C->AD d) A->BCD 10) Consider the join of a relation R with a relation S. If R has m tuples and S has n tuples. Then the maximum and minimum size of the join respectively are

Page 13: Mock (8)

a) m+n and 0 b) m+n and |m-n| c) mn and 0 d) mn and m+n DE/CO/CA/Microprocessor1) A CPU has an arithmetic unit that adds bytes and then sets its V, C, and Z flag bits as follows. The V-bit is set if arithmetic overflow occurs (in two’s complement arithmetic). The C-bit is set if a carry-out is generated from the most significant bit during an operation. The Z-bit is set if the result is zero. What are the values of the V, C, and Z(respectively) flag bits after the 8-bit bytes 1100 1100 and 1000 1111 are added? a) 0 0 0 b) 1 1 0 c) 1 1 1 d) 0 1 0 2) A certain pipelined RISC machine has 8 general-purpose registers R0, R1, . . . , R7 and supports the following operations.ADD Rs1, Rs2, Rd Add Rs1 to Rs2 and put the sum in RdMUL Rs1, Rs2, Rd Multiply Rs1 by Rs2 and put the product in RdAn operation normally takes one cycle; however, an operation takes two cycles if it produces a result required by the immediately following operation in an operation sequence. Consider the expression AB+ABC+BC,where variables A, B, C are located in registers R0, R1, R2. If the contents of these three registers must not be modified, what is the minimum number of clock cycles required for an operation sequence that computes the value of AB+ABC+BC ? a) 5 b) 6 c) 7 d) 8 3) Two J-K flip-flops with their J-K inputs tied HIGH are cascaded to be used as counters. After fourinput clock pulses, the binary count is..a)00 b)11 c)01 d)10 4) How many characters per sec(7bits +1 parity) can be transmitted over a 2400bps line if thetransfer is synchronous and asynchronous respectively(1 start bit and 1 stop bit)a)300 240 b)275 300 c) 240 240 d)240 300 5) Which one of the following is true for a CPU having a single interrupt request line and a single interrrupt grant line?a) Neither vectored interrupt nor multiple interrupting devices are possible.b) Vectored interrupts are not possible but multiple interrupting devices are possible.c) Vectored interrupts and multiple interrupting devices are both possible.d) None of these 6) Hamming Distance between 001111 and 010011 isa) 1 b) 2 c) 3 d) 4 7) The access time of a cache memory is 100ns and that of main memory is 1000ns. It is estimated that 80% of the memory requests are for read and the remaining 20% for write. The hit ratio for read access is 0.9. A write-through procedure is used. The average access time considering both read and write requests is [Write the answer in the space provided in answer sheet] 8) A virtual memory has a page size of 512 words. There are eight pages and four blocks. The associative memory page table contains the following entries.

Page 14: Mock (8)

Page Block Which of the following virtual address(in hexadecimal) will cause a page fault

0 3 a) 0x144

1 1 b) 0x344

4 2 c) 0xB44

6 0 d) 0xD44

9) The logical address space in a acomputer system consists of 128 segments. Each segment can have upto 32 pages of 4K words each. Give the hexadecimal logical address for segment 36 and word number 2000. [Write the answer in the space provided in answer sheet]. 10) Reduce the following function using K-Map and express as SOP[Write the answer in the space provided in answer sheet].F(A,B,C,D)=Σ (0,1,2,6,8,9,10) d(A,B,C,D) =Σ (5,7,13,15) Networking1)Consider the IP address 210.212.49.19. What will be the class, type, network address and broadcast address for this IP will be:a)D, public, 210.212.49.1, 210.212.49.255 b)C, private, 210.212.49.1, 210.212.49.255c)C, public, 210.212.49.0, 210.212.49.255 d)C, public , 210.212.49.0, 210.212.49.256 2)The main reason for splitting the link layer functionalities into LLC and MAC:a)LLC is used for framing and MAC is used for flow and error controlb) To provide interconnectivity between different LANs and at the same time provide specific access methods for each LAN.c) LLC is associated with IP addresses while MAC is associated with hardware address.d) None of these. 3) Match the following

1. Data link layer (i)The lowest layer whose function is to activate,deactivate and maintain the circuit between DTEand, DCE

2.Physical layer (ii) Perform routing and communication

3.Presentation layer (iii) Detection and recovery from errors in the transmitted data

4.Network layer (iv)Provides for the syntax of data

(a) 1-(iii), 2-(i), 3-(iv), 4-(ii) (b) 1-(ii), 2-(i), 3-(iv), 4-(iii)(c) 1-(iv), 2-(i), 3-(ii), 4-(iii) (d) 1-(ii), 2-(i), 3-(iii), 4-(iv) 4)Which of the following statements are correct?i.Time division multiplexing allows a connection to use unused slots of another connection.ii.Sliding window achieves higher throughput than Stop-and-Go.iii.Multiplexing a large number of flows reduces burstiness.

Page 15: Mock (8)

a) i and ii b) i,ii and iii c) ii and iii d) all are incorrect 5) End to end connectivity is provided from host to host in(a)Network Layer(b)Transport Layer (c)Session Layer(d)It is a combined functionality of the network and data link layer 6) A and B are the only two stations on an Ethernet. Each has a steady queue of frames to send. Both A and B attempt to transmit a frame, collide, and A wins the first backoff race. At the end of this successful transmission by A, both A and B attempt to transmit and collide. The probability that A wins the second backoff race isA) 0.5 B) 0.625 C) 0.75 D) 1.0 7) On a TCP connection, current congestion window size is Congestion Window = 4 KB. The window size advertised by the receiver is Advertise Window = 6 KB. The last byte sent by the sender is LastByteSent = 10240 and the last byte acknowledged by the receiver is LastByteAcked = 8192. The current window size at the sender isA) 2048 bytes B) 4096 bytes C) 6144 bytes D) 8192 bytes 8) Ping uses which Internet layer protocol?a) RARP b) ICMP c) ARP d) FTP 9) The technique used by traceroute to identify the hosts a) By progressively querying routers about the next router on the path to B using ICMP packets, starting with the first router b) By requiring each router to append the address to the ICMP packet as it is forwarded to B. The list of all routers en-route to B is returned by B in an ICMP reply packet c) By ensuring that an ICMP reply packet is returned to A by each router en-route to B, in the ascending order of their hop distance from A d) By locally computing the shortest path from A to B 10) What is the difference between a switch and a hub? a) Switches operate at physical layer while hubs operate at data link layer b) Switches operate at data link layer while hubs operate at transport layer c) Switches operate at data link layer while hubs operate at physical layer d) Switches operate at transport layer while hubs operate at physical layer UNIX1) Suppose an user mock does not have read privilege to /etc/passwd file. Which of the following commands will produce different output then their normal behavioura)passwd b) ls -l c) find d) Both a and b. 2) Given a traditional UNIX system, which of the following commands will produce error, given that the user does not have execute permission for directory mock, but has read permissions.a) ls mock b) ls -F mock c) ls -l mock d) All of these 3) Consider the following shell script #!/bin/bash -----> line 1echo “Mock” #!/bin/sh ---> line 2echo “Google !!!”a) line 1,2 are both comments b) line 1,2 are interpreter but error as cant have more than one interpreter

Page 16: Mock (8)

c) line 1 is interpreter and 2 is comment d) both are interpreter and line 1 is executed by bash and 2 by sh 4) how many directories will be created(assuming there are no directories of following names)mkdir abhishek/shubham shubham/umesh umesh/deepnarayan abhisheka) 1 b) 2 c)3 4) 4 5) Write down a command line to select all file having inode no. x or no. of links y[Write the ans in space provided in answer sheet] 6) Choose the correct statement- a) exit system call does not flushes the standard I/O and buffers b) _exit system call is used to flush the standard I/O and buffers c) On Unix system call _Exit and _exit are synonymous d) _exit system call is used to call exit handlers and signal handlers OS1.int main(){

for(i=0;i<n;i++) {fork();printf(“Hello\n”); }

printf(“Hello\n”); }The number of times Hello will be printed is a) 2^(n+1) b) 2*(2^(n+1) -2 c) 3* (2^n) - 2 d) None of these 2. Which of the following statement is true regarding signals?a) Default action of the SIGKILL and SIGSTOP can be changed.b) Threads within a process share the signal numbers.c) both a and b d) None of these 3. What will be output of the following program-volatile int a;int main() { a=10; volatile int *b=&a; volatile int c=11; if(vfork()==0) { a++; (*b)++; c++; printf("%d %d %d\n",a,*b,c); exit(0); } printf("%d %d %d\n",a,*b,c); }Assuming child process executes firsta) 12 12 12 b) 12 12 12 12 12 12 10 10 10 c) 10 10 10 d) None of these 10 10 10 4. In a particular Unix Os, each data block is size 1024 bytes, each node has 10 direct data block addresses and three additional addresses: one for single indirect block, one for double indirect block and one for triple indirect block. Also, each block can contain addresses for 128 blocks. Which one of the following is approximately the maximum size of a file in the file system?

Page 17: Mock (8)

a) 512MB b) 2GB c) 8GB d) 16GB 5. which of the following statements are true?I) shortest remaining time first scheduling may cause starvationII) preemptive scheduling may cause starvationIII) round robin is better than FCFS in terms of response timea) I only b) I and III only c) II and III only d) I , II and III 6) Consider the methods used by processes p1 and p2 for accessing their critical sections whenever needed, as given below. the initial values of shared boolean variabless1 and s2 are randomly assigned.

Method used by p1 while( s1==s2) ;critical section s1=s2;

Method used by p2 while( s1!=s2);critical sections2 = not(s1);

Which one of the following statements describes the properties achieved?a) Mutual Exclusion but not progress b) progress but not Mutual Exclusionc) Neither Mutual Exclusion nor Progress d) Both Mutual Exclusion and Progress 7) The size of Virtual Memory depends on the which of the following in Linux Operating Systema) Physical Memory b) Secondary Memory c)Both d) None of these 8) If the Disk head is located initially at 32, find the number of disk moves required with FCFS if the disk queue of I/O blocks requests are 98,37,14,124,65,67. a) 310 b) 324 c) 315 d) 321 9) Consider the following code snippet... if (fork() == 0){ a = a + 5; printf("%d, %d \n", a, &a); } else { a = a - 5; printf ("%d, %d \n", a,& a); }Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE? [ a ? b means that the relationship between a and b cannot be determined and will depend on whether child runs first or parent runs first or some other factors]a) x ? u y ? v b) x ? u y = vc) x = u+10 y ? v d) x = u+10 y = v 10) The state of a process after it encounters an I/O instruction is __________. a) Ready b) Blocked/Waiting c) Idle d) Running 11) Which technique was introduced because a single job could not keep both the CPU and the I/O devices busy? a) Time-sharing b) Spooling c) Preemptive scheduling d) Multiprogramming 12) int i;void fun() {

int j;for(j=0;j<10000;j++)

Page 18: Mock (8)

i++; }main() {

thread_t tid1,tid2;pthread_create(&tid1,null,fun,null);pthread_create(&tid2,null,fun,null);pthread_join(tid1,null); pthread_join(tid2,null);printf(“%d”,i); }

Output from above code is a) lies between some defined range b) garbage as “i” is not initialisedc) 20000 d)10000 13) Suppose seek time is 2ms, rotational speed is 15,000rpm, no. of bytes on a track is 2^10 and number of bytes to be transferred is 512 bytes, Calculate total average access time.a) 10 b) 12 c) 8 d) 6 Questions 14 and 15 are based on following code.char string[]=”hello world”;main() {

int count, i;int to_par[2],to_chi[2]; char buf[100];pipe(to_par); pipe(to_chi);if(fork()==0) {close(0);dup(to_chi[0]);close(1);dup(to_par[1]);//----------------------------- position 1while(1) {

if((count=read(0,buf,sizeof(buf)))==0)exit(0);

write(1,buf,count); } }close(1); dup(to_chi[1]);close(0);dup(to_par[0]);for(i=0;i<5;i++) {

write(1,buf,strlen(buf));read(0,buf,sizeof(buf));} }

14) On running the above code n times, number of processes a.out is a)n b)2n c)0 d)n-115) Suppose in “position 1” we write these lines

close(to_par[1]); close(to_par[0]); close(to_chi[1]); close(to_chi[0]);Now on running above code n times, the number of processes a.out isa) n b)2n c)0 d)n-1 Automata1) Consider the grammar with the following translation rules and E as the start symbol.E -> E # T {E.value = E.value * T.value } | T {E.value = T.value }T -> T & F { T.value = T.value + F.value } | F {T.value = F.value}F -> num {F.value = num.value }Compute E. value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.

Page 19: Mock (8)

a) 200 b) 180 c) 160 d) 40 2) The C language is: a) A context free language b) A context sensitive languagec) A regular language d) Can be parsed fully only by a Turing machine 3) Which one of the following regular expressions is NOT equivalent to the regular expression (a + b + c)* ?a) (a* + b* + c*)* b) (a*b*c*)* c) ((ab)* + c*)* d) (a*b* + c*)* 4) Given a grammar s -> s + s ; s -> s * s ; s -> aFind the no of parse trees for a+a*a+aa) 4 b) 5 c) 6 d) 7 5) Consider the following languages. For each say if it is (1) regular, (2) context free but not regular , (3) Not context free(i) {a^nb^nc^i : i<=n} (ii) {a^ib^j | : i < j }(iii) {a^nb^nc^n } (iv) {0^2, 1^2 }a) 2 2 2 1 b) 3 2 3 1 c) 3 3 3 1 d) 3 2 2 2 6) Look at the following non-deterministic finite-state automaton (NFA), with A as the startstate, and D as the only accepting state.

Which deterministic finite-state automaton (DFA) with d as its state transition function acceptsthe same language?

a) Start state A , accepting states C and D.d A b = Bd B a = Cd C a = D

b) Start state A , accepting state C.d A b = Bd B a = Cd C a = C

c) Start state A , accepting state D.d A b = Bd B a = Dd B b = Cd C a = D

d) All the answers above are correct