Data structure/Data Structure and Algorithms (DSA) set 4 Sample Test,Sample questions

Question:
 . #include <stdio.h>
#include <string.h>
int main(){
int i=0;
for(;i<=2;)
printf(" %d",++i); return 0;
}

1. 0 1 2 3

2. 0 1 2

3.1 2 3

4.compiler error


Question:
 A declaration "short int" is used for variables

1.which have a short duration in a program B. C.

2. which have short names

3.which may require less storage than normal integers

4.All of the three


Question:
 A node in a linked list must contain at least

1. three fields

2.two fields

3.four fields

4. one field


Question:
 A ________ linked list is a linked list structure in which each node has a pointer to both its successor and predecessor.

1.circularly

2.doubly

3.linear

4.sequential


Question:
 In a circularly linked list organisation ,insertion of a record involves the modifications of

1.no pointer

2.1 pointer

3.2 pointer

4.3 pointer


Question:
 In a linked list, the pointer of the last node contains a special value, called the ______ pointer.

1.null B. C. D.

2.zero

3.link

4.next pointer


Question:
 In C, if you pass an array as an argument to a function, what actually gets passed?

1.value of elements in array

2. first element of the array

3. base address of the array

4.address of the last element of array


Question:
 In linked list,a node contain

1. node,adrees field and data field

2.node number and data field

3.next adress field and information field

4.None of the above


Question:
 In linked list,the logical order of elements

1. is same as their physical arrangement

2.is not necessarily equivalent to their physical arrangement

3.. is determined by their physical arrangement

4.none of the above


Question:
 List pointer variable in linked list contains address of the

1. following node in the first

2.current node in the first

3. first node in the first

4.none of the above


Question:
 The declaration "unsigned u" indicates u is a/an

1.unsigned character

2.unsigned integer

3.character

4.none of these


Question:
 The members of the union are accessed by____

1.dot operator

2.pointer -> operator

3.both a and b

4. none of these


Question:
 To insert a node in a circular list at rear end it should be inserted at …...of the queue

1.front position

2.front-1position

3.rear position

4.rear-1 position


Question:
 What is the maximun number of dimensions an array in C may have?

1.two

2.eight

3.twenty

4.theoratically no limit. the only practical limits are memory size and compilers


Question:
 What is true about linked kist?

1.it is a linked structure,where each data gives the address of the next data

2. it is a dynamic data structure

3. it is a static data structure

4.both (a) and (b)


Question:
 What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
int i=4,x;
x=++i + ++i + ++i;
printf("%d",x); return 0;
}

1.21

2.18

3.12

4.Compiler Error


Question:
 Which of the following data structure is linear type ?

1.strings

2.lists

3.queues

4.All of the above


Question:
A circular list can be used to represent

1. a stack

2.a queue

3.a tree

4.both a and b


Question:
A node of linked list contains_______

1. data field

2.a self referential pointer

3.both (a)and(b)

4.only b


Question:
A polynomial can be represented in a _______ by just storing the coefficient and exponent of each term.

1.array

2.linked list

3.queue

4.stack


Question:
A variable which is visible only in the function in which it is defined, is called

1. A. static

2.auto

3.external

4.local


Question:
A _______ list structure can be traversed in two directions-- in the forward direction from beginning of the list to end, or in the backward direction, from the end of the list to the beginning.

1.one way

2.linear array

3.two way

4.header


Question:
A ________ linked list is a linked list which always contains a special node, called the header node.

1.circular

2.grounded

3.header

4.doubly


Question:
An external variable

1. is globally accessible by all functions

2.has a declaration

3. will be initialized to 0 if not initialized

4.All of the three


Question:
Are *ptr++ and ++*ptr are same?

1. A. no they are not same B. C.

2.yes they are one and the same

3.yes they are one and the same

4. none of these


Question:
Because of linear structure of linked list having linear ordering,there is similarity between linked list and array in

1.insertion of a node

2.deletion of a node

3.traversal of elements of list

4.None of the above


Question:
C language was invented by

1. abacus

2.charles babage

3.thomson

4.dennis ritchie


Question:
Consider that n elements are to be sorted. What is the worst case time complexity of Bubble sort?

