tailieunhanh - INTRODUCTION TO COMPUTER SCIENCE - PART 4

THE LIST DATA MODEL Chương trình máy tính thường hoạt động trên các bảng thông tin. Trong hầu hết trường hợp, các bảng không chỉ đơn giản là vô định hình khối của các giá trị số, họ liên quan đến quan trọng cấu trúc các mối quan hệ giữa các yếu tố dữ liệu. Trong hình thức đơn giản của nó, một bảng có thể là một danh sách tuyến tính của các yếu tố, khi nó có liên quan thuộc tính cấu trúc có thể bao gồm các câu trả lời cho những câu hỏi như: Những yếu tố đầu tiên trong. | INTRODUCTION TO COMPUTER SCIENCE HANDOUT 4. THE LIST DATA MODEL K5 K6 Computer Science Department Văn Lang University Second semester -- Feb 2002 Instructor Trăn Đức Quang Major themes 1. Basic Concepts 2. Stacks 3. Queues Reading Sections and . BASIC CONCEPTS Computer programs usually operate on tables of information. In most cases these tables are not simply amorphous masses of numerical values they involve important structural relationships between the data elements. In its simplest form a table might be a linear list of elements when its relevant structural properties might include the answers to such questions as Which element is first in the list Which is last Which elements precede and follow a given one How many elements are in the list In this handout we only consider linear lists. Conceptually a linear list or simply list is a finite sequence of zero or more elements. We generally expect the elements of a list to be of some one type. For example if the elements of a list are all of integers we may call it a list of integers. Character strings are special lists. In C a string is stored in an array ending with a null marker 0 . All the library functions have a test for this marker. Linked Lists A list may be implemented as a linked list of elements each is allocated a cell or node consisting of an area for data and a pointer to the next element in the list as shown in the following figure. See more in Section textbook and Handout 1. Element 1 Element 2 Element 3 Element 4 24 INTRODUCTION TO COMPUTER SCIENCE HANDOUT 4. THE LIST DATA MODEL STACKS A stack is a special kind of lists in which all operations are performed at one end of the list which is called the top of the list. The term LIFO for last-in first-out list is a synonym for stack. Because of this restriction stacks have two specialized operations push and pop where push x puts the element x on the top of the stack and pop removes the topmost element from the stack. The figure

TỪ KHÓA LIÊN QUAN
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.