Home - marzoukali/cs-notes GitHub Wiki

Programming languages basics:

Data Structures:

  • A data structure is a particular way of organizing data in a computer so that it can be used effectively.

Data Structures Categories:

  • Primitive or Non-primitive:

1- Primitive Data Structures (Integer, float, char, pointer).

2- Non-primitive Data Structures (Array, List [Non-Linear: Tree, Graph & Linear: Stack, Queue], File).

  • Physical or Dynamic:

1- Physical Data Structures (Arrays, Matrices, Linked Lists).

2- Dynamic Data Structures (Stack, Queue, Tree, Graph, Hash Table).

Algorithms

Sorting:

  • Sorting is arranging the elements in a list or collection in increasing or decreasing order of some property.
  • One of the most important benefits of sorting is if the list is unsorted so we have no option to search than the linear search O(n) but we can use binary search O(logn) which is much faster when a list is sorted.

Sorting Algorithms:

  • Selection Sort
  • Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
  • Heap Sort
  • Counting Sort
  • Radix Sort

Classifications:

1- Time Complexity.

2- Space Complexity (Memory Usage): - In-Place (Constant Memory). - Memory space grows with input size.

3- Stability: A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted. Some sorting algorithms are stable by nature like Insertion sort, Merge Sort, Bubble Sort, etc. And some sorting algorithms are not, like Heap Sort, Quick Sort, etc.

4- Internal or External Sort: For Internal, or records are in main memory or RAM. For external, all records are on disk/tape.

5- Recursive (Quick or Merge) or Non-recursive.