1.o(1)

2.o(log2n)

3. o(n)

4. o(n^2)


Question:
Deletion of a node from an empty linked list will cause________

1.underflow

2.overflow

3.run time error

4. all of the above


Question:
How many bits are absolutely necessary to store an ASCII character ?

1. 7

2.8

3.15

4.16


Question:
How many times the program will print "Amrutvahini" ? #include<stdio.h>
int main()
{
printf("Amrutvahini");
main();
return 0;
}

1. infinite times

2.32767 times

3. 65535 times

4.till stack overflows


Question:
If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

1.abcd

2.abdc

3.dcab

4.dcba


Question:
In a ________ linked list, the last node's link field points to the first node of the list.

1. circularly

2.linearly

3.sequentially

4.indexed


Question:
Insertion in a linked list requires modification of____pointers

1.1

2.2

3.3

4.4


Question:
Null pointer is used to tell

1.end of linked list

2. empty pointer field of a structure

3.the linked list is empty

4. all of the above


Question:
One difference between a queue and a stack is:

1.queues require dynamic memory, but stacks do not.

2.stacks require dynamic memory, but queues do not

3. queues use two ends of the structure; stacks use only one.

4.stacks use two ends of the structure, queues use only one.


Question:
Queue is a -------------- List .

1.fifo

2.lifo

3.lilo

4.liso


Question:
Searching of linked list requires linked list to be created

1.in stored order only

2.in any order

3.without underflow condition

4.None of the above


Question:
The complexity of linear search algorithm is

1. o(n)

2.o(log n)

3.o(n2)

4.o(n log n)


Question:
The data type created by the data abstraction process is called

1. class

2.structure

3.abstract data type

4. user defined data type


Question:
The keyword used to transfer control from a function back to the calling function is

1. switch

2.goto

3.go back

4.return


Question:
The link list also contains a list pointer variable called start or ________.

1.name

2. field

3.node

4.link


Question:
The main measures of efficiency of an algorithm are

1.processor and memory

2.complexity and capacity

3. time and space

4.data and space


Question:
The most significant bit is lost in following operation

1.<<

2. >>

3.&

4./


Question:
The program fragment
int i = 263 ;
putchar (i) ;
prints

1. 263

2.ascii equivalent of 263

3.rings the bell

4.garbage


Question:
The result of 0001 1010 & 0000 1000 is ___

1.0001 1111

2.1111 0001

3.0000 1000

4.None of These


Question:
The result of 0001 1010 << 2 is____

1.0101 1100

2. 0110 1000

3.0001 1110

4.None of These


Question:
The result of 0001 1010^0001 0000 is____

1.0101 1001

2.1010 0100

3.0000 0010

4.none of these


Question:
The second part of the node, is called _______ field, and contains the address of the next node in the list.

1. pointer

2.field

3.node

4.link


Question:
the terms push and pop are related to

1. stack

2.queue

3.array

4.None of the above


Question:
The variables which can be accessed by all modules in a program, are called

1.local variables

2.internal variables

3.external variable

4.global variables


Question:
The worst case occures in linear search algorithms when

1.item is somewhere in the middle of the array

2.item is not there in the array at all

3.item is last element in the array

4.item is last element in the array or is not there at all.


Question:
Unsigned integers occupies

1.two bytes

2.four bytes

3.one bytes

4.eight bytes


Question:
Unsigned integers occupies

1.two bytes

2.four bytes

3.one bytes

4.eight bytes


Question:
What additional requirement is placed on an array, so that binary search may be used to locate an entry?

1.the array elements must form a heap

2. the array must have at least 2 entries.

3. the array must be sorted.

4.the arrays size must be a power of two.


Question:
What is the similarity between structure,union and enum?

1. all of them let you define new values

2.all of them let you define new pointers

3. all of them let you define new structure

4.all of them let you define new data types


Question:
What term is used to describe an O(n) algorithm

1.constant

2.linear

3.logarithmic

4.quadratic


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
#define max 5;
int main(){
int i=0;
i=max++;
printf("%d",i++); return 0;
}

1.5

2.6

3.7

