Skip to main content

Difference between Array and Linked List

 Difference between Array and Linked List

Hello Friends, Today we will tell you the difference between array and linked list, So let's start this guys.



Both Arrays and linked list are used for store the linear data but arrays allocate the contiguous memory location in Compile time while linked list allocate the memory in run time.

This is basic and most important difference .Now, we will read the other main difference,

  1. Array is an ordered collection of same data type but linked list is ordered collection of same type of element which is connected to each other by pointers.
  2. Array supports random access which means that we can access this directly by index.e.g. For 1st element arr[0] , for 7th element arr[6] etc. while Linked list supports sequential access which means that in linked list for access any elements/nodes we have to sequentially traverse the full list.
  3. Arrays store the elements in contiguous memory location while In linked list a new elements can be store anywhere.
  4. In Arrays, elements can access very fast and time complexity is O(1) While time complexity of linked list is O(n).
  5. In Arrays, insertion and deletion operation takes longer because memory locations are continuous and fixed but In Linked list, Insertion and deletion operation are very fast.
  6. In the Array memory allocates in compile time and it is also called Static memory allocation  But in Linked list, memory allocates in run time and it is also called Dynamic memory allocation.
  7. In Array, each elements are free and we can access it through their index value but In linked list, Each node are pointed by before and next nodes.
  8. Array can be single dimensional , two dimensional or multi dimensional while Linked list can be linear (singly),doubly and circular.
  9. In array, the size of array is specified at the time of declaration but in linked list the size of linked list is increases in run time, as new node add in this.
Note: If you Liked this difference between array and linked list , then please tell me in the comment and please share it to your friends .

Thank you!



Comments

Popular posts from this blog

Top 10 Engineering Colleges in India: A Comprehensive Guide in 2023

Engineering is a highly sought-after field in India, and choosing the right college is crucial for a successful career. In this blog, we will explore the top 10 engineering colleges in India, highlighting their reputation, academic excellence, infrastructure, placement records, research and innovations, student life and extracurricular activities, scholarship and financial aid opportunities, alumni networks, as well as their accreditation and affiliations. As of  cutoff in June 2023, here are the top engineering colleges in India according to the National Institutional Ranking Framework (NIRF) ranking: 1. Indian Institute of Technology Madras (IIT Madras): Indian Institute of Technology Madras (IIT Madras) is one of the premier engineering colleges in India. Here are some key points regarding its reputation, academic excellence, infrastructure, placements, research and innovations, student life and extracurricular activities, scholarships and financial aid, alumni network, and accredit

Automata Lab Assignment

 Assignment Lab Assignment Lab Assignment -01 Write a C program for pattern Searching .   C code: #include <stdio.h> #include <string.h> int  match ( char   [ ] ,   char   [ ] ) ; int  main ( )   {    char  a [ 100 ] ,  b [ 100 ] ;    int  position ;    printf ( "Enter some text \n " ) ;    gets ( a ) ;    printf ( "Enter a string to find \n " ) ;    gets ( b ) ;   position  =  match ( a ,  b ) ;    if   ( position  !=   - 1 )   {      printf ( "Found at location: %d \n " ,  position  +   1 ) ;    }    else   {      printf ( "Not found. \n " ) ;    }    return   0 ; } int  match ( char  text [ ] ,   char  pattern [ ] )   {    int  c ,  d ,  e ,  text_length ,  pattern_length ,  position  =   - 1 ;   text_length     =   strlen ( text ) ;   pattern_length  =   strlen ( pattern ) ;    if   ( pattern_length  >  text_length )   {      return   - 1 ;    }    for   ( c  =   0 ;  c  <=  text_length  -  pattern_length ;  c ++ )   {     p

Advantage and Disadvantage of Data Structure

 Advantage and Disadvantage of Data Structure Hello friends, in today's post we will see advantage and disadvantage of data structure also need of data structure. So, let's start this.. What is the need of Data structure? As applications are getting complex and data rich, there are three common problems applications face now-a-days. Data Search: Consider an inventory of 1 million items of a store. If application is to search an item. It has to search item in 1 million items every time slowing down the search. As data grows, search will become slower. Processor Speed: Processor speed although being very high, falls limited if data grows to billion records. Multiple requests: As thousands of users can search data simultaneously on a web server, even very fast server fails while searching the data. To solve the above problems, data structures come to rescue. Data can be organized in a data structure in such a way that all items may not be required to be search and required data ca