# Data Structure

## How to reverse a linked list?

Reversing Linked List is an interesting topic in data structure and algorithms. This article describes several algorithms to implement the reverse-linked list. Reverse a Linked List: LinkedList is a data structure that stores data in a linear fashion. It is not a continuous method. Each element of a LinkedList contains a piece of information and …

## How to swap nodes in a linked list without Swapping data?

Given a linked list and two keys in it, swap the node for two given keys. You need to change the link to replace the node. If the data contains many fields, exchanging data at the node can be expensive in many situations. It can assume that all keys in linked list are separate. This …

## How to write C functions that modify head pointer of a Linked List?

Consider a simple representation of the linked list (no dummy nodes). The functions that manipulate these linked lists can be divided into two categories: 1) The function does not change the head pointer: Printing the linked list, there is a function, such as all nodes in the node data members, such as add value update, …

## Find Length of a Linked List (Iterative and Recursive)?

Both recursion and iteration execute a series of instructions repeatedly. Recursion is when a declaration in a function repeatedly calls itself. Iteration means that the loop repeats itself until the control condition goes false. The main difference between recursion and iteration is that recursion is a process and always applies to a function. Iteration is …

## A Programmer’s approach of looking at Array vs. Linked List

Arrays are generally considered data structures that are fixed in size at compile time and whose array memory is allocated from a data section (such as a global array) or a stack section (such as a local array). Similarly, a linked list is considered a data structure that does not have a fixed size and …

Deletion of the linked list can occur in different parts of the list. Some cases are: Beginning of the linked list. End of the linked list. Given position in the linked list. Let’s take a look at the schedule for each of these cases. 1. Deletion at beginning of the linked list: To remove the …

## How to delete a node in a linked list at a given Location?

Introducing linked lists and inserting linked lists was covered in a previous post on linked lists of data structures and algorithms. Let’s create a problem statement to understand the removal process. Specify a “key” to remove the first occurrence of this key in the linked list. Iterative method: To remove a node from the linked …

A linked list is a set of data structures interconnected by links. A linked list is a set of links that contains items. Linked lists are the second most widely used data structure after arrays. Insertion in Linked list: There are three situations for inserting element in list. Insertion at the beginning. Insertion in the …

## Differences between Arrays and Linked Lists?

Both arrays and linked lists are used to store similar types of linear data, but arrays consume contiguous memory locations allocated at compile time, that is, when an array is declared, but for linked lists. Memory is allocated data as follows: Will be added to this. That is, at run time. For example, Arrays are …