4.0


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
char c=125;
c=c+10;
printf("%d",c); return 0;
}

1. 135

2. +inf

3.-121

4. -8


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
double far* p,q;
printf("%d",sizeof(p)+sizeof q); return 0; }

1.12

2.8

3.4

4.1


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
int a=2;
if(a==2){
a=~a+2<<1;
printf("%d",a);
}
else{
break;
} return 0;
}

1. it will print nothing

2.-3

3.-2

4. compiler error


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
int i=10;
static int x=i;
if(x==i)
printf("Equal");
else if(x>i)
printf("Greater than");
else
printf("Less than"); return 0;
}

1.equal

2. less than

3. greater than

4.compiler error


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){
int array[]={10,20,30,40};
printf("%d",-2[array]); return 0;
}

1.-60

2.-30

3.60

4.garbage value


Question:
What will be the output of the following code? Void main(){int a=10;int *b=&a;int **c=&b;printf("%d %d %d",a,*b,**c);}

1.0 10 garbage

2.10 garbage garbage

3.10 10 10

4.syntax error


Question:
What will be the output of the program? #include<stdio.h>
int i;
int fun();

int main()
{
while(i)
{
fun();
main();
}
printf("Hello
");
return 0;
}
int fun()
{
printf("Hi");
}

1.hello

2.hi hello

3.no output

4. infinite loop


Question:
What will be the output of the program? #include<stdio.h>
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}
printf("%d
", X);
return 0;
}

1.40 40

2.20 20

3.20

4.error


Question:
Which data structure allows deleting data elements from front and inserting at rear?

1. stack

2.queue

3.dequeue

4.binary search tree


Question:
Which nodes contains a null pointer in a linked list?

1.first node

2.middle node

3.last node

4. both (a) and (b)


Question:
Which of the following 'C' type is not a primitive data structure?

1.int

2.float

3.char

4.none of these


Question:
Which of the following data structure is linear data structure?

1.trees

2.graphs

3.arrays

4.none of above


Question:
Which of the following formulas in big-O notation best represent the expression n²+35n+6?

1.o(n³)

2.o(n²)

3.o(n)

4.o(42)


Question:
Which of the following is a collection of different data type elements?

1.array

2.structure

3.string

4.all of the above


Question:
Which of the following statement is true about char ****a ?

1. a is pointer to a pointer to a pointer to char

2.a is pointer to a pointer to a pointer to char

3.a is a pointer to a char pointer

4.a is a pointer to a pointer to a char


Question:
___ attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes.

1.underflow

2.overflow

3.compaction

4.free storage


Question:
____ header list combines the advantages of a two-way list and a circular header list.

1. one way

2.two way circular

3.two way

4.header


Question:
_____ attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes.

1.garbage collection

2. garbage compaction

3.buddy system

4.queue


Question:
_____ list is a special list that is maintained, which consists of unused memory cells.

1.linear

2.doubly linked

3.circularly linked

4.free storage


Question:
______ is a technique using which a computer periodically collects all the deleted space onto the free storage list.

1.garbage collection

2.garbage compaction

3.linked list

4.free storage


Question:
______ refers to situation where one wants to delete data form a data structure that is empty

1. free storage

2.underflow

3.overflow

4.compaction


Question:
________ is an organization that provides faster request and return time response.

1.stack

2.queue

3.buddy system

4.recursion


More MCQS

  1. Data Structures and algorithms MCQ Questions
  2. Data Structure -Abstract Data Types
  3. Data Structure Questions and Answers Singly Linked
  4. Data Structures &algorithms MCQ Questions
  5. Data Structure Multiple Choice Questions and Answers
  6. Data Structure (DS) MCQ Set 1
  7. Data Structure (DS) MCQ Set 2
  8. Data Structure and Algorithms (DSA) set 1
  9. Data Structure and Algorithms (DSA) set 2
  10. Data Structure and Algorithms (DSA) set 3
  11. Data Structure and Algorithms (DSA) set 4
  12. Data Structure and Algorithms (DSA) set 5
  13. Linear Data Structures - List
  14. Data Structure MCQ questions and answer
  15. Data Structure MCQ questions and answer
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!