Capgemini Technical Topicwise Sorted (1).docx

  • Uploaded by: mmj
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Capgemini Technical Topicwise Sorted (1).docx as PDF for free.

More details

  • Words: 2,322
  • Pages: 21
Table of Contents CONTROL STATEMENTS ................................................................................ 1 ENUM, STRUCT AND UNION ........................................................................... 3 OPERATORS................................................................................................... 3 POINTERS ...................................................................................................... 5 BASIC DATA STRUCTURE............................................................................... 6 QUEUE ........................................................................................................... 6 LINKED LISTS ................................................................................................ 6 GRAPH ........................................................................................................... 6 STACK ........................................................................................................... 7 TREES............................................................................................................ 7 ALGORITHM ................................................................................................... 8 ARRAY ........................................................................................................... 8 ALGORITHM-LANGUAGE INDEPENDENT......................................................... 9 RECURSION ................................................................................................... 9 DYNAMIC PROGRAMMING ............................................................................ 11 DIVIDE AND CONQUER................................................................................. 13 SORTING ...................................................................................................... 17 SEARCHING ................................................................................................. 19 DIGITAL LOGIC ............................................................................................ 19 FLIP FLOPS .................................................................................................. 19 LOGIC GATES ............................................................................................... 20

BASIC C CONTROL STATEMENTS 1.What will be the output of the following C code? #include<stdio.h> Int main() { Int x=0; If(x==1) If(x==0)

Printf(“inside if \n”); Else Printf(“inside else if\n”); Else Printf(“inside else\n”); } OPS: a.inside if b.inside else c.compilation error d.inside else if 2. What will be the output of the following C program? #include<stdio.h> Int main() { Int a=0,i=0,b; For(i=0;i<5;i++) { A++; If(i==3) Printf(“hello world”); Break; } Printf(“%d”,a); Return 0; } OPS: a.2 b.1 c.hello world d.4 3. What will the output of the following c code ? #include<stdio.h>

Int main() { Int x=2,y=0,z=3; x>y ? printf(“%d”,z); return z; } OPS: a. compilation error b. 3 c.1 d. Runtime error ENUM, STRUCT AND UNION 1.What is the output of the following C code? #include <stdio.h> Union sti { Int nu; Char m; }; Int main() { Union sti m; Printf(“%d”,size of(m)); Return 0; } OPS: a.12 b.4 c.16 d.5 OPERATORS 1.What will be the output of the following code ?

#include<stdio.h> Void main() { Int x=9,y=2,z=6; Int a= x & y | z; Printf(“%d”,a); } Ops: a.2 b.3 c.0 d.6 2. What would be the output of the following c code? #include<stdio.h> Int main() { Int x=4,y=0; Int z; Z=(y++,y); Printf(“%d\n”,z); Return 0; } OPS: a.1 b. undefined behavior due to order of evaluation can be different c.0 d.compliation error 3.what will be the output of the following c code? #include<stdio.h> Int main() { Int y=5; Int z=y+(y=10); Printf(“%d\n”,z); }

OPS: a.20 b.4 c.either 12 or 20 d.12 POINTERS 1. What will be the output of the following code ? Main() { Int num[]={1,4,8,12,16}; Int *a,*b; Int I; A=num; B=num+2; I = *a++; Printf(“%d,%d,%d\n”,I,*a,*b); } OPS: a.4,4,8 b.2,4,8 c.1,4,8, d.2,1,,8 2. comment on the output of the following c code ? #include<stdio.h> Void main() { Int k=4; Int *const p=&k; Int r=3; P=&r; Printf(“%d”,p); } OPS: a.it will print address of r

b.it will print address of k+ address of r c. it will print address of k d.complie time error BASIC DATA STRUCTURE QUEUE 1. Suppose queue is implemented using a linked list and its front node and rear nodes are tracked by two reference variables. Which of these reference variable will change during an insertion into a non empty queue? OPS: a.only the front will change b.none of them will change c.only the rear will change d.both will change 2.In which of the following situations queue implementation is usefull? OPS: A. All the mentioned options B. When data is transferred asynchronously between two processes C.When a resource is shared among multiple consumers. D. Load balancing.

LINKED LISTS 1.What will be the probability of selecting a random node from a given singly linked list?(Assume that there are n nodes in the list) OPS: a.2(n-1)/n b.n/2(n-1) c.2n-1 d.1/n GRAPH 1.What is the maximum degree of any vertex in a simple graph with n vertices.? OPS: a.2n-1

