Articles for author: Sushant Gaurav

Time and Space Complexity of Selection Sort

Time complexity measures the execution time of an algorithm’s instructions. For the selection sort, the average, worst-case, and best-case time complexity of the selection sort are all $O(N^2)$, and the space complexity is O(1), indicating it requires a constant amount of extra storage space. Time Complexity of Selection Sort The Time complexity of Selection Sort ...

Sort a Linked List

A linked list is a sequential collection of data elements connected via links. The data element of a linked list is known as a node which contains two parts namely- the data part and the pointer. For sorting a linked list, we can use the insertion sort-based algorithm as well as the merge sort algorithm. The insertion sort-based algorithm uses ...

Dictionary in Data Structure

A dictionary in data structure is used to store the data in the form of key-value pair. The dictionary in data structure has an attribute called the key. The key is the attribute that helps us locate the data or value in the memory. A dictionary in data structure supports a wide variety of operations using a wide ...

Rearrange Array Alternately

Problem Statement We are provided with a sorted array of size n and we need to rearrange the array alternately. By rearrange array alternately, we should rearrange the array so that the first greatest element will come at the first position, and the first smallest element comes at the second position. Similarly, the second greatest element comes at ...

Primitive Data Structure

The data structures are nothing but a meaningful way of arranging, and storing the data in the computer for efficient utilization and processing depending upon the situation. A primitive data structure can store the value of only one data type. For example, a char data structure (a primitive data structure) can store only characters. The ...

Classification of Data Structure

The data structures are nothing but a meaningful way of arranging, and storing the data in the computer for efficient utilization and processing depending upon the situation. A primitive data structure can store the value of only one data type. The size of a primitive data structure is known as it can store can only ...

Median of Two Sorted Arrays

Median of Two Sorted Arrays of Same Size Before getting into the problem statement of finding the median of two sorted arrays, let us first get a brief introduction about the arrays. An array is a linear collection of values stored at contiguous memory locations. Array stores homogeneous values(similar data type values). To learn more ...

Find Second Largest Number in Array

You are given an array of numbers (integers) and the task is to find second largest number in array. Takeaways The most efficient approach to find second largest number in array uses only one loop. Find Second Largest Element in an Array Refer to the Example and Explanationsections for more details about how to find second largest number ...

Reverse Doubly Linked List

Problem Statement You are given a pointer or reference to the doubly linked list’s head node and the task is to reverse a doubly linked list (the order should be reversed). After changing the order, you need to return the pointer or reference to the head node of the reversed doubly linked list. Refer to the example and explanation section for more details and the approach section to understand ...