Minimum Spanning Trees
What is Sorting?
Given a list of random numbers, sorting means ordering the numbers in either ascending or descending order. By default, we sort numbers in an ascending order.
Unsorted and Sorted Arrays
Time and Space Complexity
- Time complexity of an algorithm gives the measure of time taken by it to run as a function of the length of the input. Similarly, Space complexity of an algorithm quantifies the amount of space or memory taken by an algorithm to run as a function of the length of the input.
- Recall that suppose our input is an array of N elements, and our algorithm iterates through the array once, time complexity will be O(N). If I run two embedded loops to traverse the array N times, time complexity will be O(N2).
Trees and Graphs
- Tree is an abstract data structure that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.
- Graph with all vertices connectes is a connected graph and a tree that covers all vertices in graph is called spanning tree.
- Graphs with a weight to edges is called weighted graph,Graphs with directions is directed graph.