Showing posts with label DATA STRUCTURES. Show all posts
Showing posts with label DATA STRUCTURES. Show all posts

Wednesday, 12 March 2014

DATA STRUCTURES MCQS

1) Additional information sent when an exception is thrown may be placed in 
 A. The throw keyword
 B. The function that caused the error
 C. The catch block
 D. An object of the exception class
 Ans:- C

2) It is possible to declare as a friend 
 A. A member function
 B. A global function
 C. A class
 D. All of the above
Ans:- D

3) In a class specifier ,data or function designated private are accessible 
 A. To any function in the program
 B. Only if you the password
 C. To member functions of that class
 D. Only to public members of the class
Ans:-C

4) What is the output of the following code
char symbol[3]={‘a’,‘b’,‘c’};
for (int index=0; index<3; index++)
cout << symbol [index]; 
 A. a b c
 B. “abc”
 C. abc
 D. ‘abc’
Ans:-C

5) This pointer 
 A. Implicitly points to an object
 B. Can be explicitly used in a class
 C. Can be used to return an object
 D. All of the above
Ans:- D

6) cfront 
 A. is the front end of a C compiler
 B. is the per-process of a C compiler
 C. is a tool that is translated a C++ code to its equivalent C code
 D. None of above
Ans:- C

7) A pure virtual function is a virtual function that 
 A. Has no body
 B. Returns nothing
 C. Is used in base class
 D. Both (A) and (C)
Ans:-D

8) Access to private data 
 A. Restricted to methods of the same class
 B. Restricted to methods of other classes
 C. Available to methods of the same class and other classes
 D. Not an issue because the program will not compile
Ans:-B

9) What will be the output of the following program?
#include<iostream.h>
void main()
{
float x=5,y=2;
int result;
result=x % y;
cout<<result;
} 
 A. 1
 B. 1.0
 C. Error message
 D. 2.5
Ans:- C

10) A function call mechanism that passes arguments to a function by passing a copy of the values of the arguments is __________ 
 A. Call by name
 B. Call by value
 C. Call by reference
 D. Call by value result
Ans:- B

11) _________ members of a base class are never accessible to a derived class. 

 A. Public
 B. Private
 C. Protected
 D. A,B and C
Ans:- B

12) Real world objects contain 
 A. State and behavior
 B. Date and time
 C. Data and information
 D. None of these
Ans:- A

13) This type of inheritance is a mixture of multiple inheritance and hierarchical inheritance 
 A. Single inheritance
 B. Multiple inheritance
 C. Hierarchical inheritance
 D. Hybrid inheritance
Ans:- D

14) In access control in a protected derivation, visibility modes will change as follows 
 A. Private, public and protected become protected
 B. Only public becomes protected
 C. Public and protected become protected
 D. Only private becomes protected
Ans:-C

15) Within a switch statement 
 A. Continue can be used but Break cannot be used
 B. Continue cannot be used but Break can be used
 C. Both Continue and Break can be used
 D. Neither Continue nor Break can be used
Ans:-B

16) A virtual class is the same as 
 A. An abstract class
 B. A class with a virtual function
 C. A base class
 D. None of the above
Ans:- D

17) A struct is the same as a class except that 
 A. There are no member functions
 B. All members are public
 C. Cannot be used in inheritance hierarchy
 D. It does have a this pointer
Ans:- C

18) Which of the following cannot be legitimately passed to a function 
 A. A constant
 B. A variable
 C. A structure
 D. A header file
Ans:- D

19)If x =5, y =2 then x ^y equals________.
(where ^ is a bitwise XOR operator) 
 A. 00000111
 B. 10000010
 C. 10100000
 D. 11001000
Ans:-  A 

20) In multiple inheritance 
 A. The base classes must have only default constructors
 B. Cannot have virtual functions
 C. Cannot have virtual classes
 D. None of the above
Ans:-  C

Tuesday, 11 March 2014

DATA STRUCTURES MCQS

1) The C language includes the header file standard input & output in 
 A. stdlib.h library
 B. stdio.h library
 C. conio.h library
 D. #include library
 Ans:- B

