6Data structure design (データ構造の設計) Data structure is one of the most important aspects of a program: Program = Data Structure + Algorithm.

Slides:



Advertisements
Similar presentations
Is Charlie Brown a Loser? Do you think you know your real character? Do you actually know, for example, the good and bad points about yourself? It is.
Advertisements

WSDL と JAX-RPC ソフトウェア特論 第 10 回 / お知らせ レポート課題を出しています。 提出は 7/30 ( 金 ) まで。
3D Wand による 3 次 元形状計測. 3次元形状計測装置  3D Wand(テクノドリーム 21 社 製)  構成 3D Wand 本体: 7 つの発光ダイオー ドとラインレーザー発光装置が一体となっ た手に持って移動できる電池駆動の装置.
SPSSによるHosmer-Lemeshow検定について
東京工科大学 コンピュータサイエンス 亀田弘之
7.n次の行列式   一般的な(n次の)行列式の定義には、数学的な概念がいろいろ必要である。まずそれらを順に見ていく。
第 3 回 iPhone アプリ開発勉強会 Objective-C 基礎講座 - インスタンスメソッド - 三井 相和.
9.線形写像.
情報処理A 第10回 Excelの使い方 その3.
麻雀ゲーム 和島研究室 ソ 小林巧人
5.連立一次方程式.
相関.
音当て Game 時田 大樹 飛山 雄太郎. 作品の目的 入力として、スイッチを押すと音がスピー カーから流れ、スイッチを離すと、音が止 まる仕組みとなっている。
―本日の講義― ・平均と分散 -代表値 -ぱらつき(分散・標準偏差等) ・Excelによる演習
ノイズ. 雑音とも呼ばれる。(音でなくても、雑 音という) 入力データに含まれる、本来ほしくない 成分.
フーリエ係数の性質. どこまで足す? 理想的には無限大であるが、実際に はそれは出来ない これをフーリエ解析してみる.
1章 行列と行列式.
本宮市立白岩小学校. 1 はじめに 2 家庭学習プログラム開発の視点 ① 先行学習(予習)を生かした 確かな学力を形成する授業づく り ② 家庭との連携を図った家庭学習の習慣化.
プログラミングⅠ( 1 組) 第 9 回
フーリエ級数. 一般的な波はこのように表せる a,b をフーリエ級数とい う 比率:
プログラミング入門2 第4回 式文 代入式 論理演算子 ループの脱出、スキップ 情報工学科 篠埜 功.
9.通信路符号化手法1 (誤り検出と誤り訂正の原理)
Excelによる積分.
1 6.低次の行列式とその応用. 2 行列式とは 行列式とは、正方行列の特徴を表す一つのスカ ラーである。すなわち、行列式は正方行列からスカ ラーに写す写像の一種とみなすこともできる。 正方行列 スカラー(実数) の行列に対する行列式を、 次の行列式という。 行列 の行列式を とも表す。 行列式と行列の記号.
計算のスピードアップ コンピュータでも、sin、cosの計算は大変です 足し算、引き算、掛け算、割り算は早いです
線形符号(10章).
1 0章 数学基礎. 2 ( 定義)集合 集合については、 3セメスタ開講の「離散数学」で詳しく扱う。 集合 大学では、高校より厳密に議論を行う。そのために、議論の 対象を明確にする必要がある。 ある “ もの ” (基本的な対象、概念)の集まりを、 集合という。 集合に含まれる “ もの ” を、集合の要素または元という。
複素数.
1 0章 数学基礎. 2 ( 定義)集合 集合については、 3セメスタ開講の「離散数学」で詳しく扱う。 集合 大学では、高校より厳密に議論を行う。そのために、議論の 対象を明確にする必要がある。 ある “ もの ” (基本的な対象、概念)の集まりを、 集合という。 集合に含まれる “ もの ” を、集合の要素または元という。
信号測定. 正弦波 多くの場合正弦波は 0V の上下で振動する しかし、これでは AD 変換器に入れら れないので、オフ セットを調整して データを取った.
1 9.線形写像. 2 ここでは、行列の積によって、写像を 定義できることをみていく。 また、行列の積によって定義される写 像の性質を調べていく。
通信路(7章).
3.プッシュダウンオートマトンと 文脈自由文法
ビット. 十進数と二進数 十進数  0から9までの数字を使って 0、1、2、3、4、5、6、7、8、9、 10、11、12 と数える 二進数  0と1を使って 0、1、10、11、100、101、11 0、111 と数える.
人工知能特論 II 第 4 回 二宮 崇 1. CCG (COMBINATORY CATEGORIAL GRAMMAR) 組合せ範疇文法 2 今日の講義の予定.
アルゴリズムとデータ構造 補足資料14-1 「ハッシュ法」
3.正方行列(単位行列、逆行列、対称行列、交代行列)
プログラミング演習B ML編 第3回 2010/6/15 (コミ) 2010/6/16 (情報・知能) 住井 ~sumii/class/proenb2010/ml3/
論理回路 第1回. 今日の内容 論理回路とは? 本講義の位置づけ,達成目標 講義スケジュールと内容 受講時の注意事項 成績の評価方法.
トランスフォームロボット の設計と製作 矢萩研究室 ソ 神貴浩 創作ゼミナールⅠ 計画発表.
JPN 311: Conversation and Composition 許可 (permission)
方程式を「算木」で 解いてみよう! 愛媛大学 教育学部 平田 浩一.
C言語応用 構造体.
3.多項式計算アルゴリズム べき乗の計算 多項式の計算.
プログラミング演習B ML編 第3回 2006/7/4 (通信コース) 2006/7/12 (情報コース) 住井 ~sumii/class/proenb2006/ml3/
JPN 312 (Fall 2007): Conversation and Composition 文句 ( もんく ) を言う.
移動エージェントプログラムの 動作表示のためのアニメーション言 語 名古屋大学情報工学コース 坂部研究室 高岸 健.
1 プログラミング言語論 第13回 プログラムの意味論と検証 (2) 表示的意味論 担当:犬塚. 2 表示的意味論 denotational semantics  表示的意味論では、プログラムの要素とそれが 意味するものを対応付ける。 変数 式 文 A B … A+2 2B+C A:=A+2 if.
1 プログラミング言語論 第5回 手続き呼出し 担当:犬塚. 2 今日の講義 手続きや関数などの呼出しに関わること  手続きの宣言、手続きの定義  名前の束縛とスコープ  ブロック構造  スコープ規則  引数渡し  引数渡しと評価(計算)方式.
プログラミングⅠ( 2 組) 第 1 回 / pLB1.pptx.
8.任意のデータ構造 (グラフの表現とアルゴリズム)
プログラミング入門2 第3回 複合文、繰り返し 情報工学科 篠埜 功.
第14回 プログラムの意味論と検証(3) 不動点意味論 担当:犬塚
ネットワークの基礎技術と TCP/IP 曹 暁達 ( そう ぎょうたつ ) 国際産業情報学科 2 年 10 月 28 日.
ことばとコンピュータ 2007 年度 1 学期 第 1 回. 2 ことばとコンピュータ 授業科目名:言語情報処理論 授業題目名:ことばとコンピュータ 履修コード: 5067 教室: 323 一学期開講 授業の進め方 – 基本的に講義中心ですすめ,時々コンピュー タを使う.
プログラミング演習( 1 組) 第 8 回
Kitenet の解析 (110118) 九州大学 工学部 電気情報工学科 岡村研究室 久保 貴哉.
1 プログラミング言語論 第4回 抽象データ型 担当:犬塚. 2 今日の講義 データ抽象に関する事柄を見る。  データ抽象とは  抽象データ型とは  抽象データ型の諸概念、利点  ADTのバリエーション 引数つきの抽象データ型 モジュール単位のカプセル化  データ不変条件.
Exercise IV-A p.164. What did they say? 何と言ってましたか。 1.I’m busy this month. 2.I’m busy next month, too. 3.I’m going shopping tomorrow. 4.I live in Kyoto.
音の変化を視覚化する サウンドプレイヤーの作成
HCC Hair Color Change. メンバー ソ 渋谷麻美 ソ 渋谷麻美 ソ 清野理衣子 ソ 清野理衣子 ソ 三上貴大 ソ 三上貴大.
Self-efficacy(自己効力感)について
7. Modular design (モジュール 設計) Modular design is an important technique for designing good quality program systems. In this part, you will learn: (内容) The.
大阪在住(自宅…豊中、勤務先…淀屋橋) ブログ Microsoft MVP (Visual Developer – Visual C#) Visual.
5. Control-flow design representations 制御の流れの設計表現 The structure chart (構造図) The Jackson Structure Diagram ( Jackson 構造 図) The flowchart (フローチャート ) The.
知能ソフトウェア特論 項書換え系(3) 合流性 Term Rewriting Systems(3) Confluence Intelligent Software.
Builder Pattern S. Yukita Builder Pattern2 Builder パターン 使われ所 大きなインスタンスを組み上げる場合。 インスタンスの組み上げにパターンが あるとき,パターンをディレクタに固 定する。 組み上げパターンに従って実際の仕事.
Network Programming in C 第3回「 C Fundamentals ~ command line arguments, pointers, and structures 」 20 10 Fall semester Rodney Van Meter.
今日の内容 高階関数  関数を値として扱う 関数を引数にとる 関数を返す関数 プログラミングの例題  クイックソート.
Presentation transcript:

6Data structure design (データ構造の設計) Data structure is one of the most important aspects of a program: Program = Data Structure + Algorithm

In a Structure Chart there is no definition of data-items involved. For example, what do those arguments mean? (次の構造図で使われた 引数は、定義されていない)

In a Jackson Structure Diagram there is no definition of data-items involved. (次の Jackson Structure 図で使われたデータ項目は定 義されていない)

In a flowchart there is no definition of data-items. E.g., expenses-file.

Design of data structures include the following aspects: (データ構造の定義には、次のことを定 義すべきだ) Define types and variables. (型と変数の定義) Determine how the variables are used (e.g., are they global or local? do they hold internal or external data?) (変数の使い方を決まる) Data structures involved in design should be defined in the form of being easily transformed into corresponding data structures in programming languages. (設計書に使われたデータ項目は、 プログラミング言語で実装しやすい形で定義 することが必要である)

6.1 Defining types and variables First, we need to understand the following points about programs: Programs process directly variables denoting useful data. A variable has the features: It corresponds to a memory unit. It has a name. It has a value. Every variable must be declared with a type, indicating the range of the values the variable can take (e.g., x: T). A type is a set of values together with a set of operations: Type = set of values + set of operations where the set of operations can be a single operation or empty. (型は値の集合と操作の集合)

int = {…, -1, 0, 1, …} + {+, -, *, /, …} values operations real = {…, -1.5, -1.0, 0, 1.0, 1.5, …} + {+, -, *, /, …} values operations WeekDays = {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY} + { } values operations Examples of types: (型の事例)

A notation for type definitions The design of data structures in the design phase should focus on the issues: The values of elementary data items. The member data items and their values of composite data items. The structure of organizing data items. By following this principle, a notation for defining types is introduced next. This notation is part of the Structured Object-Oriented Formal Language (SOFL), which can be used for both abstract and detailed design.

Basic types (built-in types) nat0: {0, 1, 2, …} nat: {1, 2, 3, …} int: {…, -1, 0, 1, …} real: {…, -1.5, -1.0, 0, 1.0, 1.5, …} string: {s | s is a sequence of characters} enumeration: {A1, A2, …, An} (e.g., {DOG, CAT, COW, HORSE}) subset of nat0: e.g., 1..8 (= {1, 2, …, 8}) (= {9, 10, …, 100}) and so on.

The form of defining a type A = Texp where Texp is a type expression. For example, Name = string declares that every name in type Name is a string of characters.

Composite type In general, a composite type A is defined as follows: A = composed of f1: Type-1 f2: Type-2 … fn: Type-n end where f1, f2, …, fn are called fields of type A.

Example Item = composed of name: Name price: real shop: Name date: Date end; /* Item is a composite type */ Date = composed of day: month: 1..12; year: nat0 end /* Date is another composite type */

Sequence types A sequence type is an abstract representation of the concrete data types available in programming languages, such as array, vector, linked list, and file. Two forms of sequence type definitions: (1)A = seq of Type-1 (2)A1 = seq[n] of Type-1 (1) states that A is a set of sequences, each consisting of a list of data items in type Type-1. (2) states that A1 is a set of sequences, each consisting of a list of at most n data items in Type-1. That is, every sequence in type A1 has at most n data items.

Examples Item-List = seq of Item; /* illustration: Item-List = { [ ], [a], [a1, a2], [b1, b2, b3], …, [c1, c2, …, cn] } /* Item = composed of name: Name price: real shop: Name date: Date end; /* Item is a composite type defined before*/

Class = seq[60] of Student; /* illustration: Class = { [ ], [s1], [s1, s2], …, [s1, s2, …, s60] } */ where Student is supposed to have been defined before.

Variable declarations The form of a variable declaration: a, b, c: Type-1; /*Which has no difference in semantics from the variable declaration: Type-1 a, b, c; */ or a: Type-1; b: Type-2; c: Type-3;

Examples of variable declarations (1)a: nat0; /* a = 0, a = 1, a = 2, or a = 10 … */ (2) a: nat; /* a = 1, a = 2, or a = 10, … */ (3) a: int; /*a = -1, a = 0, or a = 1, … */ (4) a: string; /*a = “Hosei”, a = “University, … */ (5) a: WeekDays; /*a = MONDAY, a = TUESDAY, … */ (6) a: Item; /*field select: a.f, where f is a field of a. for example, a.name, a.price, a.shop, a.date */

(7) a: Item-List; /*a = [b1, b2, …, bn], … where b1, b2, …, bn are variables of composite type Item. Simple operations: application: a(i), where i is the index of sequence a. for example, a(1) = b1, a(2) = b2, a(n) = ? length: len(a), for example, len(a) = n. */

6.2 Determining how the variables are used (変数の使い方が決まる) When we declare variables with types, we must try to understand how they will be potentially used in the program. Two aspects are important: (二つのポイントが重 要 である) Global and local variables? Representation of internal or external data?

6.2.1 Global and local variables Description 1: a global variable in a module (e.g., a single Java class) is a variable that can be accessed directly by different operations (e.g., methods in a single Java class). Description 2: a local variable is a variable that can only be accessed by a single operation; and after the termination of an execution of the operation this variable will no longer exist (e.g., variables declared inside a method of a Java class).

An abstract example module A a: int; b: int; c: string; end-module; operation P1(x: int) tem: int; begin tem := a; a := x + b; b := a; … end-op; operation P2(y: string) begin if c = y then b := a * b; else b := a + b end-op;

A specific example in Java //Scope.java import java.awt.Graphics; import java.applet.Applet; public class Scope extends Applet { int x = 1; //instance variable, global variable public void paint(Graphics g) { int x = 5; //local variable, with the same name as the global variable. System.out.println(“the initial value of x in paint” + x); a(); b(); System.out.println(“the final value of x in paint” + x); //the same as the initial x. }

void a() { int y = 0; //local variable y = x; //the initial value of x is held in y, x is used as a global variable ++x; x = x * x; System.out.println(“the initial value of x in a” + y); System.out.println(“the final value of x in a” + x); } void b() { System.out.println(“the initial value of global variable x in b” + x); x *= 10; //x is used as a global variable System.out.println(“the final value of x in b” + x); }

6.2.2 Variables representing internal and external data ( 内部変数と外部変数) Usually, files are used to hold external data and all other data structures are used to hold internal data, such as array, vector, and linked list. External data are the data independent of the program system. This kind of data is expected to be kept for future use, either by the same program or by other programs. For example, files are usually used to hold such kinds of data. Internal data means the data that exist only during executions of the program system. This kind of data is usually used by the program before its termination, and will disappear after the termination of the program.

How to distinguish variables representing external data and internal data (内部変数と外部変数の区別) Definition A variable representing external data is called external variable, and a variable representing internal data is called internal variable. A way to distinguish external and internal variables is to mark external variables with a special symbol #.

Specifically speaking, suppose f1 is expected to hold external data, its declaration takes the form: #f1: Type-1 where Type-1 is usually a sequence type. Example: #item-list: Item-List where Item-List is defined as: Item-List = seq of Item