Linear Search


Problems

Problem : 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.


Problem : 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.


Problem : 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.


Problem : 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?


Problem : 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.


Take a Study Break

SparkLife

What's your Pretty Little Liars name?

Take this quiz to find out!

SparkLife

Which young actress just got married?

Click to find out!

SparkLife

Cat bearding WINS THE INTERNET

Have you seen this yet?

SparkLife

Scary movies with funny posters

These. Are. Hilarious.

Geek out!

The MindHut

Geeky Actors: Then and Now

Travel back in time!

The MindHut

Villains We Want These Actresses to Play

From super cute to super bad!

The MindHut

10 Movies Better Than Their Books

What do you think?

The MindHut

Summer Movie Open Thread

Leave your thoughts here!

The MindHut

12 Scientific Inaccuracies in Into Darkness

What did Star Trek get wrong?

The Book

Cover image

Read What You Love, Anywhere You Like

Get Our FREE NOOK Reading Apps