[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Data Structures :: Linked Lists - Discussion

Home > Data Structures > Linked Lists > MCQs Questions Discussion

17 / 48

What does the following function return, if q contains the address of the first element?

int function(NODE *q) { int c = 0; while( q != NULL) { q = q->link; c++; } return (c); } ?

AThe value of the last node of the linked list

BThe value of the first elements of the linked list

DThe number of elements in a linked list

Show Explanation

Consider list1 and list2 linked lists given below:

list1: 15 -> 18 -> 25 -> 30

list2: 11 -> 14 -> 17 -> 23 -> 32 -> 56

What will be the elements of the queue that is returned by the code snippet given below when list1 and list2 are passed as arguments to function, fun?

def fun(input_list1,input_list2):

output_queue = Queue(10)

while(temp1 != None and temp2 != None):

if(temp1.get_data() < temp2.get_data()):

output_queue.enqueue(temp1.get_data())

temp1 = temp1.get_next()

elif(temp1.get_data() > temp2.get_data()):

output_queue.enqueue(temp2.get_data())

temp2 = temp2.get_next()

else:

output_queue.enqueue(temp2.get_data())

temp1 = temp1.get_next()

temp2 = temp2.get_next()

while(temp1 != None):

output_queue.enqueue(temp1.get_data())

temp1 = temp1.get_next()

while(temp2 != None):

output_queue.enqueue(temp2.get_data())

temp2 = temp2.get_next()

return output_queue

Note: Order of displaying the queue elements is from front to rear.

Select one:

Rate This: +0 -0

Rate This: +0 -0

Rate This: +0 -0

Rate This: +0 -0

Rate This: +0 -0

Rate This: +0 -0