wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Prelims - LIST

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

(a)   is defined as a mathematical model with a collection of operations defined on that model.

2.

Benifits of ADT

a)

Implementation of ADTs can be changed without requiring changes to the program that uses the ADTs

b)

Modularity

c)

Reuse

d)

Code is easier to understand

3.

How many DISTINCT types of LIST operation you can perform?

a)

4

b)

5

c)

3

d)

8

4.

In a array implementation of list, before insertion i have to move elements to one direction, then i have to free the position and then i have insert. which of the following code does that?

a)

for(i = n-1 ; i >= pos-1 ; i--)

list[i+1] = list[i];

b)

for(i = n-1 ; i >= pos-1 ; i--)

list[i-1] = list[i];

c)

for(i = n-1 ; i >= pos-1 ; i--)

list[i] = list[i+1];

d)

for(i = n-1 ; i >= pos-1 ; i--)

list[i] = list[i-1];

5.

Routine to delete element in an array implementation of List

a)

for(i=pos-1;i<n-1;i++)

list[i]=list[i-1];

b)

for(i=pos-1;i<n-1;i++)

list[i]=list[i*1];

c)

for(i=pos-1;i<n-1;i++)

list[i]=list[i+1];

d)

for(i=pos-1;i<n-1;i++)

list[i]=list[i+2];

6.

Given below, code to display "n" elements in an array which is a list? Fill with appropriate values


for(i=___;i<____;i++)

printf("%d\t",list[i]);

a)

0,n

b)

n,0

c)

0,n-1

d)

n-1,0

7.

(a)   is an ordered collection of elements. Each element in the list is referred as a node.

8.

Which of the following is/are the advantages of Linked list?

a)

Insertion and deletion of elements can be done efficiently

b)

It uses dynamic memory allocation

c)

Memory utilization is efficient compared to arrays

9.

Which of the following is/are not the dis-advantage of Linked list?

a)

Linked list does not support random access

b)

Memory is required to store next field

c)

Searching takes time compared to arrays

d)

None of the above

10.

Give syntax to create a node for Single linked list?

a)

newnode=(struct node *)malloc(sizeof(struct node*));

b)

newnode=(struct node )malloc(sizeof(struct node));

c)

newnode=(struct node *)malloc(sizeof(struct node));

d)

newnode=(struct node )malloc(sizeof(struct node*));

11.

Give routine to insert at the beginning in a linked list whose structure is by struct node, with list head as L and pointer variable as next

a)

newnode->next=next;

L=newnode;

b)

newnode->next=node;

L=newnode;

c)

newnode->next=L;

L=newnode;

d)

newnode->L=next;

L=newnode;

12.

How to insert a node after a position P in singly linked list?

a)

Newnode -> data = P ;

Newnode -> next = p ->next ;

P -> next = newnode ;

b)

Newnode -> data = x ;

Newnode -> next = p ->next ;

P -> next = L ;

c)

Newnode -> data = x ;

Newnode -> next = p ->node ;

P -> nextnode = next ;

d)

Newnode -> data = x ;

Newnode -> next = p ->next ;

P -> next = newnode ;

13.

Which of the following is application of Singly Linked List?

a)

moving pages forward and backward in browser

b)

Giving chance to each player in a multi player game

c)

Implementing Stack

14.

Which of the following is application of Doubly Linked List?

a)

moving pages forward and backward in browser

b)

Giving chance to each player in a multi player game

c)

Implementing Stack

15.

Which of the following is application of Cicularly Linked List?

a)

moving pages forward and backward in browser

b)

Giving chance to each player in a multi player game

c)

Implementing Stack

16.

Which of the following is correct way to create node structure for Doubly linked list?

a)

struct node

{

int data;

struct node prev;

struct node next;

struct node link;

};

b)

struct node

{

int data;

struct node next;

};

c)

struct node

{

int data;

struct node prev;

};

d)

struct node

{

int data;

struct node prev;

struct node next;

};

17.

How to create very first node in a Doubly Linked List which is initially empty? Assume head pointer variable is L

a)

newnode->data=X;

newnode->next=L;

newnode->prev=L;

b)

newnode->data=X;

newnode->next=;

newnode->prev=NULL;

list. L=newnode;

c)

newnode->data=X;

newnode->next=head;

newnode->prev=head;

d)

newnode->data=X;

newnode->next=head;

newnode->prev=tail;

list. L=newnode;

18.

how to insert a node at the end of Doubly Linked list?

a)

while(p->next!=NULL)

p=p->next;

newnode->next=NULL;

p->next=newnode;

newnode->prev=p;

b)

while(p->!=NULL)

p=p->next;

newnode->next=NULL;

p->next=newnode;

c)

while(p->next!=NULL)

p=p->next;

newnode->next=NULL;

newnode->prev=p;

d)

while(p->next!=NULL)

p=p->next;

newnode->next=NULL;

p->next=newnode;

newnode->prev=NULL;

19.

Consider a list with head node as L, if one wants to search an element and find its position too, what code he has follow? Assume P is of the type of struct which defines the list.

a)

for(P=L;P!=NULL;P=P->next)

{

if(P->data==a)

{ flag=1;

printf(“\nThe element is found”);

}

}

b)

for(P=L;P!=NULL;P=P->next)

{ count++;

if(P->data==NULL)

{

printf(“\nThe element is found”);

printf(“\nThe position is %d”,count);

}

}

c)

for(P=L;P!=NULL;P=P->next)

{ count++;

if(P->data==a)

{ flag=1;

printf(“\nThe element is found”);

printf(“\nThe position is %d”,count);

}

}

d)

for(P=L;P!=data;P=P->next)

{ count++;

if(P->data==a)

{ flag=1;

printf(“\nThe element is found”);

printf(“\nThe position is %d”,count);

}

}

20.

Design structure for Polynomial manipulation

a)

struct poly

{ int coeff;

int power;

struct poly *next;

}

b)

struct poly

{

int power;

int var;

int expo;

struct poly *next;

}

c)

struct poly

{ int coeff;

int power;

}

d)

struct poly

{ int coeff;

struct poly *next;

}