Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
146 views

Programming and Data Structure Solved MCQs Part 2 Book

This document contains 50 multiple choice questions related to programming and data structures. The questions cover topics like data types, algorithms, data structures (arrays, stacks, queues, linked lists, trees, graphs), sorting, searching, complexity analysis, and the C programming language. Correct answers are provided for each question.

Uploaded by

Rida Baig
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views

Programming and Data Structure Solved MCQs Part 2 Book

This document contains 50 multiple choice questions related to programming and data structures. The questions cover topics like data types, algorithms, data structures (arrays, stacks, queues, linked lists, trees, graphs), sorting, searching, complexity analysis, and the C programming language. Correct answers are provided for each question.

Uploaded by

Rida Baig
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

A-PDF Text Replace DEMO: Purchase from www.A-PDF.

com to remove the watermark

Programming and Data Structure Solved


MCQs- Part 2

http://freepdf-books.com
Programming and Data Structure Solved
MCQs- Part 2

Unsigned integers occupies

Two bytes
Four bytes
One byte
Eight byte
________________________________________________________
A weather forecasting computation requires 250 billion floating point
operations. The problem is processed in a supercomputer that ca
perform 100 mega flops. How long will it take to do these
calculations.

4167 min
40 min
52.67 min
60.12 min
________________________________________________________
The value that follows the keyword CASE may only be

Constants
Variable
Number
Semicolon
________________________________________________________
A data structure whose elements from a sequence is known as

Non-linear Data Structure


Linear Data Structure
Homogeneous Data Structure
Heterogeneous Data Structure

http://freepdf-books.com
________________________________________________________
The process of production of customer list in alphabetical order falls
under the category of

Editing
Sorting
Updating
Calculating
________________________________________________________
If an array is used as function argument, the array is passed

By value
By reference
By name
The array cannot be used as a function argument
________________________________________________________
Binary search tree is an example of

Divide and conquer


Greedy algorithm
Back tracking
Dynamic programming
________________________________________________________
The earliest calculating devices are

Abacus
Clock
Difference
None of these
________________________________________________________
Which of the following data structure is non-linear type?

Strings
Lists

http://freepdf-books.com
Stacks
None of above
________________________________________________________
What value would the following function return for the input x=95
Function fun (int x)
{
if(x>100)
{
return fun(x-10)
}
else
return fun(fun(x+11))
}

91
90
89
92
________________________________________________________
A data structure in which linear sequence is maintained by pointers
is known as

Pointer based data structure


Stack
Array
Linklist
________________________________________________________
The information about an array used in a program will be sorted in

Symbol table
Activation table
System table
Dope vector
________________________________________________________

What does the following fragment of C-program print?

http://freepdf-books.com
char c[] "GATE2011";
char *p =c;
printf ("%s", p+p[3]-p [1] );

GATE2011
E2011
2011
011
________________________________________________________
From the point of view of the programmer, what are the major
advantages of using a high-level language rather than internal
machine code or assembly language ?

Program portability
Easy development
Efficiency
None of the above
________________________________________________________
By default real number is treated as

Float
Double
Long double
Far double
________________________________________________________
Which of the following data structure is used to represent
relationship between pairs, where relationship is not hierarchical ?

Graph
Tree
Hash Table
Queue
________________________________________________________
What is the output of the following program segment?
main()

http://freepdf-books.com
{
int i = ++2;
printf(“%d\n”, i);
}

3
2
0
-1
________________________________________________________
‘C’ allows a three-way transfer of control with the help of

Unary operator
Relational operator
Ternary operator
Comparison operator
________________________________________________________
The postfix expression AB + CD – * can be evaluated using a

stack
tree
queue
linked list
________________________________________________________
C language was invented by

Abacus
Charles babage
Thomson
Dennis Ritchie
________________________________________________________
What is the output of the following program segment?
main()
{
int i = 1;
do

http://freepdf-books.com
{
printf(“%d..”, i);
}
while(i--);
}

0..1..
1..0..
0
-1
________________________________________________________
Suppose a circular queue of capacity (n -1) elements is implemented
with an array of n elements. Assume that the insertion and deletion
operations are carried out using REAR and FRONT as array index
variables, respectively. Initially, REAR = FRONT = 0. The conditions
to detect queue full and queue empty are

full: (REAR+1) mod n == FRONT


empty: REAR == FRONT
full: (REAR+1) mod n == FRONT
empty: (FRONT+1) mod n == REAR
full: REAR == FRONT
empty: (REAR+1) mod n == FRONT
full: (FRONT+1) mod n == REAR
empty: REAR == FRONT
________________________________________________________

Consider the following sequence of operations :


(i) Pointer p1 is set to point at a new heap-dynamic variable.
(ii) Pointer p2 is assigned p1 value.
(iii) The heap dynamic variable pointed to by p1 is explicitly
de-allocated, but p2 is not changed by the operation. This situation
leads to which of the following :

p1 becomes a dangling pointer


p2 becomes a dangling pointer
Both p1 and p2 are now dangling pointers
Neither p1 nor p2 is now a dangling pointer
________________________________________________________

http://freepdf-books.com
Consider the following program
main ( )
{ float a = 0.5, b = 0.7;
if (b < 0.8)
if (a < 0.5) printf (“ABCD”);
else printf (“PQR”);
else printf (“JKLF);
}
The output is

