Week10:
Sorting big-Oh
In this week, I leaned some techniques to make codes of A2 during the lecture, and some sorting methods and their running time. I thought I completed the A2, but I found a huge mistake in regex_match. It is that I processed a regular expressions of Regex (e.g. '(1|0)') to find if it matches a String. I had to process RegexTree instead of the regular expression. I rewrote every code in regex_match.
Searching linear takes more time to find a data because we must research every element in the list. There are some methods which find a value faster than linear search.
Quick sort: First, pick up one item from the list and compare it with each item in the list. If item in the list is greater than the item picked,put it on left side of the picked item. If item in the list is less than the item picked, put it on right side of the picked item. Then, use quick sort to the items in left side of the picked item and items in right side of picked item.
Merge sort: First, divide a list into two list. Then compare last items of each list and append bigger items to the empty list and pop the item from formal list. Continue this work until two list become empty. Finally, reverse the new list which contains every item.
0 件のコメント:
コメントを投稿