|
-
January 29th, 2010, 05:58 PM
#2
Re: Delete_items_from_string
What you would need to do in that case is shuffle b, c, d, and e over one space, and then mark the array as being one shorter.
This is in general why erasing an element from an array is O(n). Other data structures are better for frequent erasures at arbitrary positions.
Of course, erasing an element from the *end* of an array is O(1), since you only need to reduce the apparent array size by 1.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|