LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-03-2004, 12:29 PM   #16
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43

Quote:
I am still a student.
me too

you'll get all this nonsense in whatever your data structures or algorithms course is. To summarize:

Arrays: Fast indexing, fast iteration small footprint, but slow appending, prepending, and insertion

Linked lists: Slow indexing, fast iteration, slightly larger footprint, fast appending*, prepending, and insertion

* but be sure to keep a tail pointer if you want to append quickly
 
Old 10-03-2004, 01:05 PM   #17
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
Quote:
Originally posted by aluser
me too

you'll get all this nonsense in whatever your data structures or algorithms course is. To summarize:

Arrays: Fast indexing, fast iteration small footprint, but slow appending, prepending, and insertion

Linked lists: Slow indexing, fast iteration, slightly larger footprint, fast appending*, prepending, and insertion

* but be sure to keep a tail pointer if you want to append quickly

Actually for linked lists, insertion at a random location (slow indexing remember) is slow due to the need to traverse the list, giving O(n) performance in the average case.

In addition linked list has the same problem with replacing the node at at particular position. An array can achieve it in constant time. You win some, you lose some.

Last edited by mirradric; 10-03-2004 at 01:08 PM.
 
Old 10-03-2004, 01:41 PM   #18
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
true -- usually when you talk about insertion you assume you already have an iterator where you mean to insert.
 
Old 10-04-2004, 02:00 PM   #19
Omarel
LQ Newbie
 
Registered: Nov 2003
Distribution: Slackware
Posts: 12

Rep: Reputation: 0
Yes, I know the times Anyway the truth is as mirradric said, always u win smth but also u lose smth :P.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sizeof and malloc in C exvor Programming 4 08-07-2005 12:06 PM
malloc eagle683 Programming 6 05-22-2005 02:40 PM
malloc() vijeesh_ep Programming 4 08-25-2004 03:50 PM
malloc debugger legolas_t Programming 3 07-04-2004 01:32 PM
about malloc eshwar_ind Programming 11 02-18-2004 03:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration