Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit I- CS8391 Data structure

Total questions: 25

Worksheet time: 57mins

Name
Class
Date
1.

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

a)

log2 n

b)

n

c)

log2 n-1

d)

n/2

2.

The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is

a)

283

b)

142

c)

71

d)

45

3.

In Which data structure is used to traverse the elements in forward and backward direction

a)

Circular singly linked list

b)

Doubly linked list

c)

Circular linked list

d)

Singly Linked list

4.

The condition that occurs when an attempt is made to insert data into a full data structure is

a)

Overflow

b)

Underflow

c)

None

d)

Void

5.

Header(Sentinel/Dummy) in data structure list is used to point to

a)

First node of list

b)

Last node of the list

c)

Null value

d)

None

6.

. In a linked list when an element is inserted

a)

Memory is allocated to a node

b)

Memory is deallocated to the node

c)

Neither memory is allocated nor deallocated

d)

None

7.

What kind of linked list is best to answer question like "What is the item at position n"?

A.

B.

C.

D.

a)

Singly linked list

b)

Doubly linked list

c)

Circular linked list

d)

Array implementation of linked list

8.

In a Circular doubly linked list the previous pointer of the first node

(a)  

9.

To delete the 6th element from singly linked list, the operation sequence is

(i) Link the 5th node to 7th node (ii) Free the 6th node (iii) Locate 5th and 6th node

a) b) c) iii,i,ii d) i,ii,iii

a)

ii,i,iii

b)

ii,iii,i

c)

iii,i,ii

d)

i,ii,iii

10.

Which of the following application makes use of a circular linked list?

a)

Undo operation in a text editor

b)

Recursive function calls

c)

Allocating CPU to resources

d)

Implement Hash Tables

11.

Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only.

Given the representation, which of the following operation can be implemented in O(1) time?


i) Insertion at the front of the linked list

ii) Insertion at the end of the linked list

iii) Deletion of the front node of the linked list

iv) Deletion of the last node of the linked list

a)

I and II

b)

I and III

c)

I, II and III

d)

I, II and IV

12.

Which of the following operations is performed more efficiently by doubly linked list than by singly linked list.

a)

Deleting a node whose location is given

b)

Searching an unsorted list for a given item

c)

Inserting a node after the node with a given location

d)

Traversing the list to process each node.

13.

The minimum number of fields with each node of doubly linked list is

a)

1

b)

2

c)

3

d)

4

14.

Consider the following definition in c programming language. Which of the following c code is used to create new node?

struct node

{

int data;

struct node * next;

}

typedef struct node NODE;

NODE *ptr;

a)

ptr = (NODE*)malloc(sizeof(NODE));

b)

ptr = (NODE*)malloc(NODE);

c)

ptr = (NODE*)malloc(sizeof(NODE*));

d)

ptr = (NODE)malloc(sizeof(NODE));

15.

Which of the following types of expressions does not require precedence rules for evaluation?

a)

Fully parenthesized infix expression

b)

Partially parenthesized infix expression

c)

Both A) and B)

d)

Prefix expression

16.

In the linked list implementation of the stack class, where does the push method place the new entry on the linked list?

a)

At the head

b)

At the tail

c)

After all other entries that are greater than the new entry.

d)

After all other entries that are smaller than the new entry

17.

Suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through data[9]. The CAPACITY is 42. Where does the push method place the new entry in the array?

a)

data[0]

b)

data[1]

c)

data[9]

d)

data[10]

18.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(())) are:

(a)  

19.

What is the value of the postfix expression 6 3 2 4 + – *?



(a)  

20.

The following sequence of operations is performed on stack: PUSH (10),PUSH (20),POP,PUSH (10),PUSH (20),POP,POP,POP,PUSH (20),POP The sequence of the value popped out is:

(a)  

21.

What will be the output of the below program? Three minutes

int main()

{

stack< string, vector<string> > s;

s.push( "me" );

s.push( "talk" );

s.push( "to" );

while ( !s.empty() )

{

cout << s.top() << " ";

s.pop();

}

cout <<"\n\n\n";

return 0;

}

a)

talk to me

b)

to talk me

c)

me talk to

d)

me to talk

22.

Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?

a)

Possible if X is not last node. Use following two steps (a) Copy the data of next of X to X. (b) Delete next of X.

b)

Possible if size of linked list is even.

c)

Possible if size of linked list is odd

d)

Possible if X is not first node. Use following two steps (a) Copy the data of next of X to X. (b) Delete next of X

23.

What is the output of the following function when the list contains the values: 1,4,67,3,45,68,2(head points to the first node- not the dummy node)


void fun1(struct node* head)

{

if(head == NULL)

return;

fun1(head->next);

printf("%d ", head->data);

}

a)

2 2 2 2 2 2 2

b)

2 68 45 3 67 4 1

c)

1 67 45 2 4 3 68

d)

1 4 67 3 45 68 2

24.

What is the output of the following function if the given value of n is 81

void fun(int n)

{

Stack S = (stack ) malloc (size of (struct node));

while (n > 0)

{

// This line pushes the value of n%2 to stack S

push(&S, n%2);

n = n/2;

}

while (!isEmpty(&S))

printf("%d ", pop(&S)); // pop an element from S and print it

}

a)

1010001

b)

1000101

c)

1100101

d)

1110011

25.

Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c + d ^ e ^ f is

(a)