Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Hệ điều hành
Lecture Introduction to computing systems (2/e): Chapter 16 - Yale N. Patt, Sanjay J. Patel
Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Introduction to computing systems (2/e): Chapter 16 - Yale N. Patt, Sanjay J. Patel
Chí Kiên
84
20
ppt
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Chapter 16 - Recursion. The main contents of this chapter include all of the following: What is recursion? recursion versus iteration, towers of Hanoi, fibonacci numbers, binary search, integer to ASCII,. | Chapter 16 Recursion Mathematical Definition: RunningSum(1) = 1 RunningSum(n) = n + RunningSum(n-1) Recursive Function: int RunningSum(int n) { if (n == 1) return 1; else return n + RunningSum(n-1); } What is Recursion? A recursive function is one that solves its task by calling itself on smaller pieces of data. Similar to recurrence function in mathematics. Like iteration -- can be used interchangeably; sometimes recursion results in a simpler solution. Example: Running sum ( ) 16- Executing RunningSum RunningSum(4) RunningSum(3) RunningSum(2) RunningSum(1) return value = 1 return value = 3 return value = 6 return value = 10 return 1; return 2 + RunningSum(1); return 3 + RunningSum(2); return 4 + RunningSum(3); res = RunningSum(4); 16- High-Level Example: Binary Search Given a sorted set of exams, in alphabetical order, find the exam for a particular student. 1. Look at the exam halfway through the pile. 2. If it matches the name, we're done; if it does not match, then. 3a. If the name is greater (alphabetically), then search the upper half of the stack. 3b. If the name is less than the halfway point, then search the lower half of the stack. 16- Binary Search: Pseudocode Pseudocode is a way to describe algorithms without completely coding them in C. FindExam(studentName, start, end) { halfwayPoint = (end + start)/2; if (end 16- High-Level Example: Towers of Hanoi Task: Move all disks from current post to another post. Rules: (1) Can only move one disk at a time. (2) A larger disk can never be placed on top of a smaller disk. (3) May use third post for temporary storage. Post 1 Post 2 Post | Chapter 16 Recursion Mathematical Definition: RunningSum(1) = 1 RunningSum(n) = n + RunningSum(n-1) Recursive Function: int RunningSum(int n) { if (n == 1) return 1; else return n + RunningSum(n-1); } What is Recursion? A recursive function is one that solves its task by calling itself on smaller pieces of data. Similar to recurrence function in mathematics. Like iteration -- can be used interchangeably; sometimes recursion results in a simpler solution. Example: Running sum ( ) 16- Executing RunningSum RunningSum(4) RunningSum(3) RunningSum(2) RunningSum(1) return value = 1 return value = 3 return value = 6 return value = 10 return 1; return 2 + RunningSum(1); return 3 + RunningSum(2); return 4 + RunningSum(3); res = RunningSum(4); 16- High-Level Example: Binary Search Given a sorted set of exams, in alphabetical order, find the exam for a particular student. 1. Look at the exam halfway through the pile. 2. If it matches the name, we're done; if it does not match, .
TÀI LIỆU LIÊN QUAN
Lecture Introduction to computing systems: Chapter Introduction to Part II - Yale N. Patt, Sanjay J. Patel
Lecture Introduction to computing - Lesson 4: Computer systems
Lecture Introduction to computing - Lesson 11: Operating systems
Lecture Introduction to computing - Lesson 34: Intelligent systems
Lecture Introduction to computing systems (from bits & gates to C & beyond): Chapter 1 - Yale N. Patt, Sanjay J. Patel
Lecture Introduction to computing systems (from bits & gates to C & beyond): Chapter 2 - Yale N. Patt, Sanjay J. Patel
Lecture Introduction to computing systems (from bits & gates to C & beyond): Chapter 3 - Yale N. Patt, Sanjay J. Patel
Lecture Introduction to computing systems (from bits & gates to C & beyond): Chapter 4 - Yale N. Patt, Sanjay J. Patel
Lecture Introduction to computing systems (from bits & gates to C & beyond): Chapter 5 - Yale N. Patt, Sanjay J. Patel
Lecture Introduction to computing systems (from bits & gates to C & beyond): Chapter 7 - Yale N. Patt, Sanjay J. Patel
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.