Tuesday 11 March 2014

DATA STRUCTURES MCQS

1) What will be output if you will execute following c code?
#include<stdio.h> int main(){    int i;    for(i=0;i<5;i++){         int i=10;         printf(" %d",i);         i++;    }    return 0; 
 A. 10 11 12 13 14
 B. 10 10 10 10 10 
 C. 0 1 2 3 4
 D. Compilation error
  Ans:-  B
  Explanation Default storage class of local variable is auto. Scope of auto variables are block in which it has been declared. When program control goes out of the scope auto variables are dead. So variable iwhich has been declared inside for loop has scope within loop and in each iteration variable i is dead and re-initialized. Note: If we have declared two variables of same name but different scope then local variable will have higher priority 

2) Which of the following data structure is used to represent relationship between pairs, where relationship is not hierarchical ? 
 A. Graph
 B. Tree
 C. Hash Table
 D. Queue
Ans:- A

3) Which of the following data structure is used to represent hierarchical relationship among its elements? 
 A. Graph
 B. Tree
 C. Hash Table
 D. Queue
Ans:-B

4) If a binary tree satisfies shape and order property its known as  
 A. Binary Search Tree
 B. Sequential Search Tree
 C. Heap
 D. Rooted Tree
Ans:- C

5) A data structure in which linear sequence is maintained by pointers is known as 
 A. Pointer based data structure
 B. Stack
 C. Array
 D. Linklist
Ans:- D

6) A data structure whose elements from a sequence is known as 
 A. Non-linear Data Structure
 B. Linear Data Structure
 C. Homogeneous Data Structure
 D. Heterogeneous Data Structure
Ans:- B

7) Each attribute of an entity has a defined set of values. This set of values is called a 
 A. Range
 B. Domain
 C. Entity Set
 D. Mapping
Ans:-B

8) A data item that cannot be divided into sub items is known as 
 A. Primary Data Item
 B. Primary Key
 C. Group Data Item
 D. Elementary Data Item
Ans:- C

9)Inheritance is a feature of --------------language 
 A. C Language
 B. C++ Language
 C. Basic
 D. Cobol
Ans:- B 

10) The statement that transfers control to the beginning of the loop is called 
 A. Break statement
 B. Exit statement
 C. Continue statement
 D. Goto statement
Ans:- C

11) The language that the computer can understand and execute is called 
 A. Machine Language
 B. Application Software
 C. System Program
 D. Assembly language
Ans:-A

12) The keyword used to transfer control from a function back to the calling function is 
 A. Switch
 B. Goto
 C. Go back
 D. Return
Ans:- D

13) If an array is used as function argument, the array is passed 
 A. By value
 B. By reference
 C. By name
 D. The array cannot be used as a function argument
Ans:-B

14) In C, if you pass an array as an argument to a function, what actually gets passed? 
 A. Value of elements in array
 B. First element of the array
 C. Base address of the array
 D. Address of the last element of array
Ans:-C

15) The break statement causes an exit 
 A. Only from the innermost loop
 B. Only from the innermost switch
 C. From the innermost loop or switch
 D. From the program
Ans:- C

16) The smallest element of an array’s index is called its 
 A. Lower bound
 B. Upper bound
 C. Range
 D. Extraction
Ans:-  A

17) If a = 5 and b = 7 then the statement p = (a > b) : a ? b 
 A. assigns a value 5 to p
 B. assigns a value 7 to p
 C. assigns a value 8 to p
 D. gives an error message
Ans:-  D

18) The __________ statement causes immediate exit from the loop overriding the condition test 
 A. Exit
 B. Break
 C. Goto
 D. None of the above
Ans:- B

19) The value that follows the keyword CASE may only be 
 A. Constants
 B. Variable
 C. Number
 D. Semicolon
Ans:- A

20) The machine registers are sometimes called 
 A. Local variables
 B. Global variables
 C. Accumulators
 D. Static variables
Ans:-  A

No comments:

Post a Comment