TAILIEUCHUNG - Data Structures and Program Design in C++ phần 7

Được phần nào cẩn thận hơn, chúng ta có thể, trên thực tế, có được một số chính xác hơn những so sánh được thực hiện bởi Mergesort, mà sẽ cho rằng hiệu suất thực tế của nó đến gần hơn với số lượng tốt nhất có thể so sánh của các phím cho phép | 422 Chapter 9 Tables and Information Retrieval review of first Life program 1. Updating the Configuration The crucial Life method is update whose task is to start with one Life configuration and determine what the configuration will become at the next generation. In Section we did this by examining every possible cell in the grid configuration calculating its neighbor count to determine whether or not it should live in the coming generation. This information was stored in a local variable new_grid that was eventually copied to grid. Let us to continue to follow this outline except that with an unbounded grid we must not try to examine every possible cell in the configuration. Instead we must limit our attention to the cells that may possibly be alive in the coming generation. Which cells are these Certainly we should examine all the living cells to determine which of them remain alive. We must also examine some of the dead cells. For a dead cell to become alive it must have exactly three living neighbors according to the rules in Section . Therefore we will include all these cells and likely others besides if we examine all the cells that are neighbors of living cells. All such neighbors are shown as the shaded fringe in the configuration of Figure . In the method update a local variable Life new_configuration is thereby gradually built up to represent the upcoming configuration We loop over all the living cells from the current configuration and we also loop over all the dead cells that are neighbors of these living cells. For each cell we must first determine whether it has already been added to new_configuration since we must be careful not to add duplicate copies of any cell. If the cell does not already belong to new_configuration we use the function neighbor_count to decide whether it should be added and if appropriate we insert it into new_configuration. At the end of the method we must swap the List and Hash_table members between the current

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.