ABCD
PQR
JKLF
None of these
________________________________________________________
What would be the output of the following program, if run from the
command line as “myprog 1 2 3” ?
main (int argc, char * argv[ ])
{ int i ;
i = argv[1] + argv[2] + argv[3] ;
printf (“% d”, i) ;
}

123
6
Error
“123”
________________________________________________________
The expression P >> 6 shifts all bits of P six places to right. What is
the value of P >> 6 if P 0.6db7 ?

0.1234
0.0001
0.0000
0.1B6
________________________________________________________
The process of accessing data stored in a serial access memory is

http://freepdf-books.com
similar to manipulating data on a

Heap
Queue
Stack
Binary tree
________________________________________________________
Queue is a ----------- list.

LIFO
LILO
FILO
FIFO
________________________________________________________
Linked lists are not suitable data structures for which one of the
following problems

Insertion sort
Binary search
Radix sort
Polynomial manipulation
________________________________________________________
The << operator is used for

Right shifting
Right shifting
Bitwise shifting
Bitwise complemen
________________________________________________________
In a circular linked list

Components are all linked together in some sequential manner


There is no beginning and no end
Components are arranged hierarchically

http://freepdf-books.com
Forward and backward traversal within the list is permitted
________________________________________________________
If binary tree has n leaf nodes,then number of nodes of degree 2 in T
is

log2n

n-1
n
2n
________________________________________________________
Consider the following C code segment.
int a, b, c = 0;
void prtFun(void);
main( )
{ static int a = 1; /* Line 1 */
prtFun( );
a += 1;
prtFun( );
printf(“ \n %d %d ”, a, b);
}
void prtFun(void)
{ static int a = 2; /* Line 2 */
int b = 1;
a += ++b;
printf(“ \n %d %d ”, a, b);
}
What output will be generated by the given code segment?

31
41
42
42
61
61
42
62
20
31
52
52
________________________________________________________

http://freepdf-books.com
Following sequence of operations is performed on a stack:
PUSH (10), PUSH(20), POP,PUSH (10), PUSH (20),POP, POP, POP,
PUSH (20), POP

20,10,20,10,20
20,20,20,10,20
20,10,20,10,10
20,20,10,10,20
________________________________________________________
Output of the program given below is
int i;
main()
{
printf(“%d”, i)

1
0
-1
NULL
________________________________________________________
Usually, an algorithm will contain a number of procedural steps
which are dependent on results of previous steps and is called
_______________.

Flowchart
Chart
Drawing Chart
Food Chart
________________________________________________________
What would be output of the following program? # define SQR(X)
(X*X) main() { int a, b=3; a = SQR(b+2); printf(“\n%d”, a); }

25
11
Error

http://freepdf-books.com
Garbage value
________________________________________________________
The efficient data structure to insert/delete a number in a stored set
of numbers is

Queue
Linked list
Doubly linked list
Binary tree
________________________________________________________
How many times the following program would print (“abc”)? main() {
printf(“\nabc”); main(); }

Infinite number of times


32767 times
65535 times
Till the stack does not overflow
________________________________________________________

When the following code is executed what will be the value of x and y
?
int x = 1, y = 0;
y = x++;

2,1
2,2
1,1
1,2
________________________________________________________
Which of the following is a bad example of recursion ?

Factorial
Fibonacci numbers
Tower of Hanai

http://freepdf-books.com
Tree traversal
________________________________________________________
An advantage of choosing this implementation of \set of integers" is
that adding an element to a set is a contact time operation. Which of
the following is a disadvantage of this implementation?

Adding elements to a very small sets could cause error flags to be


raised.
Deleting elements from very large sets could cause error °ags to be
raised.
Deleting elements from very large sets could cause error °ags to be
raised.
Constructing the union of two sets will require quadratic time in the
size of the set being constructed.
________________________________________________________
The number of different directed trees with 3 nodes are

2
3
4
5
________________________________________________________
What would be output of the following program, if the array begins at
65486?
main()
{
int arr[ ] = {12, 14, 15, 23, 45};
printf(“%u%u”, arr+1, &arr+1);
}

65486, 65486
65488, 65488
65488, 65496
None of the above
________________________________________________________
The name of all functions end with a

Pair of parenthesis

http://freepdf-books.com
Semicolon
Braces
Colon
________________________________________________________
A template stores

Styles, macros
Auto Text entires, Customized word command Settings
Graphics, text
All of the above
________________________________________________________
What would be output of the following program?
# define SQR(X) (X*X)
main()
{
int a, b=3;
a = SQR(b+2);
printf(“\n%d”, a);
}

25
11
Error
Garbage value
________________________________________________________
The decimal value 0.5 in IEEE single precision floating point
representation has

fraction bits of 000…000 and exponent value of 0


fraction bits of 000…000 and exponent value of -1
fraction bits of 100…000 and exponent value of 0
no exact representation
________________________________________________________
Queues serve a major role in

Simulation of recursion

http://freepdf-books.com
Simulation of arbitrary linked list
Simulation of limited resources
Expression evaluation
________________________________________________________
Number of binary trees formed with 5 nodes are

32
64
120
42

http://freepdf-books.com

You might also like