CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Consider the function f defined below:

struct item
{
int data;
struct item *next;
};
int f(struct item *p)
{
return (
(p == NULL)
(p next == NULL
((pdata <= p next data )
&& f(p next))
);
}

For a given linked list p, the function f returns 1 if and only if

A
the elements in the list are sorted in non-increasing order of data value
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
not all elements in the list have the same data value
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
the list is empty or has exactly one element
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
the elements in the list are sorted in non-decreasing order of data value
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution

The correct option is D the elements in the list are sorted in non-decreasing order of data value
For given linked list p, the function f returns 1 if and only if the elements in the list are stored in non-decreasing (increasing) order of the data value.

f returns 1 if p == NULL or p Next == NULL or p data <=pnext data,
satisfies in linked list for every node p.

flag
Suggest Corrections
thumbs-up
0
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Sets and Their Representations
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon