1.1 Introduction

87 阅读2分钟

Data structures

1. logical structure

linear structure

  1. Linear List
  2. Stack
  3. Queue

nonlinear structure

  1. Tree
  2. Graph
  3. Set

2. storage structure(physical structure)

    1. Sequential storage structure
    2. Linked storage structure
    3. Index storage structure
    4. Hash stroage structure

3. Data operation

#include "stdio.h"
#define stuMaxSize 1000;

type struct{    
    int studentNumber;    
    char name;    
    bool gender;    
    short age;    
    short weight
}stu;

stu *stuSet = (stu*)malloc(sizeof(stu)*stuMaxSize);

bool initStu(stu &stuSet);
char getStuName(int stuNum);
bool addStu(int stuNum,char stuName,bool stuGender,short age,short weight,stu &stuSize);
void sortStuNum(stu &stuSet,stu );

Algorithms

5 important features

  1. Finiteness
  2. Definiteness
  3. Effectiveness
  4. Input
  5. Output

goals

  1. Correctness
  2. Readability
  3. Robustness
  4. High efficiency & Low storage requirements

Time complexity & Space complexity

Exercise

一、选择题

01.可以用( D )定义一个完整的数据结构。

A.数据元素 B.数据对象

C.数据关系 D.抽象数据类型

02.以下数据结构中,( A )是非线性数据结构。

A.树 B.字符串

C.队列 D.栈

03.以下属于逻辑结构的是( C )。

A.顺序表 B.哈希表

C.有序表 D.单链表

04.·以下与数据的存储结构无关的术语是( A )。

A.循环队列 B.链表

C.哈希表 D.栈

05.以下关于数据结构的说法中,正确的是( A )。

A.数据的逻辑结构独立于其存储结构

B.数据的存储结构独立于其逻辑结构

C.数据的逻辑结构唯一决定其存储结构

D.数据结构仅由其逻辑结构和存储结构决定

06.在存储数据时,通常不仅要存储各数据元素的值,而且要存储( B )。

A.数据的操作方法 B.数据元素的类型

C.数据元素之间的关系 D.数据的存取方法

07.链式存储设计时,结点内的存储单元地址( C )。

A.一定连续 B.一定不连续

C.不一定连续 D.部分连续,部分不连续

二、综合应用题

01.对于两种不同的数据结构,逻辑结构或物理结构一定不相同吗?

Binary tree

02.试举一例,说明对相同的逻辑结构,同一种运算在不同的存储方式下实现时,其运算效率不同

Linear list (sequencial storage structure) O(1)=RU O(n)=CD CRUD

Linear lisr(linked storage structure) O(n)=RU O(1)=CD