Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What is the difference between an ARRAY and a LIST?
What is the difference between an ARRAY and a LIST?
✍: Guest
Answer1
Array is collection of homogeneous elements.
List is collection of heterogeneous elements.
For Array memory allocated is static and continuous.
For List memory allocated is dynamic and Random.
Array: User need not have to keep in track of next memory allocation.
List: User has to keep in Track of next location where memory is allocated.
Answer2
Array uses direct access of stored members, list uses sequencial access for members.
//With Array you have direct access to memory position 5
Object x = a[5]; // x takes directly a reference to 5th element of array
//With the list you have to cross all previous nodes in order to get the 5th node:
list mylist;
list::iterator it;
for( it = list.begin() ; it != list.end() ; it++ )
{
if( i==5)
{
x = *it;
break;
}
i++;
}
2012-02-02, 3069👍, 0💬
Popular Posts:
What Are the Parameter Modes Supported by PL/SQL? - Oracle DBA FAQ - Creating Your Own PL/SQL Proced...
What is the difference between "calloc(...)" and "malloc(...)"? 1. calloc(...) allocates a block of ...
.NET INTERVIEW QUESTIONS - What is COM ? Microsoft’s COM is a technology for component software deve...
Explain all parts of a deployment diagram? Package: It logically groups element of a UML model. Node...
What is CodeDom? “CodeDom” is an object model which represents actually a source code. It is designe...