computer programming and data structures

advertisement
FIRST YEAR
QUATION BANK
COMPUTER PROGRAMMING AND
DATA STRUCTURES
COMPUTER SCIENCE AND ENGINEERING
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
UNIT-I
1. Pseudo code is
(a) language independent code
(b) refined version of program
(c) code developed using the syntax of a specific language (d) outcome of compilation process
2. The process of repeating a group of statements in an algorithm is known as
(a) sequence
(b) iteration
(c) flow
(d) selection
3. The process of removing a bug is known as
(a) running
(b) executing
(c) debugging
(d) compilation
4. Pictorial representation of an algorithms is known as
(a) Flowchart
(b) Diagram
(c) Graphchart
(d) picture
5. What symbol is used to represent the connector
(a) parellogram
(b) rectangle with rounded end
(c) circle
(d) rectangle
6. What symbol is used to represent input/output operations in a flow chart.
(a) Rectangles
(b) Parellograms
(c) circles
(d) Rectangle with rounded end
7. Which of the following is used to perform computations on the entered data?
(a) Memory
(b) Processor
(c) input devices
(d) Output devices
8.which of the following is not an input device?
(a) plotter
(b) Scanner
(c) Keyboard
(d) Mouse
9. which of the following is not an output device?
(a) plotter
(b) Scanner
(c) printer
(d) Speaker
10. which of the following is not a translator program?
(a) Linker
(b) assembler
(c) Compiler
(d) Interpreter
11. which of the following is used as a primary memory of the computer?
(a) Magnetic storage device
(b) RAM
(c) Optical storage device
(d) magneto-optical storage device
12. which of the following is known as the ‘languange of the computer’?
(a) Programming languange
(b) High level languange
(c) Machine languange
(d) Assembly languange
13. which type of operating system allows more than one program to run at the same time in a
computer system?
(a) Multi-threading operating system
(b) iteractive operating system
(c) Multi-user operating system
(d) Multi-tasking operating system
14. which of the following is used as a secondary memory of the computer?
(a) Magnetic storage device
(b) RAM
(c) Cache memory
(d) ROM
15. which of the following converts assembly languange into machine languange?
(a) Interpreter
(b) Computer
(c) Algorithm
(d) Assembler
16. the step-by-step description of a process is called as
(a) Algorithm
(b) Flowchart
(c) program
(d) Pseudocode
16. what symbol is used to represent the start/stop?
(a) circle
(b) rectangle with rounded end
(c) parallelogram
(d) rectangle
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 2
17. the symbol for decision making statement is
(a) diamond box
(b) circle
(c) rectangle
(d) parallelogram
PART-B
1. What type of errors are checked during compilation
(a) logical errors
(b) divide by zero error
(c) run - time errors
(d) syntax errors
2. The purpose of main function is
(a) to stop program execution (b) to stop algorithm (c) to start algorithm (d) to start program
execution
3. What is the valid identifier in the following
(a) 1fdasgf
(b) @hgd12
(c) fahs%*
(d) q1234
4. What is range of char data value?
(a) -64 to 64
(b) -128 to 127
(c) 0 to 255
(d) -127 to 128
5. The minimum number of temporary variable needed to swap the contents of two variable is
(a) 3
(b) 1
(c) 0
(d) 2
6. What is output of following program ?
main( )
{
int x;
x= 4 + 2 % 8;
printf(“%d”,x);
}
(a) 6
(b) 4.25
(c) 4
(d) -6
7. When && operator is used with two conditions, conditions need to be satisfied for the expression to
be true.
(a) neither
(b) only first
(c) any one
(d) both
8. Bitwise operators cannot be performed on
(a) float
(b) long int
(c) int
(d) char
9. In the expression b=6.6/a+(2*a+(3*c)/a*d)/(2/n); which operation will be performed first?
(a) 2*a
(b) 2/n
(c) 3*c
(d) 6.6/a
10. What is the output of printf(“%d”,printf(“tim”));
(a) garbage
(b) results in a syntax error
(c) printf tim and terminates abruptly
(d) tim3
11. What is output of the following program?
main( )
{int x=15,y;
y=(x >5)? 3 : 4;
printf(“%d”,y);
}
(a) 2
(b) 4
(c) 3
(d) 1
12. Identify the loop construct:
(a) if-else
(b) goto
(c) while
(d) switch-case
13. Which of the following is a correct way of defining a symbolic constant pie in C
(a) # define pie = 22/7
(b) #define pie 22/7
(c) #define pie= 3.142
(d) # Define pie 22/7
14. The function getchar( ) is used to read
(a) a boolean value
(b) a character
(c) a string
(d) a word
15. Which of the following is a valid numeric constant
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 3
(a) 15 750
(b) 65432
(c) $1000
(d) 20,000
16. Which of the following is a scalar data type used in ‘C’
(a) double
(b) union
(c) structure
(d) array
17. Pick the operators that associates from right to left
(a) +
(b) %
(c) =
(d) 18. The operator % yields
(a) Fractional part
(b) remainder after integer division
(c) quotient value
(d) Percentage value
19. In an expression involving ||
||
operator the evaluation
(a) will be stopped if one of its components evaluates to true (b) takes place from left to right
(c) takes place from right to left
(d) will be stopped if one of its components evaluates to false
20. If a=15 then b=a <<2 will results
(a) b=3
(b) b=30
(c) b=7
(d) b=60
21. What is the output of the following program
main( )
{ int a=5, i=1; while( i ++ < a) { printf(“%d”,a); }
(a) 5,4,3,2,1
(b) 5 5 5 5 5
(c) 4,3,2,1
(d) 1 1 1 1 1
22. switch(ch)
{case ‘a’: printf(“a”);
case ‘b’: printf(“b”);
default: printf(“error”);
} if ch is assigned to the character ‘a’ then the output will be
(a) a b
(b) a b error
(c) a
(d) error
23. What would be the final value of x after execution of the following program?
# include (stdio.h)
void main()
{
int x = 1;
do while (x<=10)
{
x++;
} while (x< = 5);
printf (“\n x = %d”, x);
}
(a) x = 6
(b) x = 2
(c) 10
(d) x = 11
24. The storage area for register variables
(a) memory
(b) processor registers (c) virtual memory
(d) cache
25. The ANSI C standard recognizes maximum length of a variable up to
(a) 8 characters
(b) unlimited characters (c) 31 characters
(d) 15 characters
26. Which of the following is an incorrect variable name.
(a) else
(b) name
(c) string
(d) age
27. What is the size of long double variable
(a) 10 bytes
(b) 8 bytes
(c) 4 bytes
(d) 16 bytes
28. Variables are initialized in C, using
(a) : =
(b) >
(c) =
(d) = =
29. If a is float variable, a=5/2 will return a value
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 4
(a) 2.5
(b) 2
(c) 2.0
(d) 3
30. int a=13,b=7,c;
c=a&b what is the value of c
(a) 0000 0000 0000 0101
(b) 0000 0000 0000 0100
(c) 0000 0000 0000 0110
(d) 0000 0000 0001 0101
31. In the following, which is bitwise operator?
(a) >
(b) *
(c) |
(d) <
32. If y is of integer type variable then the two expressions.
3*(y-8)/9 and (y-8)/9*3 yield the same value if
(a) y-8 is an integer multiple of 3
(b) y is an odd number
(c) y is an even number
(d) y-8 is an integer multiple of 9
33. What is output of the following program?
main()
{int a;
float b;
a=1/2;
b=1.0/2.0;
printf(“ a=%d b=%f”,a,b);
}
(a) a=0.0 b=0. 5
(b) a=0 b=0. 5
(c) a=0.0 b= 5
(d) a=0.5 b=0. 5
34. In switch (expression) statement, the expression should evaluate to
(a) an integer
(b) a void
(c) a float
(d) a character
35. The minimum number of times the for loop is executed is
(a) 0
(b) cannot be predicted (c) 1
(d) 2
36. Which of the following cannot be used as an identifier.
(a) alphabet followed by digit (b) alphabet
(c) Keywords
(d) Library function name
37. Which of the following statements is wrong
(a) con = ‘T’ * ‘A’ ;
(b) This = ‘T’ * 20 ;
(c) 3+a=b;
(d) mes = 123.56
38. main( )
{ int a=5; float b=10,c;
c=b%a;
printf(“%f”,c);
}output is——————–
(a) gives an error
(b) 2.0
(c) 0.00
(d) 0.000000
39. int x=1,y=5;
x=++x + –y;
what is the value of x
(a) 8
(b) 6
(c) 5
(d) 7
40. Consider the segment
If(1) printf(“yes”);
else printf(“no”);
what will be the output
(a) no
(b) Unpredictable
(c) yes
(d) Error
41. Which of the following statements is false
(a) The initialization and increment parts of a for statement can be empty
(b) The body of do-while statement can be empty
(c) The expression in the condition part of a for statement can be empty
(d) The initialization part of a for statement cannot have more than one initialization
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 5
42. What is the control string for representing string
(a) %c
(b) %s
(c) %f
(d) %d
43. Every executable C program must contain a
(a) printf function
(b) scanf, printf and main functions
(c) main function
(d) scanf function
44. The individual units of a C program is known as
(a) records
(b) tokens
(c) units
(d) program
45. How many variables of the same type can be initialized at a time with the same value
(a) Three
(b) One
(c) Two
(d) any number of variables
46. Integer division results in
(a) rounding
(b) underflow
(c) overflow
(d) truncation
47. The operator with lowest priority in the list && , + , | | , < is
(a) +
(b) | |
(c) &&
(d) <
48. Which of the following shows the correct hierarchy of arithmetic operations in C
(a) ( ), / or *, - or +
(b) ( ), &&, *,/,+,(c) ( ), &&, / , *, +, (d) ( ),&&,*or / + or -;
49. The statement printf(“%d”,7);
(a) prints 0
(b) runtime error
(c) prints the value 7 (d) results in syntax error
50. The keyword ‘else” can be used with
(a) for statement
(b) if statement
(c) switch ( ) statement (d) do.. while ( ) statement
51. Give the output of the following program:
#include < stdio.h >
main()
{int I=1;
while (I < 5)
{printf(“%d”, I);
}}
/* End of Main */
(a) Warning for no return type for main ( )
(b) Print the value of I as 1
(c) Infinite loop
(d) Prints the value of I as11111
52. What is the result of 5 &&2 ?
(a) 0
(b) 2
(c) 1
(d) 5
53. ++I is a operator.
(a) Pre-decrement
(b) Pre-increment
(c) Post increment
(d) Post decrement
54. The output of the following program is
main( )
{int i=2;
printf(“%d %d %d”,i++,i,++i);
}
(a) 2 2 4
(b) 2 3 3
(c) 3 3 3
(d) 2 3 4
55. How many while statements are possible in do.... While loop?
(a) any number
(b) 2
(c) 3
(d) 1
56. The statements that prints out the character set from A-Z is, where a is an integer variable
(a) for(a=‘a’; a<=‘z’, a++) printf(“%c”; a);
(b) for(a=‘A’; a<=‘z’, a++) printf(“%c”; a);
(c) for(a=’A’ a<=‘Z’, a++) printf(“%c”; a);
(d) for(a=‘A’; a<=‘z’, a++) printf(“%c”; a);
57. How would you declare a constant of 5 called “MYCONST”?
(a) var int MYCONST=5
(b) int myconst = 5;
29. (c) constant MYCONST = 5;
(d) #define MYCONST 5
58. The constant ‘\b0 is used for
(a) tab
(b) vertical blank
(c) bell
(d) backspace
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 6
59. The equality relational operator is represent by
(a) :=
(b) ==
(c) .EQ.
(d) =
60. main( )
{ int a=0; if(a) printf(“%d”,++a); else printf(“%d”, a+=2) ; } the output is
(a) 3
(b) 1
(c) 2
(d) 0
61. x=9-12/3+3*2-1, what is the value of x
(a) -10
(b) 10
(c) 4
(d) 2
62. The function echoes the character typed on the screen
(a) getchar()
(b) gets()
(c) getche()
(d) getchr()
63. while(++I <=n);
what is the value of I when the loop completes, if the initial value of I is 1.
(a) n-1
(b) n+2
(c) n+1
(d) n
64. Which of the following is shorthand operator for a=a%b
(a) a%=b
(b) a =%b
(c) a % b
(d) a%b=a
65. Which of the following is the ternary operator in C
(a) ??
(b) ?:
(c) ::
(d) ?;
66. The effect of shifting a variable to the left by one bit position is
(a) subtract it by 2 (b) add it by 2
(c) multiply it by 2
(d) divide it by 2
67. Consider scanf(“%2d”, &n); and the input data is 3142 then n will be assigned
(a) 42
(b) 31.42
(c) error
(d) 31
68. What is the size of long double variable
(a) 8 bytes
(b) 10 bytes
(c) 16 bytes
(d) 4 bytes
69. In C every variable has
(a) a size and value (b) a type, name, value and size
(c) a type and size
(d) a name and
type
70. Associativity of arithmetic operators is from
(a) left to right
(b) middle to right
(c) middle to left
(d) right to left
71. What is the value of !0?
(a) 00
(b) 0
(c) -1
(d) 1
72. What is the output of the following program
main()
{ int i; for( i=1; i<=5; i++) printf(“%d”,i); }
(a) 4 4 4 4
(b) 5 5 5 5
(c) 1 1 1 1
(d) 1 2 3 4 5
73. C variable cannot start with
(a) an underscore (b) a number
(c) an upper case letter (d) a lower case
74. The operator ++ is called as operator
(a) increment
(b) special increment (c) decrement
(d) double addition
75. Among the following operators, whose associatively is right to left
(a) conditional expression (b) arithmetic operators
(c) logical operators
(d) bitwise
operators
76. for( i = 1;i !=5; i++)
{ printf(“%d”, i+2);} What is the output ?
(a) 3 4 5 6 7
(b) 3 4 5
(c) 3 5 7 9 11
(d) 1 2 3 4 5
77. Which operator is also referred as ternary operator.
(a) Conditional
(b) Addition
(c) Exponential
(d) Bit wise
78. A do-while loop is useful when we want that the statements within the loop must be executed.
(a) none of the above
(b) at least once
(c) more than once
(d) exactly once
79. How many keywords are there in C
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 7
(a) 34
(b) 30
(c) 31
(d) 32
80. The declaration of a variable should be done
(a) before using it (b) after using it
(c) at the time of using (d) only in the calling program
81. Which of the following is allowed in a C arithmetic statement
(a) { }
(b) [ ]
(c) / /
(d) ( )
82. What function is appropriate for accepting a string?
(a) getch ( )
(b) gets( )
(c) getche ( )
(d) scanf ( )
83. The purpose of the following fragment
B=S+B
S=B-S;
B=B-S;
Where S,B are two integers is to
(a) negate the contents of S and B
(b) swap the contents of S and B
(c) transfer the contents of S to B
(d) transfer the contents of B to S
84. main( )
{ float a;
int x = 6; y = 4;
a = x/y;
print (“%f”,a)
}what is the output
(a) error
(b) 1.5
(c) 0.5
(d) 1.00
85. What is output of following Program?
main( )
{int x=10,y=5,p,q ;
p= x> 9 ;
q= x > 3 && y != 3 ;
printf( “p=%d q=%d ” ,p,q) ;
}
(a) p =0 q = 0
(b) p = 0 q = 1
(c) p = 1 q= 0
(d) p = 1 q = 1
86. Hierarchy decides which operator
(a) consumes more CPU time
(b) operates on large number (c) is used first (d) is most
important
87. The conditional operators “ ? :” is similar to
(a) nested if
(b) if-then-else
(c) while
(d) do-while
88. Which of the following statements cannot be used to transfer the control unconditionally to a
different statement
in a ‘C’ program
(a) continue
(b) for
(c) break
(d) goto
89. C language has been developed by
(a) Martin Richards (b) Ken Thompson
(c) Peter Norton
(d) Dennis Ritchie
90. Which of the following is a primary data type?
(a) int
(b) enum
(c) array
(d) typedef
91. Output of printf(“%f”,3/4) is———
(a) 0.00
(b) gives an error
(c) 0
(d) 0.75
92. Every C Program Statement must be terminated with a
(a) .
(b) #
(c) ;
(d) !
93. Which of the following is/are syntactically correct?
(a) for();
(b) for(;);
(c) for(,);
(d) for(;;);
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 8
UNIT-II
1. The index or subscript value for an array of size ‘n’ ranges from
(a) 1 to n-1
(b) 0 to n-1
(c) 1 to n
(d) 0 to n
2. If we don’t initialize a static array, what will be the elements set to:
(a) 0
(b) a floating point number
(c) an undetermined value
(d) character constant
3. Which of the following is not a storage class
(a) external
(b) automatic
(c) register
(d) define
4. int cal sum(int a, int b);
In the above, int at the beginning indicates
(a) name of function
(b) both function arguments are integer
(c) return type of function
(d) received type of function
5. When a function is recursively called, all automatic variables are
(a) stored in a stack
(b) stored in a list
(c) stored in queue
(d) stored in an array
6. ‘void’ means
(a) something not known
(b) 0
(c) 1
(d) nothing
7. What is the output of
main()
{
int x, change (int);
x = 20;
change (x);
printf (“%d”, x);
return 0;
}
change (int x);
{
x = 10;
printf (“%d”. x);
}
(a) 10 30
(b) 20 20
(c) 10 10
(d) 10 20
8. Which of these complier directives access to the print function
(a) #include
(b) #define print
(c) include stdio.h;
(d) #include conio.h;
9. The number of elements in array declaration
(a) dynamically identifies based on largest index used in program
(b) assume default size as ‘0’
(c) requires to be specified
(d) does not require to be specified
10. Identify the incorrect declaration of arrays from the following
(a) int a[50];
(b) float values[10][20];
(c) double a[50];
(d) int score[10,15];
11. The array is declared as float a[5]; and the memory address of a[0] is 4056. What is the memory
address of a[3].
(a) 4056
(b) 4056
(c) 4059
(d) 4068
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 9
12. Two dimensional array elements are stored
(a) system dependent (b) in row major order (c) complier dependent (d) in column major order
13. How many values a function can return at a time
(a) only one
(b) depends on the system
(c) infinite values
(d) 2
14. When compared to call by value, the call by reference is in execution
(a) equal
(b) fast
(c) slow
(d) neither slow nor fast
15. Which of the following statement is wrong with respect to a storage class
(a) it specifies the defualt initial value
(b) it specifies the life of a variable
(c) by defualt a storage class is static
(d) if specifies where variable is stored
16. Symbolic constants are defined as
(a) #define s1 s2;
(b) #define s1=s2
(c) #define s1 s2
(d) #define s1=s2;
17. One dimensional array is known as
(a) set
(b) vector
(c) matrix
(d) table
18. The storage area for register variables
(a) processor registers
(b) cache
(c) virtual memory
(d) memory
19. In a program a function can be called
A. one time
B. two times
C. three times
D. any no.of times
20. A function gets called when the function name is followed by
A. comma( ,)
B. Period ( .)
C. Colon( :)
D. Semi colon(;)
21. Which is not true among the following
A. Brazil( ) is a user defined function
B. Printf( ) is a Library function
C. A function can be called from another function
D. A function can be defined in another function
22. Array elements can be accessed using
A. Tree
B. Pointer
C. stack
D. Queue
23. An array is represented in Memory by using a
A.Sequential map
B. Parallel map
C. element map
D. circular map
24. The general form of array declaration is
A. Type array name[type]
B. Type variable name[size]
C. Type data name[type]
D. Type data name[size]
26. int b[5];
main( )
{ static int a[5];
int I;
for(I=0;I<5;I++)
printf("%d%d",b[I],a[I]);
}output is
A. 0000.5times
B. error
C. garbage values
D. 000.10times
27. The amount of storage required for holding the elements of array depends on
A. size
B. Memory
C. Type and size
D. Type
28.How much memory the compiler reserves for each integer array element
A. 6bytes
B.8bytes
C.4bytes
D2bytes
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 10
29. main( )
{ static int a[ ]={ 10,20,30,40,50};
int j;for(j=0;j<5;j++)
{printf(%d,a[j]);
a++;
}
} output is
A. 10 20 30 40
B. 10 20 30
C. 10 20
D.compilier error
30. Array is used to represent the following
(a) A list of data items of different data type
(b) A list of data items of real data type
(c) A list of data items of same data type
(d) A list of data items of integer data type
31. Register variable are active
(a) outside the function
(b) throughout the program
(c) only in the function where it is defined
(d) surrounding of that function.
32. The function sqrt() is part of header file.
(a) math.h
(b) iostream.h
(c) conio.h
(d) stdio.h
33. What is the output of the following program
# includes
# include
void main()
{int a1[5] ={1};
int b = 0, k = 0;
for (b=0; b<=4; b++)
printf (“%d” , ++ a1[0]);
}
(a) 11111
(b) 23456
(c) 12345
(d) 12222
34. In a multidimensional array with initialization
(a) no demension must be omitted
(b) the left most dimension may be omitted
(c) both leftmost and right most may be omitted
(d) the right most dimension may be omitted
35. The statement used to send back any value to the calling function is
(a) exit
(b) return
(c) break
(d) continue
36. The statement used to send back any value to the calling function is
(a) continue
(b) exit
(c) break
(d) return
37. A static variable is one
(a) which cant be initialized
(b) which is same as an automatic variable but it is placed at the head of the program
(c) which is initialized once and cant be changed at run time
(d) which retains its value through out the life of the program
38. C does no automatic array bound checking. This is
(a) Disadvantage of C
(b) false
(c) Neither advantage nor disadvantage
(d) Advantage of C
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 11
39. The following program
main( )
{static int a[ ] = { 7, 8, 9 };
printf(“%d”, a[2] = 2[a] + a[2]);
}
(a) will compile successfully
(b) results in segmentation violation error
(c) result is buss error
(d) runtime error
40. What is the output of the following program?
void main()
{ char name[4] =
{‘R’, ‘
A’, ‘
V’ ‘
I’ };
printf (“%s”, name);
}
(a) RAVI followed by a garbage value (b) RAVI
(c) RAV
(d) only garbage value
41. The library function sqrt operates on a double pression argument and I is an integer variable, which
one of the
following calls would compute sqrt(I)?
(a) sqrt((double)I);
(b) (double) (sqrt(I)); (c) sqrt(I);
(d) (double) sqrt(I);
42. main()
{printf(“welcome to c programming\n”);
main();
}output of the program code
(a) Infinite loop
(b) Runtime error
(c) welcome to c programming (d) compile time error
43. What will be the output of the following program?
void main()
{
char x[ ]={‘s’, ‘a’, NULL };
printf (“\n %d”, sizeof (x));
}
(a) 2
(b) 3
(c) 0
(d) 1
44. The variables which are declared outside the program are called
(a) global variables
(b) formal variables
(c) local variables
(d) register variable
45. #include is a directive
(a) processor
(b) complier
(c) pre-compiler
(d) pre-processor
46. Array elements are stored in
(a) either in row major or column major order
(b) in diagonal order
(c) row major order
(d) column major order
47. Under which of the following conditions,the size of the array need not be specified?
(a) when it is a formal parameter
(b) when the compiler is smart
(c) when initialization is a part of definition
(d) when it is a declaration
48. If actual arguments are more than the formal arguments then
(a) extra actual arguments are discarded
(b) a compilation error
(c) extra actual arguments are initialized to garbage values
(d) extra actual arguments are initialized to zero
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 12
49. What is the output of the following program?
main()
{int x , y;
x = 10; y = 100;
change (x,y)
printf (“%d, %d”, x,y);
} change (
int x, int y);
{int k;
k = a; a = b; b = k;
}
(a) 10, 100
(b) 100, 100
(c) 10, 10
(d) 100, 10
50. An external variable definition can appear in
(a) only two files
(b) only three files
(c) only one file
(d) more than one file
51. For the array declaration int a[5]; What is the amount of storage required
(a) 20 bytes
(b) 5 bytes
(c) 10 bytes
(d) 5 bits
52. The default return type of a function is
(a) float
(b) Integer
(c) character
(d) double
53. What is the output of the following program
void main()
{int x = 2;
sqr(x);
printf(“%d”, x);
}sqr(x)
{int y;
y = x * x;
printf (“%d”, y);
}
(a) 2 2
(b) 4 4
(c) 4 2
(d) 2 4
54. What is the output of the following program
main()
{static int y;
printf (“%d\n”, y);
}
(a) compilation error (b) run-time error
(c) 0
(d) undefined
55. An array which contains two subscripts, to represent each element is called as
(a) two dimensional
(b) multidimensional (c) three dimensional (d) one dimensional
56. main()
{ char name[5];
scanf(“%s”,name);
printf(“%s”, name);
}if Program is the given as input, what will be the o/p of the program;
(a) Progr
(b) program
(c) Prog
(d) Runtime error
57. The parameters of the called function are called
(a) casual parameters (b) actual parameters (c) usual parameters (d) formal parameters
58. output of the following program is
#include< stdio.h>
main()
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 13
{int a,count;
int funct( int count);
for( count=1;count<=5;++count)
{a=funct1(count);
printf(“%d”,a);
}}
int funct1(int x)
{int y;
y= x*x;
return(y);
}
(a) 1 4 9 16 25
(b) 36
(c) 25
(d) 25 9 16
59. Register variables can hold ———– values
(a) float
(b) int
(c) complex
(d) double
60. The parameter passing mechanism for an array is
(a) Call by value
(b) Call by value-result (c) call by name
(d) Call by reference
19. What kind of variable is suitable to count how many times a function is called
(a) register
(b) external
(c) auto
(d) static
61. An array can have dimension(s).
(a) single
(b) multiple
(c) three
(d) double
62. If we don’t initialize a static array, what will be the elements set to:
(a) character constant (b) a floating point number
(c) 0
(d) an undetermined value
63. main() is
(a) user defined function
(b) friendly function
(c) library function
(d) member function
64. If the value of the formal argument is changed in the called function; the corresponding change in
the calling
function, if it is call by value
(a) machine dependent
(b) does not reflects (c) unpredictabl e
(d) reflects
65. Which of the following statement is wrong with respect to a storage class
(a) if specifies where variable is stored
(b) it specifies the defualt initial value
(c) it specifies the life of a variable
(d) by defualt a storage class is static
66. What is the difference between the 5’s in the below expressions.
int num[5];
num[5]=10;
(a) Both specify array size
(b) First is array size, second is particular element
(c) First is particular element , second is array size
(d) First is particular element , second is type
67. Under which of the following conditions,the size of the array need not be specified?
(a) when it is a formal parameter
(b) when it is a declaration
(c) when initialization is a part of definition
(d) when the compiler is smart
68. Automatic variable are active
(a) outside the function
(b) only in the function where it is defined
(c) surroundings of that function
(d) throughout the program
69. Which of the following is the symbol for preprocessor
(a) <>
(b) $
(c) *
(d) #
70. Which is a self contained block of code that performs a particular task
A.Stack
B. Array
C. Pointer
D. Function
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 14
PART-B
1. A string is an array of
(a) integers
(b) floating point numbers
(c) characters
(d) boolen values
2. A string in the ‘C’ language is represented by enclosing a sequence of characters in
(a) flower brackets
(b) double quotes
(c) parenthesis
(d) single quotes
3. What is wrong with the following program
main() { char m1[9]= “message1”; char m2[9]=“message2”; m2=m1;
printf(“msg is %s”,m2); }
(a) array cannot be initialized as above
(b) array is not a left value and so cannot be assigned to
(c) char array cannot be printed directly using printf
(d) program compiles without error, but prints an unpredictable value
4. The function strrev( ) the actual string in the array
(a) will reverse
(b) will not reverse
(c) may not reverse
(d) may reverse
5. char x[10]=“whatisit”;
char *y=“whatisit”;
Pick the correct answer
(a) The output of puts(x) and puts(y) will be different
(b) The output of puts(x) and puts(y) will be same
(c) The output of puts(y) is implementation dependant
(d) The outputs of pulse(x) and puls(y) compiler dependant
6. The strcat( ) function is used for
(a) Concatenation
(b) Multiplication
(c) Joining
(d) Addition
7.main( )
{int *j;
{ int i=10; j=&i;}
}
A. 7
B. 10
C. 5
D. compiler error
8. The general format of realloc function is
A. ptr=realloc(size)
B. ptr=realloc(ptr)
C. ptr= realloc(ptr,newsize)
D. ptr= realloc(free)
9. Which of the following standard file pointer is used for standard auxiliary device
A. std prn
B. std aux
C. std io
D. std conio
10. Array elements can be accessed using
A. pointer
B. Tree
C. stack
D. queue
11. Address x[ I ]=where I is of type int
A. Base address + ( I )
B. Base address + (I+ scale factor of int)
C. Index address + ( I + scale factor of int)
D. Index address + ( I )
12. The pointer accessing method is _________ than Array indexing
A. same efficient
B. slower
C. faster
D. less efficient
13. The operators <and> are called
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 15
A. in direction
B. in out direction
C. out direction
14. main( )
{int a=5,b,*c;c=&a;b=*c;
printf("\n value of a=%d & b=%d",a,b,)}
A. a=3,b=3
B. a=4,b=4
C. a=6,d=6
15 func(a,b)
int a,b;
{return(a=(a= =b));
}
main( )
{
int process( ),func( );
printf("The value of process is %d! \n", process(func,3,6));
} process(pf,val!,val2)
int (*pf) ( ); int val1,val2;
{
return((*pf)(val1,val2));
}
the value of process is
A. 3!
B. compiler error
C.0!
16. main()
{char s[6]="HELLO"
printf("%d",s[6]);
}
output is
A. compiler error
B. 0
C. 34
17. main()
{ int *j;
{ int i=10;j=&i;
}printf("%d",*j);
}
A. 10
B. 20
C. 15
18. main( ) { int arr[ ]={'A', 'B', 'C', 'D'}
int I; for( I=0; I<3; I++)
printf("%d",arr[I]);
}
A. 65 66 67
B. A B C D
C. 65 66 67 68
19. #include<stdio.h>
main( )
{ char s[ ]={'a', 'b','c',' \n ', 'c', '\0'};
char *p, *str, *str1;
p=&s[3];str=p;str1=s;
D. redirection operators
D. a=5,d=5
D. 1!
D. 45
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
D. 5
D. A B C
Page 16
printf("%d",++*p+ ++*str1-32);
}
A. b
B. a
C. Compiler error
D. M
20. Which of the following is used with Printf( ) function for printing the Address of a variable
A. %d
B. %u
C. %f
D. %c
21. Which of the following allows a program to read from or write to files at Command prompt
A. in out direction
B. in direction
C. out direction
D. redirection
22. main( )
{ char *str1="abcd";
char str2[ ]="abcd";
printf("%d%d%d", sizeof(str1),sizeof(str2),sizeof("abcd"));}
A. 2 5 5
B. 5 5 2
C. Compiler error
D. 5 2 5
23. The variable can be accessed by a Pointer using the Operators
A. & and B. & and *
C. // and ++
D. & and +
24. A block of memory is allocated using the function
A. falloc( )
B. dalloc( )
C. malloc( )
D. calloc( )
25. In which of the following header files the standard file pointers have been defined
A. stdconio.h
B. stdpointer.h
C. stdstream.h
D. stdio.h
26 Which of the following function places cursur at appropriate position on the screen
A. go to( )
B. goto xy( )
C. go ( )
D. goto screen( )
27. The process of call a function using pointers to pass the address of varaibles is known as
A. call by argument
B. call by parameter C. call by value
D. call by reference
28. The arguments of calling functions are called
A. parameter arguments
B. Function call
C. Actual arguments D. Formal arguments
29. Which of the following data structure used to process multiple elements with the same data types
when number of such elements are know
A. Graph
B. Array
C. Atack
D. Quene
28. Which is not true among the following
A. Pointers decrease the Execution speed
B. Pointers are more efficient the arrays
C. Pointers are more efficient in handling the data tables
D. Pointers reduces the length and complexity of a program
29. Which of the following function takes the total number of data and size each data
A. free
B. realloc
C. malloc
D. calloc
30. A character array always ends with
A. Full stop
B. NULL character
C. &
D. ?
31. The indirection( * )operator is also called as
A. deference operator
B. Star operator
C. Inference operator D. bit wise operator
32. Struct {int I; float J;) *s; if the address stores in S is 2000, what is the value of s+3?
A. 2009
B. 2000
C. 2006
D. 2012
33. void main( )
{ int const * p=5;
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 17
printf("%d",++(*p));}
A. Compiler error
B. 10
C. 5
D. 15
34. Pointer to pointer is also called as
A. Pointer function
B. Pointer structure
C. Pointer direction
D. pointer indirection
35. main( )
{ char *p; p="HELLO";
printf("%c \n ",*&*p);
}
A. HE
B. HELLO
C. HELL
D. H
36. When we pass address to a function, the parameters recieving the address should be
A. Pointers
B. Union
C.Functions
D. Structures
37. The general format of calloc is
A. ptr=(cast type *)calloc(byte size)
B. ptr=calloc(cast type*)bytesize
C. ptr=(cast type*)
D. ptr=(cast type*)calloc(n,elementsize)
38. The first parameter in he command line is always
A. struct name
B. Pointer name
C. program name
D. function name
39. main( )
{
char *p; p="%d \n";
p++;
p++;
printf(p-2,300);
}
A. 296
B. 300
C. 298
D. compiler error
40. Dynamic memory allocation in array results in
(a) allocation of memory at compile time
(b) allocation of memory at file saving time
(c) allocation of memory at runtime
(d) allocation of memory at debugging time
41. If the first string and the second string both are identical, then strcmp function returns
(a) a value of 0
(b) either 1 or 0
(c) a value of 1
(d) any positive integer
42. What is the objective of the string handling function strncmp().
(a) Compares only last n characters in both argument
(b) Compares two string only if length of one string is exactly n
(c) Similar to strcmp() function
(d) Compares only first n characters in both argument
43. Give the output for the following:
# include
main( )
{ char arr[10];
int ctr =0;
printf(“Enter a Sting:”);.
gets(arr);
while(arr[ctr]!=\‘0’)
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 18
{ctr + + ;
}printf(“%d”,ctr);
}
(a) length of the string only when it is less than 9 characters length
(b) String
(c) String length
(d) length of the string only when its length is 10 characters
45. Literal means
(a) A string constant (b) An alphabet
(c) A character
(d) A string
46. What is the use of the strlen( ) function
(a) finds the length of the string
(b) string comparison (c) string concatenation
(d) copies one string into another
47. The following function is used to count and return the number of characters in a given string
(a) strcat()
(b) strrev()
(c) strcmp()
(d) strlen()
48. Consider the following program
main()
{ char str[10]; scanf(“%s”,str); printf(“%s”,str); } The error in the above program is
(a) the format control for the string variable is not %s
(b) no error in the program
(c) memery has not been allocated for the variable str
(d) the parameter str to scanf is passed by value, it should be a address
49. What is the use of strcmp( ) function
(a) finds the length of the string
(b) string comparison
(c) copies one string into another
(d) string concatenation
50. How many memory management functions are there in C
a. 4
b. 3
c. 2
d. 1
51. Which of the following is not a C memory allocation function
a. alloc( )
b. calloc( )
c. free
d. malloc()
52. All memory management functions are found in
a. stdlib.c
b. stdio.h
c. conio.h
d. math.h
53. Which of the memory function allocates a contiguous memory
a. malloc( )
b. calloc( )
c. release( )
d. free( )
54. Return type of a malloc( ) function is
a. int
b. float
c. char
d. void
UNIT-IV
1. The body of the stucture should end with
A. semicolon( ; )
B. comma( , )
C. colon (:)
D. period(.)
2. Example of a self-referential Structure
A. Elements in a stack
B. Nodes in a Tree
C. Elements in a quene
D. Nodes in a Linked list
3. Which of the following unary operator is used to specify the size of the structure
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 19
A. Length( )
B. unary( )
C. sizeof( )
D. struct( )
4. The general formate of sending a copying of entire structure to the function is
A. Structure name(function variable name)
B. Function name (structure variable name)
C. structure name(function )
D. function name(structure)
5. In arrays of structures the members are referred using
A. *
B. ->
C. &&
D. ( . )
6. enum colors{BLACK,BLUE,GREEN}
main( )
{ printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);}
A. 0,1,2
B. compiler error
C. 0,1
D. black
7. Struct a{int I;
float j;
}; Which of the following syntax is correct to declare a structure variable
A. struct union a;
B. union struct a;
C. union a t;
D. Struct a t;
8. Which of the following are Parameters supplied to a program when te program is invoked
A. Command line argument
B. parameter argument
C. reference argument
D. Actual argumenent
9. Structure elements can be accessed through a pointer to a sructure Using the operator
A. ( , )
B. &
C. *
D. ->
10. struct{ int I;
float j; } s; size(s) will be
A. 6 bytes
B. 0 bytes
C. 2 bytes
D. 4 bytes
11. The body of union should end with
A. colon( :)
B. Period ( . )
C. Semicolon( ; )
D. comma( , )
12. If struct member is array, then an individual array element can be accessed by writting a
variable
A. Stucture(member)
B. member(datatype)
C. member(structure)
D. member(expression)
13. Which of the following is a costruct that allows memory to be shared by different types of
data
A. union
B. struct
C. Bit field
D. typedef
14. Which of the following sign is used to access the structure members
A. ->
B. &&
C. ( . )
D. *
15. In union all members use
A. no location
B. same location
C. different location
D. no stroage
16. struct aaa{ struct aaa *prev;
int i;
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 20
struct aaa*next;};
main( )
{
struct aaa abc,defghi,jkl;
int x=100;
abc.i=0;abc.prev=&jkl;abc.next=&def;
def.i=1 ;def.prev=&abc;def.next=&ghi;
ghi.i=2 ;ghi.prev=&def ;ghi.next=&jkl;
jkl.i=3 ;jkl.prev=&ghi; jkkl.next=&abc;
x=abc.next->next prev->next-> i;
printf("%d",x);}
A.2
B. Compiler error
C. 3
D. 4
17. The typedef Statement is used for
A. Declaring user defined data types
B. Declaring variant data types
C. for assigning values to vareiables
D. for type casting of variables
18. Portion of memory to be shared by different types of data is
A. field
B. array
C. struct
D. union
19. Each field in a structure can be accessed and manipulated using
A. variables and members
B. variables and operands
C. operands and arguments
D. Expressions and operators
20. #include<stdio.h>
main( )
{
struct xx
{ int x=3; char name[ ]="hello";
};
struct xx *s=malloc(sizeof(strct xx));
printf("%d",s->x);
printf("%s"s->,name);
}
A. Compiler error
B. hello
C. xx
D. name
21. The internal Representation of bit field is
A. Human independent
B. Machine dependent
C. Human dependent
D. Machine independent
22. puts(argv[0])prints
A. argv
B. the number of command line arguments
C. the name of executable code file
D. the name of the source code file
23. A type defined Structure starts with the keyword
A. Case
B. Void
C. typedef
D. Struct
24.Self referential structure means
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 21
A. Refers to any structure
B. Refers to the same structure
C. Refers to different structure
D. Refers to pointers
25.#include<stdio.h>
main( )
{
struct xx
{ int x=3; char name[]="hello";};
struct xx *s; printf("%d",s->x);printf("%s",s->name);}
A. he
B. hello
C.compiler error
D.hell
26. Which of the following is not true
A. pointers can be used for addressing the bit field directly
B. bit field provides exact amount of bits reserved for storage value
C. Unions can apper in arrays and structures
D. Unions are used to conserve memory
27. The type def Statement is used for
A. Declaring user defined data types
B. declaring variant variables
C. for assigning values to variables
D. for type casting of variables
28. The keyword is used to define enumerated data type
(a) array
(b) enum
(c) typedef
(d) struct
PART-B
1. Which of the following function is used for storing information in a disk file
A. fprintf( )
B. fscanf( )
C. scanf( )
D. printf( )
2. The general format of feof function is
A. feof(fp,"controlstring");
B. feof("control string",list);
C. feof(fp,list);
D. feof(fp);
3. Which of the following sets the file postion marker to the starting of the file
A. fseek(ptr)
B. fseek(ptr,seek_cur);
C.fseek(ptr,0,SEEK_SET);
D. fseek(ptr,0,SEEK_CUR);
4.The general format of fprintf( ) function is
A. fprintf(fp,list)
B. fprintf(control string,list)
C. fprintf(fp,controlstring,list)
D. fprintf(fp, "controlstring")
5.Which of the following function are used to detect I/o errors in the files
A. feof& ferror
B. f i/0 & fof
C. eof & error
D. fofe & f i/o
6. Which of the following mode opens a binary file in write mode
A. feof( )
B. putw( )
C. getw( )
D. wb (write)
7. Which of the following is a set of records that can be accessed through the set of Library
Functions
A. File
B. Algorithm
C. program
D. Data
8. The general format of realloc function is
A. ptr=realloc(ptr,newsize)
B. ptr=realloc(ptr)
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 22
C. ptr=realloc(size)
D. ptr=realloc(free)
9. The EOF is Equivalent to
A. 1
B. 2
C. 0
D. -1
10. "a+" is used to
A. read a file
B. read and append a file
C. append a file
D. Write into a file
11. The general formate of fscanf( ) is
A. fscanf(fp,controlstring,list);
B. fscanf(fp,list);
C. fprintf(fp, controlstring, list);
D. fscanf(fp,controlstring);
12. The function that is used to detect the end of file is
A. feof( )
B. fgetch( )
C. go ( )
D. goto screen( )
13. main( )
{ FILE *fp;
fp=fopen("test", "r");
}
A. A structure which contains a char pointer to first character in the file
B. The first character in the file
C. The name of the file
D. The last character in the file
14. The fscanf( ) statement reads data from
A. key board
B. file
C. scanner
D. program
15. Which of the following is used to read a character from the keyboard rather than for a file
A. ch=fputc(std in)
B. ch=fget(std in)
C. ch= fput(std in)
D. ch= fgetc(std in)
16. Which of the following function is used to remove the specified file from the disk
A. rewind( )
B. unlink( )
C. getw( )
D. fseek( )
17. Which of the following function is used to set the record pointer at the beginning of the file
A. putc( )
B. getw( )
C. rewind( )
D. gets( )
18.Which of the following operations can be performed on the "TEST.C" if it is successfully
opened using the statement
FILE *fp
fp=fopen("TEST.c","r+");
A. writing
B. Appending
C. Reading
D. appending and writing
19. The general format of free function is
A. free(ptr)
B. free(ptr,size)
C. free(size)
D. free(new size)
20. The C library that contains the Prototype statement for the file operation is
A. proto.h
B. file.h
C. stdio.h
D. stdlib.h
21.Which of the following is a string of characters that make up a vanu name for operating
system
A. header name
B. period name
C. file name
D. extension name
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 23
22. Which of the following standard file pointer is used for atandard Auxiliary device
A. std conio
B. std aux
C. std prn
D. std io
23."r+" is used to open a file in
A. read and write mode
B. append mode
C. write mode
D. read mode
24. The function that reads the next charecter from the standard input stream and return its value
is
A.Getc
B.Fgetc
C.Readchar
D.Getchar
25.Which of the following function is used to close all the files and returns number of files
closed
A. fclose(fp)
B. close( )
C.fcloseall( )
D. closeall( )
26. putchar() and getchar() are both
(a) control statement
(b) type declaration statements
(c) assignment statements
(d) input and output statements
UNIT-V
1. The process of arranging records in ordered manner is called
(a) sorting
(b) searching
(c) indexing
(d) None of the above
2. The process of finding a particular record is called
(a) sorting
(b) searching
(c) indexing
(d) None of the above
3. In this type of searching the records must be sorted
(a) linear search
(b) binary search
(c) selection search (d) none of the above
4. The time complexity of binary search in average case is
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn) 5.The time
complexity of bubble sort in best case is
a) O(n)
b) O(n2)
c) O(nlogn)
d) O(logn) 6.The time
complexity of selection sort is
a) O(n)
b) O(n2)
c) O(nlogn)
d) O(logn) 7.The time
complexity of insertion sort is
a) O(n)
b) O(n2)
c) O(nlogn)
d) O(logn) 8.The time
complexity of quick sort in best case is
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn)
9.The time complexity of quick sort in worst case is
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn)
10.The time complexity of bubble sort in worst case is
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn) 11.The time
complexity of selection sort in worst case is
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn) 12.The time
complexity of insertion sort in worst case is
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn) 13.The time
complexity of quick sort in worst case is
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn)
14.The time complexity of merge sort in worst case is
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 24
a) O(n)
b) O(n2)
c) O(nlogn) d) O(logn) 15.Quick sort is
an application of
a) partition exchange sort
b) partition sort
c) greedy method
d)divide and conquer
16.Merge sort is an application of
a) greedy method b)divide and conquer c) a&b d) none
17.The space complexity of Quick sort in average case is
a) 0
b)O(n)
c) O(nlogn)
d) O(logn)
18.Binary search is effective only when the elements are in
a) ascending order b) descending order c) a& b
d) jumbled order
19. The running time T(n), where `n' is the input size of a recursive algorithm is given as
followsT(n)=c+T(n-1),if n>1
d, if n≤ 1
The order of this algorithm is
a. n2
b. n
c. n3
d. nn
20. The concept of order(Big O) is important because
a. it can be used to decide the best algorithm that solves a given problem
b. It determines the minimum size of a problem that can be solved in a given system, in a
given amount of time
c. It is the lower bound of the growth rate of the algorithm
d. It is the average bound of the growth rate of the algorithm
21. The concept of order(Big O) is important because
a. it can not be used to decide the best algorithm that solves a given problem
b. It determines the maximum size of a problem that can be solved in a given
system, in a given amount of time
c. It is the lower bound of the growth rate of the algorithm
d. It is the average bound of the growth rate of the algorithm
23. The time complexity of an algorithm T(n), where n is the input size is given byT(n)=T(n1)+/n, if n>1
=1 otherwise
The order of the algorithm is
a. log n
b. n
c. n2
d. nn
24. The running time of an algorithm is given byT(n)=T(n-1)+T(n-2)-T(n-3), if n>3
= n otherwise
The order of this algorithm is
a. n
b. log n
c. nn
d. n2
25. If n=4,then the value of O(log n) is
a. 1
b. 2
c. 4
d. 8
26. If n=4,then the value of O( n2) is
a. 4
b. 16
c. 64
d. 512
27. The average time complexity of insertion sort is
a. O(n2)
b. O(n)
c. O(1)
d. O(log n)
28. The running time of an algorithm is given byT(n)=T(n-1)+T(n-2)-T(n-3), if n>3
= n otherwise. What should be the relation between T(1),T(2) and T(3) so that its order is
constant.
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 25
a. T(1)=T(2)=T(3)
b. T(1)+T(3)=2T(2)
c. T(1)-T(3)=T(2)
d. T(1)+T(2)=T(3)
29. The order of the algorithm that finds a given Boolean function of `n' variables ,
produces a is
a. constant
b. linear
c. non-linear
d. exponential
30. If n= 8, then the value of O(1) is
a. 1
b. 2
c. 4
d. 8
31. You are asked 15 randomly generated numbers. You should prefer
a. bubble sort
b. quick sort
c. merge sort
d. heap sort
32. Which of the following sorting algorithms does not have a worst case running
time complexity of O(n2)?
a. Insertion sort
b. Merge sort
c. Quick sort
d. Bubble sort
33. There are 4 different algorithms A1,A2,A3,A4 to solve a given problem with the
order log(n),log(log(n)),nlog(n),n/log(n) respectively. Which is the best algorithm?
a. A1
b. A2
c. A3
d. A4
34. You want to check whether a given set of items is sorted. Which of the following
sorting methods will be the most efficient if it is already in sorted order?
a. bubble sort
b. selection sort
c. insertion sort
d. merge sort
35. The way a card game player arranges his cards as he picks them up one by one ,
is an example of
a. bubble sort
b. selection sort
c. insertion sort
d. merge sort
36. Which of the following sorting methods sorts a given set of items that is already
in sorted order or in reverse sorted order with equal speed?
a. Heap sort
b. Quick sort
c. Insertion sort
d. Selection sort
37. Which of the following sorting methods will be the best if number of swapping
done, is the only measure of efficiency?
a. bubble sort
b. insertion sort
c. selection sort
d. heap sort
38. As part of the maintenance work, you are entrusted with the work of
rearranging the library books in a shelf in proper order, at the end of each day. The
ideal choice will be
a. bubble sort
b. insertion sort
c. selection sort
d. heap sort
39. Sorting is not useful for
a. report generation
b. minimizing the storage needed
c. making searching easier and efficient
d. responding to queries easily
40. A machine took 200 sec to sort 200 names, using bubble sort. In 800 sec. it can
approximately sort _ _ _ _ _ _ _ _ _ names
a. 400
b. 800
c. 750
d. 1600
41. A machine needs a minimum of 100 sec. to sort 1000 names by quick sort. The
minimum time needed to sort 100 names will be approximately
a. 50.2 sec
b. 6.7 sec
c. 72.7 sec.
d. 11.2 sec.
42. A sorting method with _ _ _ _ _ _ _ _ is the most efficient method
a. O(log n)
b. O(n)
c. O(1)
d. O(n2)
43. The average successful search time for sequential search on 'n' items is
a. n/2
b. (n-1)/2
c. (n+1)/2
d. log(n)+1
44. The order of the binary search algorithm is
a. n
b. n2
c. nlog(n)
d. log(n)
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 26
45. Which of the following algorithm design technique is used in the quick sort
algorithm?
a. Dynamic programming
b. Backtracking
c. Divide and conquer
d. Greedy method
46. The average successful search time taken by binary search on a sorted order
array of 10 items is
a. 2.6
b. 2.7
c. 2.8
d. 2.9
47. The number of swapping needed to sort the numbers 8,22,7,9,31,19,5,13 in an
ascending order, using bubble sort is
a. 11
b. 12
c. 13
d. 14
48. Given two sorted list of size 'm' and 'n' respectively. The number of comparisons
needed by the merge sort algorithm will be
a. m x n
b. maximum of m,n c. minimum of m,n d. m+n-1
49. For merging two sorted lists of sizes m and n into a sorted list of size m+n,
requires _ _ _ _ _ _ _ _ no.of comparisons
a. O(m)
b. O(n)
c. O(m+n)
d. O(log(m)+log(n))
50. The average number of comparisons performed by the merge sort algorithm , in
merging two sorted lists of length 2 is
a. 8/3
b. 8/5
c. 11/7
d. 1/16
51. Merge sort uses
a. divide and conquer strategy
b. backtracking approach
c. heuristic approach
d. greedy approach
PART-B
1.Towers of Hanoi is an application of
a) stack
b) queue
c) linked list
d) dequeue
2.The data structure used in railway reservation is
a) stacks
b) queues
c)priority queues
d) binary tree
3. The recursive functions are evaluated using
a) stacks
b) queues
c)priority queues
d) binary tree
4.Which of the following is not a linear data structure
a) stacks
b) queues
c)linked list
d) binary tree
5.In evaluation of postfix expression the data structure used is
a) stacks
b) queues
c)arrays
d) binary tree
6.Linked list uses ____________ type of memory allocation
a) static
b)random
c)dynamic
d)compile time
7.Linked lists uses ____________ type of structures.
a) nested structures
b) self referential structures
c) simple structures
d)unions
8. The linked list field(s) are
a. data
b. pointer
c. pointer to next node
d. data and pointer to next node
9. The linked list structure is defined as
a. struct node
{
int item;
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 27
struct node *next;
};
b. node
{
int item;
struct node *next;
};
c. struct node
{
int item;
node *node;
};
d. node
{
Int item;
node next;
};
10. Each item in the list contains a �link� to structure containing the _ _ _ _ _ _ _ item
a. previous
b. next
c. present
d. last
11. A list refers to a set of items organized _ _ _ _ _
a. sequentially
b. exponentially
c. non-sequentially d. factorially
12. Each structure of a linked list consists _ _ _ _ _ _ _ no. of fields
a. 2
b. 3
c. 4
d. 1
13. Linked lists are not suitable for data structures of which one of the following problem?
a. insertion sort
b. Binary search
c. radix sort
d. polynomial manipulation
problem
14. An item that is read as input can be either pushed to a stack and latter popped and
printed, or printed directly. Which of the following will be the output if the input is the
sequence of items-1,2,3,4,5?
a. 3,4,5,1,2
b. 3,4,5,2,1
c. 1,5,2,3,4
d. 5,4,3,1,2
15. No.of pointers to be manipulated in a linked list to delete an item in the middle _ _ _ _
___
a. Zero
b. One
c. Two
d. Three
16. No.of pointers to be manipulated in a linked list to delete first item
a. Zero
b. One
c. Two
d. Three
17. Stack is useful for _ _ _ _ _ _ _
a. radix sort
b. breadth first search
c. recursion d. quick sort
18. The end of the list is marked as
a. node.next=0
b. (node.last = 0)
c. node.next= &node;
d. node.previous=0;
19. No.of pointers to be manipulated in a linked list to insert an item in the middle _ _ _ _
____
a. Two
b. Three
c. One
d. Zero
20. Single linked list uses _ _ _ _ _ _ no. of pointers
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 28
a. Zero
b. one
c. Two
d. Three
21. LIFO is
a. stack
b. queue
c. linked list
d. tree
22. A stack is has the entries a,b,c,(with a on top). Stack B is empty. An entry popped out
of stack A can be printed immediately or pushed to stack B.An entry popped out of
stack B can only be printed. In this arrangement, which of the following permutations
a,b,c is not possible?
a. b a c
b. b c a
c. c a b
d. a b c
23. Which of the following programming languages features require a stack-base
allocation
a. pointer
b. Block-structure
c. recursion
d. dynamic scoping
24. Push down stack or push down list is
a. stack
b. queue
c. linked list
d. dequeue
25. Stacks can not be used to
a. evaluate an arithmetic expression in postfix form
b. implement recursion
c. convert a given arithmetic expression in infix form to is equivalent postfix form
d. allocates resources (like CPU) by the operating system
26. Which of the following is essential for converting an infix expression to postfix form
efficiently?
a. An operator stack
b. An operand stack
c. An operator stack and an operand stack
d. A parse tree
27. Linear linked data structure is
a. tree
b. graph
c. stack
d. binary tree
28. A queue of characters currently contained a,b,c,d. What would be the contents of
queue after the following operationDELETE, ADD W, ADD X, DELETE, ADD Y
a. A,B,C,W,Y
b. C,D,W,X,Y
c. W,Y,X,C,D
d. A,B,C,D,W
29. For storing the sorted data on which often insert and deletion operations are
performed, the following data structure is better
a. Array
b. queue
c. linked-list
d. doubly linked-list
30. A circular queue of size N will sign queue full when the number of elements in the
queue is
a. N-1
b. N
c. N+1
d. N-2
31. The postfix equivalent of the prefix * + a b - c d is
a. ab + cd - *
b. ab cd + - *
c. ab + cd * d. ab + - cd *
32. The postfix expression for the infix expressionA + B* (C+D) / F + D*E is:
a. AB + CD + F / D + E*
b. ABCD + * F / + DE*
c. A*B + CD / F*DE ++
d. A+ BCD / F* DE ++
33. A telephone system which places cells to a particular number on hold can best
represented by
a. queue
b. stack
c. linked-list
d. variable
34. If front=rear ,then the queue is
a. full
b. empty
c. unknown value
d. 1/2 full
35. Reverse polish expression is
a. Infix
b. postfix
c. prefix
d. post & prefix
36. A list of integers is read in, one at a time, and a binary search tree is constructed. Next
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 29
the tree is traversed and the integers are printed. Which traversed would result in a
printout which duplicates the original order of the list of integers?
a. pre-order
b. post-order
c. in-order
d. in-fix order
37. polish expression is
a. infix
b. postfix
c. prefix
d. post & prefix
38. To convert an Infix expression into postfix we require
a. stack
b. queue
c. linked list
d. dequeue
39. A stack is most suitable to evaluate _ _ _ _ _ _ _ expression
a. postfix
b. prefix
c. infix
d. post & infix
40. The circular linked list have
a. no beginning
b. no ending
c. beginning but no ending
d. no beginning and no ending
41. To insert a node at the beginning of the doubly linked list _ _ _ _ _ _ _ _ no. of
pointers to be manipulated
a. 1
b. 2
c. 3
d. 4
42. Doubly linked list uses _ _ _ _ _ _ _ _ no.of pointers
a. Zero
b. One
c. Two
d. Three
43. To insert a node at the beginning of the single linked list _ _ _ _ _ _ _ no. of pointers
to be manipulated
a. 1
b. 2
c. 3
d. 0
44. To insert a node at middle of the single linked list _ _ _ _ _ _ _ _ _ _ no. of pointers to
be manipulated
a. 1
b. 2
c. 3
d. 4
45. To insert a node at the end of the doubly linked list _ _ _ _ _ _ _ no. of pointers to be
manipulated
a. 1
b. 2
c. 3
d. 4
46. To insert a node at the end of the single linked list _ _ _ _ _ _ _ _ no. of pointers to be
manipulated
a. 1
b. 2
c. 3
d. 4
47. To delete the first node in single linked list _ _ _ _ _ _ _ _ no. of pointers to be
manipulated
a. 1
b. 2
c. 3
d. 4
48. To delete the last node in single linked list _ _ _ _ _ _ _ no. of pointers to be
manipulated
a. 1
b. 2
c. 3
d. 0
49. To delete the middle node in single linked list _ _ _ _ _ _ _ no. of pointers to be
manipulated
a. 1
b. 2
c. 3
d. 4
50. To delete an item in the middle of a circular doubly linked list, _ _ _ _ _ _ _ _ no.of
points to be manipulated
a. 2
b. 4
c. 6
d. 8
51. If storage class is missing in the array definition, by default it will be taken to be
a. automatic
b. external
c. static
d. either automatic or
external depending on the place of occurrence
52. To delete the last node in doubly linked list _ _ _ _ _ _ _ _ no. of pointers to be
manipulated
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 30
a. 1
b. 2
c. 3
d. 4
53. To delete the middle node in doubly linked list _ _ _ _ _ _ _ _ _ no. of pointers to be
Manipulated
a. 1
b. 2
c. 3
d. 4
54. To insert an item in a circular doubly linked list, _ _ _ _ _ _ _ no.of points to be
manipulated
a. 1
b. 2
c. 3
d. 4
55. To insert a node at middle of the doubly linked list _ _ _ _ _ _ _ no. of pointers to be
manipulated
a. 1
b. 2
c. 3
d. 4
56. To delete the first node in doubly linked list _ _ _ _ _ _ _ _ no. of pointers to be
manipulated
a. 1
b. 2
c. 3
d. 4
57. To insert an item in a circular single linked list _ _ _ _ _ _ _ _ _ no.of points to be
manipulated
a. 2
b. 3
c. 4
d. 1
58. To delete an item in a circular doubly linked list, _ _ _ _ _ _ _ _ no.of points to be
manipulated
a. 1
b. 2
c. 3
d. 4
59. Stack is useful for
a. radix sort
b. breadth first search
c. heap sort
d. depth first search
60. A general linear list is a list in which operations, such as retrievals, insertions,
changes, and deletions can be done _ _ _ _ _ _ _ _ _
a. any where in the list
b. only at the beginning
c. only at the end
d. only at the middle
61. A(n) _ _ _ _ _ _ _ is a collection of elements and relationship Among them.
a. abstract data type
b. array
c. data structure
d. standard type
62. Data that consists of a single, non decomposable entity are known as _ _ _ _ _ _
a. atomic data
b. array
c. data structure
d. standard type
63. If the sequence of operations push(1),push(2) ,pop, push(1),push(2),pop, pop,
pop, push(2),pop, are performed on a stack, the sequence of popped out values are
a. 2,2,1,1,2
b. 2,2,1,2,2
c. 2,1,2,2,1
d. 2,1,2,2,2
64. To delete an element from a queue we use the _ _ _ _ _ operation
a. pop
b. push
c. enqueue
d. dequeue
65. To add an element to a queue we use the _ _ _ _ _ operation
a. pop
b. push
c. enqueue
d. dequeue
66. A queue is a _ _ _ _ _ _ structure
a. first in-last out
b. lasting-first-out
c. first in-first out
d. last in-last out
67. A queue is a list in which insertion can be done _ _ _ _
a. any where in the list
b. only at the beginning
c. only at the end
d. only at the middle
68. A _ _ _ _ _ _ is a first in - last out(FIFO) data structure in which insertions are
restricted to one end, called the rear, and deletions are restricted to another end
,called the front
a. Stack
b. queue
c. tree
d. binary tree
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 31
69. The pointer(s) in a queue points to
a. start of the queue
b. end of the queue
c. middle of the queue
d. both start and end of the queue
70. The disadvantage of the queue is
a. when the item is deleted, the space for that item is not claimed
b. when the item is deleted, the space for that item is claimed
c. a non destructive
d. increases the memory space
71. A queue is a list in which deletion can be done _ _ _ _
a. any where in the list
b. only at the beginning
c. only at the end
d. only at the middle
72. Read() operation in queue is
a. non-destructive
b. additive
c. push()
d. destructive
73. In which of the data structure, space for the item is not claimed ,when an item is
deleted
a. queue
b. circular queue
c. stack
d. linked list
74. As the items from a queue get deleted, the space for item is not reclaimed in
queue. This problem is solved by
a. circular queue
b. stack
c. linked list
d. doubly linked list
75. Which of the following operation is used to add an item in a queue
a. write()
b. read()
c. pop()
d. push()
76. _ _ _ _ no.of pointers are required to implement read and write operations in a
queue
a. two
b. three
c. four
d. five
77. FIFO is
a. stack
b. queue
c. linked list
d. tree
78. Which of the following operation is used to an item in a queue
a. write()
b. read()
c. pop()
d. push()
79. The concatenation of two lists is to be performed in O(1) time. Which of the
following implementations of a list could be used?
a. Singly linked list
b. Doubly linked list
c. Circularly doubly linked list
d. Array implementation of list
80. The initial condition of a queue is
a. front=rear=-1
b. front=rear
c. front=rear=n
d. front=rear=1
81. Queue can be used to implement
a. radix sort
b. quick sort
c. recursion
d. depth first search
VIDHYA VIKAS INSTITUTE OF TECHNOLOGY
Page 32
Download