2) Consider the following recursive C function that takes two arguments. unsigned int foo(unsigned int n,unsigned int r) { if(n>0)return((n%r)+foo(n/r,r)); else return 0; } What is value of function foo when it called as foo(512,2)? 
 A. 9
 B. 2
 C. 8
 D. 11
Ans:- B

3) 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);
} 
 A. 25
 B. 11
 C. Error
 D. Garbage value
Ans:- B

4) Number of possible binary trees with 3 nodes is 
 A. 12
 B. 13
 C. 14
 D. 15
Ans:- D

5) The expression X=4+2%-8 evaluate 
 A. -6
 B. 6
 C. 4
 D. None
Ans:-B

6) The data structure needed to convert a recursion to an iterative procedure is 
 A. Queue
 B. Graph
 C. Stack
 D. Tree
Ans:-C

7) What punctuation is used to signal the beginning and end of code blocks? 
 A. { }
 B. -> and <-
 C. BEGIN and END
 D. ( and )
Ans:-A

8) What is the output of the following program segment?
main()
{
int i = ++2;
printf(“%d\n”, i);
} 
 A. 3
 B. 2
 C. 0
 D. -1
Ans:-A

9) An algorithm that calls itself directly or indirectly is known as 
 A. Sub algorithm
 B. Recursion
 C. Polish notation
 D. Traversal algorithm
Ans:-B

10) A Compiler is _____________________. 
 A. A combination of computer hardware
 B. A program which translates from one high-level language to another
 C. A program which translates from one high-level to a machine level
 D. None of these
Ans:-C

11) A binary tree in which if all its levels except possibly the last, have the maximum number of nodes and all the nodes at the last level appear as far left as possible, is known as 
 A. Full binary tree
 B. AVL tree
 C. Threaded tree
 D. Complete binary tree
Ans:-A

12) Which allows deletion at only one end of the list but allows insertion at both ends of the list? 
 A. Deque
 B. Circular queue
 C. Output restricted deque
 D. Input restricted deque
Ans:-C

13) A technique for direct search is 
 A. Binary Search
 B. Linear Search
 C. Tree Search
 D. Hashing
Ans:-D

14) The maximum value that an integer constant can have is 
 A. .32767
 B. 32767
 C. 1.7014e+38
 D. –1.7014e+38
Ans:- B

15) What would be output of the following program?
#include "stdio.h"
main()
{
printf(“%d%d”, size of (NULL!), size of (“ “));
} 
 A. 2 1
 B. 1 2
 C. 2 2
 D. 1 1
Ans:-  C

16) It is necessary to declare the type of function in the calling program if 
 A. Function returns an integer
 B. Function returns a non-integer value
 C. Function is not defined in the same file
 D. Function is called number of times
Ans:-  B

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

18) C language was invented by 
 A. Abacus
 B. Charles babage
 C. Thomson
 D. Dennis Ritchie
Ans:- D

19) The _______ operator is a technique to forcefully convert one data type to the others 
 A. Cast
 B. Conversion
 C. Type
 D. Unary
Ans:-A

20) A binary tree whose every node has either zero or two children is called 
 A. Complete binary tree
 B. Binary search tree
 C. Extended binary tree
 D. None of above
Ans:-C

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

Wednesday, 26 February 2014

DATA STRUCTURES MCQS

1) Number of arcs incident to a node is called as
Ans:-Predecessor

2) Methods of graph traversal
Ans:-Depth First Search(DFS)

3) Breadth First Search(BFS)

 Representation of two dimensional array in memory is called as

Ans:-Row-major and column-major

 4) A heap allows very efficient implementation of 

Ans:-Priority queue

5) The shortest path in weighted graph or network is found out using
Ans:-Dijkastra's algorithm

Kruskal algorithm

 6) The smallest element of a array is called as

Ans:-Lower bound.

7) Which of the following is tautology?
a.)x v y
b.)x v (~y)
c.)x v(~x)
d.)(x=<y)^(x<=y)
Ans.: c.)
Explanation: 


X

~X

X V(~X)
T

F

T
F

T

T
 Tip: '~' denotes negation that is '1' means '0' and '0' means '1'
'V' means 'OR' operator.
Side note: Tautolgy means all the results should be True(T) or 1

