DATA STRUCTURES IN JAVA A Laboratory Course phần 7

Nếu con trỏ không phải là lúc bắt đầu của một danh sách, sau đó di chuyển con trỏ đến các yếu tố trên trong danh sách và trả về true. Nếu không, trả về false. GetCursor Object () | LABORATORY 10 LABORATORY 10 In-lab Exercise 1 Name__ Hour Period Section__ Date__ Although recursion can be an intuitive means for expressing algorithms there are times you may wish to replace recursion with iteration. This replacement is most commonly done when analysis of a program s execution reveals that the overhead associated with a particular recursive routine is too costly either in terms of time or memory usage. Part A Replacing recursion in a routine such as the Iength method Prelab Exercise Part E is fairly easy. Rather than using recursive calls to move through the list you move a reference of type sListNode from node to node. In the case of the Iength method this iterative process continues until you reach the end of the list. The reverse method Prelab Exercise Part C presents a somewhat more challenging problem. The iterative form of this routine moves a set of references through the list in a coordinated manner. As these references move through the list they reverse the links between pairs of nodes thereby reversing the list itself. Step 1 Create an implementation of the reverse method that uses iteration in conjunction with a small set of references in place of recursion. Call this method iterReverse and add it to the file . An incomplete implementation of this method is included in the definition of the ListRec class in the file . Step 2 Activate the call to the iterReverse method in the test program in the file by removing the comment delimiter and the characters 1A from the lines beginning with 1a . Step 3 Prepare a test plan for the iterReverse method that covers lists of different lengths including lists containing a single element. A test plan form follows. 238 LABORATORY 10 Step 4 Execute your test plan. If you discover mistakes in your iterReverse method correct them and execute your test plan again. Test Plan for the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.