✪ Compare 2 consecutive elements. Swap if 1st one is larger than 2nd one.
✪ At the end of each iteration, largest element in the list bubbles up to the top of the list.
2️⃣ Selection Sort
✪ The list is scanned for the smallest element.
✪ At the end of each iteration, this smallest element is swapped with the first element in the list.
3️⃣ Insertion Sort
✪ An element in the list is picked and compared with all other elements prior to it in a reverse order.
✪ If the element is smaller than the compared element, later is shifted to right. Or else the element is inserted next to the compared element.
4️⃣ Merge Sort
It uses Divide-and-Conquer and Recursions.
✪ A list is divided in 2 equal halves. Each half goes for a recursion (calling same function).
✪ It is expected to receive 2 sorted sub lists at the end of recursion
✪ Merge 2 sorted sub lists for a full sorted list
5️⃣ Quick Sort
It uses Divide-and-Conquer and Recursions
✪ A pivot element is chosen and checked for an appropriate position in the list so that smaller elements are left to it and larger elements are right to it
✪ The left and right sub lists do the same through recursion
6️⃣ Counting Sort
✪ The list is scanned for the maximum element
✪ Another list (count list) is created of size (max element + 1) with all 0s.
✪ The list is traversed and count list is updated accordingly with appropriate count.
✪ Based on counts, list is sorted.
7️⃣ Radix Sort
✪ Find the max value in the list. Find out how many digits it has.
✪ Starting from units, then to tens and hundreds etc arrange the elements based on sorted numbers in that digit place.
8️⃣ Bucket Sort
It uses Scatter-Gather approach
✪ First a bucket list is created. Each bucket in the list can contain elements of certain range.
✪ Elements are scattered to buckets
✪ Each bucket is sorted (other sorting technique)
✪ Elements from all buckets are gathered
9️⃣ Heap Sort
It uses heap data structure.
✪ Elements are kept in heap either in Min-Heap or, Max-Heap.
✪ The root is swapped with the right most child node and, then removed from the heap.
✪ Then the heap is heapified and this process continues till the heap is empty.
1️⃣0️⃣ Shell Sort
✪ It uses insertion sort mechanism. But instead of scanning elements one-by-one, it uses a sequence.
Example of a sequence: N/2, N/4, N/8 where N is size of list.
✪ So after each iteration, elements at particular intervals (based on sequence) are sorted.
That's it guys.
All these sorting techniques will individually be described in a 🧵 as part of DSA series. It will be explained both in written and visual format.
Stay tuned for the upcoming threads in this series.
See you soon 👋
• • •
Missing some Tweet in this thread? You can try to
force a refresh
7️⃣5️⃣ Numeric Problems to strengthen your *COMPETITIVE CODING* skill
✪ Are you planning to be a competitive coder?
✪ But not sure how to start?
Don't worry. Here are 75 numeric problems that will certainly improve your competitive coding skill.
Problems listed 👇
1️⃣ Number
1️⃣ Find a digit at a specific place in a number
2️⃣ Find count of digits in a number
3️⃣ Find the largest digit
4️⃣ Find the 2nd largest digit
5️⃣ Find the smallest digit
6️⃣ Find the 2nd smallest digit
7️⃣ Find generic root (sum of all digits) of a number
++
8️⃣ Reverse the digits in a number
9️⃣ Rotate the digits in a number
1️⃣0️⃣ Is the number a palindrome?
1️⃣1️⃣ Find the binary, octal and hexadecimal equivalent
1️⃣2️⃣ Convert a binary, octal and hexadecimal to a decimal
1️⃣3️⃣ Find sum of 'n' numbers
7️⃣5️⃣ Data Structures and Algorithms (DSA) questions
You should be able to master all these in coming days through the upcoming DSA series.
🧵 👇
1️⃣ Algorithms Basics
1️⃣ What is an algorithm?
2️⃣ How to approach to solve a problem?
3️⃣ What is time complexity? How to measure it?
4️⃣ What is space complexity? How to measure it?
2️⃣ Data Structure Basics
5️⃣ What are types of data structures?
6️⃣ What are some mostly used data structure operations?
7️⃣ What is traversal?
8️⃣ How to insert an element?
9️⃣ How to delete an element?
1️⃣0️⃣ How to get an element?
1️⃣1️⃣ How to update an element?