0% found this document useful (0 votes)
24 views2 pages

Dsa Reviewer

The document compares and contrasts arrays and linked lists. Arrays are better for random access, searching, and insertion/deletion at the end. Linked lists are better for sequential access and situations where the number of elements is unknown. The document also describes the basic components and operations of linked lists like nodes, pointers, and insertion/deletion.

Uploaded by

djay vllflr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Dsa Reviewer

The document compares and contrasts arrays and linked lists. Arrays are better for random access, searching, and insertion/deletion at the end. Linked lists are better for sequential access and situations where the number of elements is unknown. The document also describes the basic components and operations of linked lists like nodes, pointers, and insertion/deletion.

Uploaded by

djay vllflr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Link − Each link of a linked list can store a data called an • All items in list have same data

same data type


element. • All list members stored using single group name.
Next − Each link of a linked list contains a link to the next Two Dimensional (2D) Array
link called Next. • is organized as a matrix with a number of rows
LinkedList − A Linked List contains the connection link to and columns.
the first link called First.
Array Representation
Array versus Linked Lists • Index starts with 0.
• Array length is 10 which means it can store 10
Arrays are suitable for: elements.
-Inserting/deleting an element at the end. • Each element can be accessed via its index. For
-Randomly accessing any element. example, we can fetch an element at index 10 as 9.
-Searching the list for a particular value. Traversing
• print all the array elements one by one.
Linked lists are suitable for: Searching
-Inserting an element. • Searches an element using the given index or by
-Deleting an element. the value.
-Applications where sequential access is required. Insertion
-In situations where the number of elements cannot • Adds an element at the given index.
be predicted beforehand. Deletion
• Deletes an element at the given index.
Linked list can be visualized as a chain of nodes, where Update
every node points to the next node. • Updates an element at the given index.
Linked list
Types of Linked List • is a sequence of data structures, which are
connected together via links/nodes.
Simple Linked List − Item navigation is forward only. • is a sequence of links which contains items.
Doubly Linked List − Items can be navigated forward and • is the second most-used data structure after
backward. array.
Circular Linked List − Last item contains link of the first
element as next and the first element has a link to the NULL
last element as previous. • The last element in a linked list.
Linked lists provide flexibility in allowing the items to be
Basic Operations rearranged efficiently.
• Insert an Element
Insertion − Adds an element at the beginning of the list. • Delete an Element
Deletion − Deletes an element at the beginning of the Link
list. • Each item stored in an array.
Display − Displays the complete list. Next
Search − Searches an element using the given key. • Each link of a linked list contains a link to the
Delete − Deletes an element using the given key. next link called Next.
LinkedList
Derived Data Type • contains the connection link to the first link
• Those data types which are implementation called First.
independent as they can be implemented in one or the Arrays are suitable for:
other way are known as derived data types. • Inserting/deleting an element at the end.
Array Data Structure • Randomly accessing any element.
• is a fundamental element of computer • Searching the list for a particular value.
programming that creates collections of individual Linked lists are suitable for:
elements, each of which has its own array index or key. • Inserting an element.
• It is a container which can hold a fix number of • Deleting an element.
items and these items should be of the same type. • Applications where sequential access is
Element required.
• Each item stored in an array. • In situations where the number of elements
Index cannot be predicted beforehand.
• Each location of an element in an array has a
numerical index, which is used to identify the element.
One-Dimensional Array (Single-Dimension Array or
Vector)
Singly Linked List
• Item navigation is forward only.
Doubly Linked List
• Items can be navigated forward and backward.
Circular Linked List
• Last item contains link of the first element as
next and the first element has a link to the last element
as previous.
Following are the basic operations of linked list:
Insertion
• Adds an element at the beginning of the list.
Deletion
• Deletes an element at the beginning of the list.
Display
• Displays the complete list.
Search
• Searches an element using the given key.
Delete
• Deletes an element using the given key.

Representation:
• A linked list is represented by a pointer to the
first node of the linked list.
• The first node is called the head. If the linked list
is empty, then the value of the head is NULL.
Pointer
• is a variable that stores the memory address as
its value.
Pointer Variable
• points to a data type (like int or string) of the
same type, and is created with the * operator.
Operator
• The address of the variable you're working with
is assigned to the pointer.

You might also like