LINKED LISTS Flashcards

1
Q

Define and illustrate a linked list

A

Linked list is simply a chain of self-referential data nodes.
*See notes for pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a list node

A

The list node is a simple self-referential structure that stores an item of
data, and a reference to the next item.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the end and start of a linked list

A

• The end of the list is defined by a null next reference.
• The start (or head) of the list is contained in a header class, which also
encapsulates all the list’s functionality. This helps the linked list become
an independent, cohesive package.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the advantages of linked lists

A

• Size of linked lists is not fixed, they can expand and
shrink during run time.
• Insertion and Deletion Operations are fast and easier in
Linked Lists.
• Memory allocation is done during run-time (no need to
allocate any fixed memory).
• Data Structures like Stacks, Queues, and trees can
be easily implemented using Linked list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between singly linked lists and arrays

A
  • Singly Linked Lists store elements in linear order, accessible with links (can’t be random) while arrays store elements in linear order but accessible with an index (can be random)
  • Singly linked lists do not have fixed sizes while arrays have fixed sizes

-In arrays data elements are stored in contiguous locations in
memory while in SLLs new elements can be stored anywhere and a
reference is created for the new element using
pointers.

-Array- Memory is allocated during the compile time (Static
memory allocation). While SLL- Memory is allocated during the run-time (Dynamic
memory allocation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe a doubly linked list

A

• Each node contains a value, a link to its successor (if any), and a link to its predecessor (if any)
• The header points to the first node in the list and to
the last node in the list (or contains null links if the list
is empty)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the advantages of doubly linked lists over singly linked lists

A

– Can be traversed in either direction (may be essential for some programs)
– Some operations, such as deletion and inserting before a node, become easier.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the disadvantages of doubly linked lists over singly linked lists

A

– Requires more space
– List manipulations are slower (because more links must be changed)
– Greater chance of having bugs (because more links must be manipulated)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the Advantages of Circular Linked List

A

We can go to any node from any node in the Circular linked list which was not possible in the singly linked list
if we reached the last node.
• Easily we can go to head from the last node
• In a circular list, any node can be starting point means
we can traverse each node from any point.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the disadvantages of Circular Linked List

A
  • If not handled proper validation then code may go in an infinite loop.
  • Not easy to reverse a circular linked list.
  • For the implementation perspective to insert at the beginning we have to traverse the complete list to find the last node.
  • Harder to find the end of the list and loop control.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain any TWO challenges of an array data structure, which have been addressed by a LinkedList

A

Better use of Memory:
From a memory allocation point of view, linked lists are more efficient than arrays. Unlike arrays, the size for a linked list is not pre-defined, allowing the linked list to increase or decrease in size as the program runs.

Fast Insertion/Deletion Time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly