1. Trang chủ
  2. » Công Nghệ Thông Tin

Introduction to Computing: Lecture 9 - Dr. Pham Tran Vu

28 25 0
Tài liệu được quét OCR, nội dung có thể không chính xác

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 28
Dung lượng 223,73 KB

Nội dung

Introduction to Computing: Lecture 9 includes about Data Structures is essentially a number of data items, with some relationships among them. It includes Arrays, Stack, Queue, Circular queue, Linked list, Binary tree.

Trang 4

Data Structures

o Essential for any computer programmer

o A data structure is essentially a number of data items, with some relationships among them

Trang 5

SN

o Supported by all high-level programming

languages, such as Pascal, C/C++, Java, etc o Data is manipulated in tabular fashion

o Programmers only need to declare the array name, size and dimension, the language processor will

allocate memory for the array

Trang 7

fs wo-Dimension Arrays

Oo Memory addressing is one-dimension

o Need a translate of subscripting to mapping

two-dimension array addressing into

Trang 9

fs wo-Dimension Arrays Oo Storage of two-dimension array in memory — b +1 +2 +3 +4 +5 +6 +/ +48 49 410 +11 k 0 1 2 3 4 5 0 1 2 3 4 5 0 0 0 0 0 0 1 1 1 1 1 1 ñ Translatilon formula: M=b +jN+k =» N: array size

Trang 10

Stacks

o Characterised by Last In First Out (LIFO)

o Items are added or removed from a stack Is done at only one end

o Two basic operations:

=» Push: store an item into the stack

=» Pop: get an item out of the stack

Trang 11

stacks (2)

oOo Astack of size 5

push _⁄0o 1 Currently store 4 Item

Trang 14

Em oucues

o Characterised by First In First Out FIFO

Oo Similar to our every queues

Trang 15

fem aueue Implementation Using One- Dimension Array

Oo Implementation of a queue using array of 13 elements

Oo Toadd an item, the Tail is increased by 1

Oo Toremove an item the Head is increased by 1 o The queue is full when Tail equals 12

Trang 16

Em ciccule Queues

o The disadvantage of the implementation

discussed Is that the queue will be definitely full after some usage, although the number of items in the queue Is still smaller than the size of the queue

o Acircular buffer implementation can be used to solve this problem

Trang 17

EM circular Queues (2)

Trang 19

Linked Lists

o Give the array contains order list of names

Oo How to add in Crawford,

while the alphabetical

Trang 24

Ẩ No,

Oo Ina tree data structure, data elements are

organised in a tree like structure University of Technology —

Chemical Computer Science Construction Industrial

Engineering and Engineering Engineering Management

Computer oystem Computer Information software

ocience & Networking Engineering oystems Engineering

Trang 25

En 20 Data Structure Concepts o A parent node: the node that has pointer(s) to other node(s) o Achild node: the one that is pointed to a parent node

4 Root: the node of the tree that has no parent

o Leaf node: the node that has no child

o Anode ina tree cant have more than one parent

Trang 27

Ẩ Nga, search Trees

o A binary search tree Is a binary tree that has the following characteristics

Each node has a distinct value

Values of all the nodes of the left subtree of a node are smaller than the node's value

Values of all the nodes of the right subtree of a node are greater than the node's value

Trang 28

Ẩ Nga, Search Trees (2)

Ngày đăng: 30/01/2020, 18:37