Data Structures and Algorithms 😍😍😍

Quick info of Data Structures and Algorithms to code these data structures

Searching Techniques

Binary Search Iterative

Binary search iterative

Binary Search Recursive

Sorting Techniques

1. Quick Sort / Partition Sort

Partition procedure

  • Select the pivot element which is the first element of the array

  • Mark first element as 'i' and the last element as 'j'

  • Increment i if arr[i] <= pivot

  • Decrement j if arr[j] > pivot

  • After incrementing i and decrementing j as per the last two steps, swap arr[i] and arr[j]

  • Once i crosses j, in other words, if j>i then swap arr[j] with pivot and return j

Now, after the partition procedure, we'll get two parts, the left partitioned and the right partitioned part. Perform quick sort recursively on both these parts.

Time-complexity of quicksort

  • If the list is sorted in ascending or descending order then the list is traversed 1+2+3+4...+n so it'n^2

  • The worst case is therefore n^2

  • The best case happens when j appears at the center of the list. In this case, it will be nlogn

2. Bubble Sort

3. Selection Sort

4. Merge Sort

5. Count Sort

6. Radix Sort

7. Bin / Bucket Sort

8. Shell Sort

Linked List

Operations

  1. Display linked list

  2. Insert an element at first place (head)

  3. Insert an element at last place

  4. Insert an element at any place (index)

  5. Get the element at an index

  6. Delete an element

  7. Delete all elements

  8. Reverse linked list (2 ways -> copy to array and back, reverse links)

  9. Concatenate two linked lists

  10. Merge two linked lists

LinkedList vs Array

Last updated

Was this helpful?