Lecture Java Programming Language: Recursion and Advanced Algorithms - Ho Dac Hung
Số trang: 10
Loại file: pdf
Dung lượng: 167.84 KB
Lượt xem: 5
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Lecture Java Programming Language: Recursion and Advanced Algorithms provide knowledge about selection sort, sorting objects, insertion sort, recursion, mergesort, depth-first searching.
Nội dung trích xuất từ tài liệu:
Lecture Java Programming Language: Recursion and Advanced Algorithms - Ho Dac Hung Recursion and Advanced Algorithms Ho Dac Hung1 Selection Sort Sorting is the process of putting items in a designated order, either from low to high or high to low. The selection sort algorithm starts by finding the lowest item in a list and swapping it with the first. Next, the lowest item among items 2 through the last is found and swapped with item 2. This process in continued until the last item is reached, at which point all the items are stored.2 Selection Sort3 Sorting Objects Relational operator cannot be used to compare objects. Objects use methods of their class to determine if one object is greater than, less then, or equal to another. The equals() method in a class is used to determine equality. For determining order, the compareTo() method is used. Objects that are to be sorted must have a class that implements the Comparable interface.4 Insertion Sort An insertion sort starts by sorting the first two items in a list. This sort is performed by shifting the first item into the second spot if the second item belongs in the first spot. Next, the third item is properly inserted within the first three items by again shifting items into their approriate position to make room for the moved item. This process is repeated for the remaining elements.5 Recursion A method can call itself. This process is called recursion and the calls are referred to as recursive calls. Some solution would cause infinite recursion. To prevent these, a recursive solution must have a base case that required no recursion.6 Mergesort The mergesort algorithms takes a “divide and conquer” approach to sorting.7 Binary Search Like the mergesort algorothm, the binary search algorithm also taks a “divide and conquer” approach. It works by examining the middle item of an array sorted from low to high, and determining if this is the item sought, or if the item sought is above or below this middle term.8 Binary Search9 Depth-First Searching The depth-first searching algorithm works by searching from a given starting position, processing that position, and then recursively searching from all adjancent positions.10
Nội dung trích xuất từ tài liệu:
Lecture Java Programming Language: Recursion and Advanced Algorithms - Ho Dac Hung Recursion and Advanced Algorithms Ho Dac Hung1 Selection Sort Sorting is the process of putting items in a designated order, either from low to high or high to low. The selection sort algorithm starts by finding the lowest item in a list and swapping it with the first. Next, the lowest item among items 2 through the last is found and swapped with item 2. This process in continued until the last item is reached, at which point all the items are stored.2 Selection Sort3 Sorting Objects Relational operator cannot be used to compare objects. Objects use methods of their class to determine if one object is greater than, less then, or equal to another. The equals() method in a class is used to determine equality. For determining order, the compareTo() method is used. Objects that are to be sorted must have a class that implements the Comparable interface.4 Insertion Sort An insertion sort starts by sorting the first two items in a list. This sort is performed by shifting the first item into the second spot if the second item belongs in the first spot. Next, the third item is properly inserted within the first three items by again shifting items into their approriate position to make room for the moved item. This process is repeated for the remaining elements.5 Recursion A method can call itself. This process is called recursion and the calls are referred to as recursive calls. Some solution would cause infinite recursion. To prevent these, a recursive solution must have a base case that required no recursion.6 Mergesort The mergesort algorithms takes a “divide and conquer” approach to sorting.7 Binary Search Like the mergesort algorothm, the binary search algorithm also taks a “divide and conquer” approach. It works by examining the middle item of an array sorted from low to high, and determining if this is the item sought, or if the item sought is above or below this middle term.8 Binary Search9 Depth-First Searching The depth-first searching algorithm works by searching from a given starting position, processing that position, and then recursively searching from all adjancent positions.10
Tìm kiếm theo từ khóa liên quan:
Java programming language Bài giảng ngôn ngữ lập trình Java Recursion and advanced algorithms The selection sort The sorting objectsGợi ý tài liệu liên quan:
-
Bài giảng Chương 1: Cơ bản về ngôn ngữ lập trình Java
19 trang 26 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 6.2 - TS. Phan Nguyên Hải
34 trang 25 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Phần 2 - TS. Vũ Hữu Tiến
65 trang 24 0 0 -
Bài giảng Ngôn ngữ lập trình Java căn bản
115 trang 21 0 0 -
Bài giảng Công nghệ Java: Chương 0 - Trần Quang Diệu
6 trang 21 0 0 -
Lecture Introduction to Java programming - Chapter 15: Graphics
32 trang 21 0 0 -
Lecture Introduction to Java programming - Chapter 1: Introduction to computers, programs, and Java
63 trang 18 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 4 - TS. Phan Nguyên Hải
56 trang 18 0 0 -
Lecture Java programming language: Inheritance and Polymorphism - Ho Dac Hung
11 trang 17 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 5 - TS. Phan Nguyên Hải
33 trang 16 0 0