SparkNotes Shopping Cart  |     |  Checkout
Brought to you by Barnes and Noble
Linear Search
 
 
Problems
Problem 3.1: You are given an array of linked lists (each element in the array points to a linked list), as follows:
typedef struct _list_t_ {
	int data;
	struct _list_t_ *next;
} list_t;

list_t *arr[100];
Write a function to find the largest data element in any of the lists. [Solution]
Problem 3.2: You are given a malformed linked list in which one of the list element's next pointer points back to the same element. Write a function to return a pointer to the list structure with the incorrect next pointer. [Solution]
Problem 3.3: You are given a pointer to somewhere in the middle of a doubly-linked list of integers:
typedef struct _list_t_ {
	int data;
	struct _list_t_ *next;
	struct _list_t_ *prev;
} list_t;


Find the largest element in the list.
[Solution]
Problem 3.4: If a linked list were in sorted order, would you be able to write a search routine that worked in less than O(n) time? [Solution]
Problem 3.5: Given a singly-linked list, return a pointer to the first element whose data field is less than or equal to the data element of the last value in the list. [Solution]
Help | Feedback | Make a request | Report an error | Send to a friend
 
Master the AP Calculus AB-BC exam—and in just five days!
More...
 
Let our Physics Study Cards exercise your mind without cramping your style.
More...
 
 
Go to top