b.n-1 c.n+1 d.n 2. which of the following statements is /are TRUE for undirected graph? P: Number of odd degree vertices is even Q: sum of degree of all vertices is even OPS: a.both of P and Q. b. neither P nor Q. C. Q only. d. P only. STACK 1.Identify the point that is not true with respect to stack? OPS: a.It is not possible to insert or remove elements anywhere else except the top of the stack. b.stack is a dynamic set where elements are removed in the reverse order of their insertions. c.All the mentioned options are correct d.Stack supports LIFO order of deletion of items 2.which of the following applications may use a stack? OPS: a. A parntheseis is balancing program b. Syntax analyser for a compiler c. Keeping track of local varaiables at run time d. All the mentioned options TREES 1.Maximum height of an AVL tree with 7 node is? OPS: a.5 b.4 c.6 d.3 2. Which of the following is a direct search technique?

OPS: a.Binary search b.Linear search c. Tree search d.Hashing 3. Consider a Binary Tree having two pointers for each of its children. These pointers are set to NULL if the corresponding child is empty. How many NULL pointers does a binary tree with N nodes have? OPS: a. N-1 b. The number depends on the shape of the tree. c. N d. N+1 ALGORITHM 1. Consider the following functions and their complexities: F1(n)=2n F2(n)=n3/2 F3(n)=n Log n F4(n)=nLog n Which among the following options correctly represents the increasing order of asymptotic complexity of the functions F1,F2,F3,F4 Respectively? A. None of the mentioned options B. F2
c.3 d.4 ALGORITHM-LANGUAGE INDEPENDENT RECURSION 1. What does the run() do in general? 1. int fun ( int x, int y) 2. { 3.

if ( y = = 0) return 0;

4.

return (x + fun (x, y-1));

5. } 6. 7. int run ( int a, int b) 8. { 9.

if ( b == 0) return 1;

10.

return fun ( a, b-1));

