DEV Community

Kartik Kumar
Kartik Kumar

Posted on

cs50x week3 learnings :-)

Week 3 completed

As the weeks are passing, more challenges are coming in solving the problem sets.
This week 3 was about the algorithms. The challenging part for me in this week was to understanding the concept of time complexity notations like BIG O , Omega and theta.

Also got familiar with searching and sorting algorithms.
A) Linear search - we compare required element with each element in the list until we found.

B) Binary search - list must be sorted to apply binary search. then we start from middle and check if the required element is in the left part or right , then again we divide and conquer.

C) Bubble Sort - We usually bubbles the highest element to the last of the list. Procedure is swapping the adjacent elements if not in order in whole list. Then repeat again but not checking the sorted elements. If no swaps in first pass then elements are sorted.

D) Selection Sort - In this we search the smallest element from the list of unsorted array and swaps the smallest element with the first element of the unsorted array.

E) Merge Sort - In this we simply divide the list in two, then sort the left half and then right half and then merge.

Top comments (0)