Data Structure Questions and Answers-Circular Linked List

 

 Buy/Download all MCQ Ebook   >>>Click Here<<<

Data Structure Questions and Answers-Circular Linked List

Click on any option to know the CORRECT ANSWERS

Question 1
What differentiates a circular linked list from a normal linked list?
A
You cannot have the 'next' pointer point to null in a circular linked list
B
It is faster to traverse the circular linked list
C
You may or may not have the 'next' pointer point to null in a circular linked list
D
All of the mentioned
KBC Questions answers

Question 1 Explanation: 
The 'next' pointer points to null only when the list is empty, otherwise it points to the head of the list.

Question 2
How do you count the number of elements in the circular linked list?
A

public int length(Node head) { 	int length = 0; 	if( head == null) 		return 0; 	Node temp = head.getNext(); 	while(temp 
B

public int length(Node head) { 	int length = 0; 	if( head == null) 		return 0; 	Node temp = head.getNext(); 	while(temp 
C

public int length(Node head) { 	int length = 0; 	if( head == null) 		return 0; 	Node temp = head.getNext(); 	while(temp 
D
None of the mentioned
Civics Test Questions answers

Question 2 Explanation: 
If the head is null, it means that the list is empty. Otherwise, traverse the list until the head of the list is reached.

Question 3
What is the functionality of the following piece of code? Select the most appropriate

public void function(int data) { 	int flag = 0; 	if( head != null) 	{ 		Node temp = head.getNext(); 		while((temp != head) && (!(temp.getItem() == data))) 		{ 			temp = temp.getNext(); 			flag = 1; 			break; 		} 	} 	if(flag) 		System.out.println("success"); 	else 		System.out.println("fail"); }
A
Print success if a particular element is not found
B
Print fail if a particular element is not found
C
Print success if a particular element is equal to 1
D
Print fail if the list is empty
Public administration Questions answers

Question 3 Explanation: 
The function prints fail if the given element is not found. Note that this option is inclusive of option d, the list being empty is one of the cases covered.

Question 4
What is the time complexity of searching for an element in a circular linked list?
A
O(n)
B
O(nlogn)
C
O(1)
D
None of the mentioned
Sociology Questions answers

Question 4 Explanation: 
In the worst case, you have to traverse through the entire list of n elements.

Question 5
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
All of the mentioned
History Questions answers

Question 5 Explanation: 
Generally, round robin fashion is employed to allocate CPU time to resources which makes use of the circular linked list data structure.

There are 5 questions to complete.