11. } A. calculate X+X*Y B. calculate X^Y C. calculate X*Y D. calculate y ^ X 3.What will be the output f the following pseudo code? Input f=6,g=9 and set sum=0 Integer n if(g>f) for(n=f;n
5.Consider the following pseudo code a:=1; b:=1; while (a<=500) begin a:=2^a; b:=b+1; end What is the value of b at the end of the pseudo code? OPS: a.7 b.5 c.4 d.6 7.The following pseudocode can be used for : Let LB be the lower bound and UB be the upper bound of a linear array A. [Initialize counter ]set k at lower bound LB Repeat for k=LB to UB Print a[k] [End of the loop] Exit OPS: a.Deleting an element from an array b.Sorting an array c.Traversing an array d. Inserting elements in the array 8. What will be the output of the following algorithm for number =10? Start Declare the variable I,j,and num Enter the value of num Repeat for i=1 to num Declare the static variable sap and set sap=0 sap=sap+i j=sap end loop print j

Note: static allows the last value of the variable to be preserved between successive function calls. OPS: a.85 b.75 c.65 d.55 9.What will b output of the following pseudocode? Input:s algorithm(integer num) set integer i=2 while i<=num/2 if num mod i=0 print”Unsuccessful” and exit; i=i+1 if (i==(num/2)+1) print”Successfull” OPS: a.Successful b.Unsuccessful c.It will not print anything d. Undefined behaviour of the algorithm DYNAMIC PROGRAMMING 2. What does the following algorithm do? 1. Start 2. take 2 strings s1 and s2 3. set k=0 4. Repeat while length of string s1 5.

increment k

6. set j=0 7.

repeat while length of string s2

8.

set s1[k] = s2[j]

9.

increment J by 1

10. increment K by 1 11. set s1[K] = Null 12. print s1 13. stop A. reverse and concatenate two strings B. concatenate two strings C. reverse and copy both the strings D. none of the mentioned option 6.What will be output of the following given statements. Declare the integer variables x,y,z. if x>y.if z>y Display”One” else if z is equal to x Display”two” else Display”three” else Display”four” OPS: a.it will display two if z is <=y b.it will display 2 if x>y>z c.it will display 4 if x>yn Go to line no 9 Else T=T+m M=m+1 Go to line no 3 Display the value of T

Stop OPS: a.28 b.76 c.32 d.56 22.What will be the output of the following pseudocode? Input n=1234 Integer q,r and rn Set q-n and rn=3 While(q>0) R= q mod 10 Rn=rn+r^3 Q=q/10 End while loop Print rn OPS: a. None of the mentioned options b.10 c.100 d.36 e.321 DIVIDE AND CONQUER 4.What will be the output of the following pseudo code for the given array a[5]=3,4,6,1,2 and pos is 2?(Note: n=the size of the array) Declare I,j,n,pos Repeat for j=pos to n-1 Set a[j]=a[j+1](end of the loop) n=n-1; Display the new array end OPS: a. 3 4 2 1 2 b. 3 4 1 2

c.3 2 4 6 1 2 d. 3 6 1 2 10. What will be the output of the following pseudocode for input a=8 and b=9? Function(input a,input b) if (a
b. 13 17 19 23 c.13 15 17 19 21 23 25 27 29 d.12 15 18 21 16. what will be the output of the following algorithm? Start Declare a,I,and b For I=0 to 4 Increment a by 1 If I=3 then Print hello Get out of the loop End if End for Print a OPS: a. hello4 b. hello c. 1 d. 4 18. What will be the output of the following algorithm? Start Declare v ariable f,g and i Set f=0 and g=1 For i=1 to 4 Print f F=f+g G=f+g End OPS: a. 0 1 1 2 b. 0 1 1 8 c. 0 1 3 8 d. 0 2 5 8

19. What will be the output of the following pseudocode? Declare variable x, y and i Set x=0 and y=1 For(int i=1;i<=4; i=i+1) Print x X=x+y Y=x/y End of the loop OPS: a. 0 1 3 8 b. 0 1 2 4 c. 0 1 2 3 d. 1 0 2 4 23. What will be output of the following algorithm for the input x=22 and y=3? Start Declare x,y,m,n Set m=x and n=y While m not equal to n then If m greater than n M=m-1 Otherwise N=n-1 End if End while Print n OPS: a.12 b.3 c.4 d.None of the mentioned options

SORTING 11. What will be the necessary condition to get the desired element fom a given array by using the following algorithm? IF LOC=-1 do ITEM NOT FOUND do_something(DATA,N,ITEM,LOC) Initialize COUNTER set Loc =0,LOW=0,HI=n-1 [search for item] Repeat while LOW<=HI MID=(LOW+HI)/2 IF ITEM =DATA[MID] do LOC=MID Return LOC IF ITEM10 && b
If (6 rel="nofollow">5 && 12<10) Print true Else Print False The output will be ‘false’ as one expression(12<10)in if() is not true? OPS: a.42 b.124 c.256 d.336 12. What will be the output of the following pseudocode? Integer result and set num1=5,num2=7 and num3=6 If (num1>num 2) If (num1>num3) result=num1 else result=num3 else if (num2>num3) result= num2 else result=num3 Print result OPS A.Error in logic B.4 C.7 D.5

17.Consider the following pseudocode. a:=1; b:=1; while (a <=500) begin a: =2^d;

b:=b+1; end What is the value of b at the end of pseudo code? a.5 b.6 c.7 d.4 SEARCHING 20.Consider the following operations along with Enqueue and DEqueue operations on queues where k is a global parameter MultiDequeue(Q) { n=k while (Q is not empty) and (n>0) { Dequeue (Q) n = n-1 } } What is the worst-case time complexity of a sequence of ‘m’ MultiDeque()operations on an initially empty queue? OPS: a. θ(m+k) b. θ(mk) c. θ(m^2) d. θ(m) DIGITAL LOGIC FLIP FLOPS 1. How many flip-Flops are required for mod-16 counter? A. 3 B. 4 C. 6 D. 5

2. Which one correctly defines Full-Adder? OPS: a. An adder circuit having two inputs used to add two binary digits.It produces their sum and carry as input. b. An adder circuit having three inputs used to add two binary digits plus a carry.It produces their sum and carry as output. c. An adder circuit used in the least significant position when adding two binary digits with no carry into consider.It produces their sum and carry as outputs. d. An adder circuit having two inputs and two outputs LOGIC GATES 3. If we add NOT gate to the inputs of the And gate then it becomes? a. A OR gate b.A NAND gate c.A XOR gate d.A XNOR gate ANALOG AND DIGITAL CONVERTERS 4.In order to build a 3 bit simultaneous A/D converter,what is the number of comparator circuits required? OPS: a.7 b.8 c.15 d.16 MULTIPLEXER AND DEMULTIPLEXER 5.A demultiplexer can be used as a/an? OPS: a.decoder b.AND gate c.XOR gate d.latch NUMBER SYSTEM 6.The decimal number 38 in its binary form would be equivalent to? OPS: a.000110 b.101110 c.100111

d.100110

Related Documents

Capgemini
November 2019 0
Capgemini
October 2019 5
Technical
October 2019 36
Technical
November 2019 33
Technical
November 2019 37

More Documents from ""