Question Insert Question 

Forum: Com Sci 221, U Chicago, Autumn 2001, Old Classwork
Re: News Assignment #5, due 29 October (Mike O'Donnell)
Date: 2001, Oct 29
From: Avi Schwab ajschwab

Ok... I have a question about the insert procedure for the sparse arrays we are implimenting in this problem. My question is due to the fact that this is a sparse array, which in principle does not have to have sequential indices. So, due to the fact that this is not just an ordered list, what index should we use when we insert into the "array"? For a normal sparse array, we would specify an insertion index, but in this problem that would 1) not allow bsearch to be used and 2) not always result in an ordered array. My only guess is to use the index directly after the index found by the search, which really makes the whole "sparse" idea pretty useless. Any ideas?

For clarification: Say we have an array with indices: 1,6,20,66 and values: 1,6,20,66 respectively. I want to insert the value 50. Would it just go in the 21st index (making the sparse array useless)? Or could we specify some index to insert (e.g. 50) without making the binary search call useless?

I hope this is understandable.

Avi


Messages

1. Feedback Insert requires an index and a value by Mike O'Donnell, 2001, Oct 29
(_ None Thanks by Avi Schwab, 2001, Oct 29

to: "Insert Question"