Select the correct option to test your answer:
Computer
Miscellaneous On Data Structures
Difficulty: Medium
What does the following code do? #include<stdio.h> #include<stdlib.h> struct Node { int val; struct Node* next; }*head; int linear_search(int value) { struct Node *temp = head->next; while(temp != 0) { if(temp->val == value) return 1; temp = temp->next; } return 0; } int main() { int arr[5] = {1,2,3,4,5}; int n = 5,i; head = (struct Node*)malloc(sizeof(struct Node)); head->next = 0; struct Node *temp; temp = head; for(i=0; i<n; i++) { struct Node *newNode = (struct Node*)malloc(sizeof(struct Node)); newNode->next = 0; newNode->val = arr[i]; temp->next = newNode; temp = temp->next; } int ans = linear_search(60); if(ans == 1) printf("Found"); else printf("Not found"); return 0; }
More Computer Questions
The topological sorting of any DAG can be done in . . . . . . . . time.
A relation is considered a:
Which of the following is an NP complete problem?
Which of these method of class String is used to obtain length of String object?
Which of the following keyboard shortcuts is used to move through each of the open tabs going to the left in a Chrome browser?