8) Minimum number of individual shoes to be picked up from a dark room (containing 10 pair of shoes) if we have to get atleast one proper pair.
a.)3
b.)11
c.)10
d.)20
Ans.: b.)
Explanation of logic: There are 10 pair of shoes.
A single proper matching pair can be found out only when we pick the 11th shoe because till 10th shoe we cannot be very sure that we will get the right pair. But the 11th shoe that we take will definitely let us match the right pair surely. (LOGICAL REASONING QUESTION)

9)  Circle has how many vertices?
a.) No vetices
b.) 2 vertex
c.) 5 vertex
d.) Infinite vertices

Ans.: d.)
Note: A simple but logic question.
You can mark as much vertices as possible on a circle.
Example:
Ugc net computer science
10) The logic of pumping lemma is and example of
a.)Recursion
b.) Divide and conquer rule
c.) Pigeon hole principle
d.) Iteration
Ans.: c.)

11) An undirected graph possesses an eulerian circuit only if it is connected and its vertices are
a.) All of even degree
b.) All of odd degree
c.) of any degree
d.) even in number
Ans.: a.)

12) The number of edges in a complete graph with N vertices is equal to
a.) N(N-1)
b.) 2N-1
c.) N-1
d.) N(N-1)/2
Ans.: d.)

13) The number of edges in a connected graph with 'n' vertices is
a.) n-1
b.) n(n-1)/2
c.) n^2
d.) 2n-1
Ans.: a.)

14) A graph G  4,5  has                     
a.) 4 edges
b.) 5 edges
c.) 20 edges
d.) 15 edges
Ans.: c.)
Logic: Number of edges in Graph G(m,n)=m*n

15) A self complemented,distributed lattice is
a.) Boolean algebra
b.) Modular lattice
c.) Complete lattice
d.) Self dual lattice.
Ans.: a.)

16) A graph with all nodes of equal importance is called as
a.) Complete graph
b.) Regular graph
c.) Non regular graph
d.) Multigraph
Ans.: b.) 

17) A partial ordered relation is transitive, reflexive and
a.) bisymmetric
b.) antisymmetric
c.) antireflexive
d.) asymmetric
Ans.: b.)

18) If n is an integer, and n^2 is odd then 'n' is
a.) even
b.) odd
c.) even or odd
d.) prime
Ans.: b.)
Reason:1.) Let n be 7 then,
n^2=49 

19) Let n be 9 then,
n^2=81
In both cases, the result is an odd number 
Therefore, answer is odd.

DATA STRUCTURES MCQS

What is Data structure?
Ans.: The logical or mathematical representation of data.
It is way of organizing data that considers the data stored and also their relationship with each other.

Applications of data structures in computer science
Ans.: Compiler design
DBMS
Artificial intelligence
Statistical analysis
Numerical analysis
Graphics
Operating system

Simulation

What is the minimum number of queue needed to implement priority queue?
Ans.: Two

Explanation: One queue for actual storing of data and another queue for storing priorities.

Arithmetic expressions cam be evaluated using

Ans.: Polish and reverse polish notations.

Methods used to store sequential files
Ans.: Straight merging
Polyphase sort
Distribution of initial runs.

Natural merging

How many different trees possible with 7 nodes.
Ans.: 121
Explanation: 2^n-n

2^7-7=128-7=121

 Which is the condition that occurs when two distinct key values are mapped to the same memory location.

Ans.: Collision

Simplest file structure is

Ans.: Sequential file structure

What is computational procedure
Ans.: An algorithm that does not terminate.

Example: Operating System

8 queens problem can be solved by

Ans.: Backtracking method.

Which is the memory address of the first element of the array.

Ans.:Base address.

Stack is also called as

Ans.:Push down list.

A descending heap is also called as

Ans.:Max heap

A linked list with no nodes is called as

Ans.:Empty list or null list.

A strictly binary tree with n leaves have how many nodes.

Ans.:2n-1 nodes

Which is the most commonly used hash functions to compute hash address.

Ans.:Division method

Which graph shows basic blocks and the success of relationships

Ans.:Flow graph

Commonly used language processors are
Ans.:Compilers
Interpreters

Assembler

In queue, the end from which data is inserted is called as

Ans.:Rear

Through linked list, we can implement

Ans.:Stack, queue, graph