tailieunhanh - Introduction - Nguyen Viet Anh

Introduction What is Algorithm? (a clearly specified set of simple instructions to be followed to solve a problem, may be specified, Data structures, Program = algorithms + data structures). | Nguyen Viet Anh - CS3329 Spring 2011 Introduction What is Algorithm? a clearly specified set of simple instructions to be followed to solve a problem Takes a set of values, as input and produces a value, or set of values, as output May be specified In English As a computer program As a pseudo-code Data structures Methods of organizing data Program = algorithms + data structures Nguyen Viet Anh - CS3329 Spring 2011 Introduction Why need algorithm analysis ? writing a working program is not good enough The program may be inefficient! If the program is run on a large data set, then the running time becomes an issue Nguyen Viet Anh - CS3329 Spring 2011 Example: Selection Problem Given a list of N numbers, determine the kth largest, where k N. Algorithm 1: (1) Read N numbers into an array (2) Sort the array in decreasing order by some simple algorithm (3) Return the element in position k Nguyen Viet Anh - CS3329 Spring 2011 Example: Selection Problem Algorithm 2: (1) Read the first k elements into an array and sort them in decreasing order (2) Each remaining element is read one by one If smaller than the kth element, then it is ignored Otherwise, it is placed in its correct spot in the array, bumping one element out of the array. (3) The element in the kth position is returned as the answer. Nguyen Viet Anh - CS3329 Spring .

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.