Data Structures and Algorithms: Concepts and Applications

(アルゴリズムとデータ構造の概要と応用分野)

Data Structures and Algorithms

(データ構造とアルゴリズム)

1st lecture, September 26, 2019

http://www.sw.it.aoyama.ac.jp/2019/DA/lecture1.html

Martin J. Dürst

(テュールスト マーティン ヤコブ)

duerst@it.aoyama.ac.jp

Building O, Room 529

 

AGU

© 2008-19 Martin J. Dürst Aoyama Gakuin University

Today's Schedule

 

自己紹介

Teaching Assistant: Keita Sugiyama (杉山敬太、M2)

 

授業の位置づけ

This is a JE course (理工学国際プログラム JE 科目): The explanations are in Japanese, the materials (mostly) in English

 

授業の進め方

 

成績評価方法

およその割合:

総合的な評価

 

Lecture Schedule and Bibliography

Data Structures and Algorithms: Schedule

Bibliography (参考書)

 

Glossary

 

Why Algorithms and Data Structures?

Example of what happens without data structures and algorithms:

 

One More Example

  // target and pattern are very long strings
  n=0;
  for (i=0; i<strlen(target); i++) {
    match = 0;
    for (j=0; j<strlen(pattern); j++)
      if (target[i+j] == pattern[j])
        match++;
    if (match==strlen(pattern))
      match++;
  }   

 

Where is the Problem?

  // target and pattern are very long strings
  n=0;
  for (i=0; i<strlen(target); i++) {
    match = 0;
    for (j=0; j<strlen(pattern); j++)
      if (target[i+j] == pattern[j])
        match++;
    if (match==strlen(pattern))
      match++;
  }   

strlen takes more time for longer strings! 

 

Solution

  // target and pattern are very long strings
  n=0;
  p_length = strlen(pattern);
  for (i=0; i<strlen(target); i++) {
    match = 0;
    for (j=0; j<p_length; j++)
      if (target[i+j] == pattern[j])
        match++;
    if (match==p_length)
      match++;
  }   

 

Further Improvement

  // target and pattern are very long strings
  n=0;
  p_length = strlen(pattern);
  t_length = strlen(target);
  for (i=0; i<t_length; i++) {
    match = 0;
    for (j=0; j<p_length; j++)
      if (target[i+j] == pattern[j])
        match++;
    if (match==p_length)
      match++;
  }   

 

The Fascination of Algorithms and Data Structures

 

Lecture Goal

Understand

 

Example of Data Structure:
Linked List

 
 
 

 

Data Structure: Concept

A data structure consists of:

The term data structure is used mostly for structures inside a computer (in main memory).

There are two different views of data structures:

 

Algorithm Examples

Problem: Searching a word (target) in a (real!) dictionary

 

Algorithm: Concept

An algorithm is a clear set of instructions for how to solve a well-defined problem in finite time.

Requirements:

  1. Clear definition of problem and result (well-defined problem)
  2. Detailled and precise step-by-step instructions (similar to a program; clear set of instructions)
  3. Termination in a finite number of steps (finite time)

 

Counterexamples

 

Difference between Algorithms and Programs

 

Relationship between Data Structures and Algorithms

 

History of Algorithms

 

Summary of this Lecture

 

Homework 1: Huge Amounts of Data

Submission: Deadline: October 2 (next Wednesday), 19:00; Place: Box in front of room O-529; Format: One page, A4 (both sides okay, legible handwriting, name and student number at top right)

(for each subproblem, give the reasons for you assumptions, and cite references. When citing Wikipedia,..., use IRIs, not URIs, e.g. http://ja.wikipedia.org/wiki/情報, not http://ja.wikipedia.org/wiki/%E6%83%85%E5%A0%B1.)

  1. For exchanges in the First Section of the Tokyo Stock Exchange, calculate the total of data items (counting one trade as one data item) during 2019. Assume that during operating hours, each stock is traded once every 3 seconds.
  2. Imagine and explain some kind of data where the number of data items is much higher than in subproblem 1, and where the data may actually be processed on a computer (there will be a deduction if different students submit similar solutions).

 

宿題 1: 膨大なデータ

提出: 来週の水曜日 (10月 2日) 19:00時締切; O 棟 529号室の前の箱に提出; A4 一枚 (両面可、読みやすい手書き) 厳守

(それぞれの問題で、想定の根拠となる理由、参考にした文献など必ず明記のこと。Wikipedia などへの参照の場合、URI のではなく IRI を使用のこと (例: http://ja.wikipedia.org/wiki/%E6%83%85%E5%A0%B1 のではなく http://ja.wikipedia.org/wiki/情報))

  1. 東京証券取引所の第一部の取引で、一つの株式会社の株が営業時間内に平均で 3秒で一回売買されていると想定して、合計で2019年に (一売買行為を一つの項目と考えるとき) 何項目のデータが集まるかを、計算しなさい。
  2. 問題 1 の結果よりもデータ項目数がもっと多くて、実際に計算機で扱えそうな問題を考え、説明しなさい (他人と同じものの場合には減点対象)。

 

Homework 2: Representation of Algorithms

Examine the algorithm representations on the additional handout, and think about each representation's advantages and disadvantages.

(no need to submit, but bring to next lecture)

 

Homework 3: Help Ms. Noda

Design an efficient (=fast) algorithm for Ms. Noda's problem.

Hint: Can you use an algorithm that you already know?

(no need to submit)

 

Homework 4: Install Ruby

Install Ruby on your notebook computer (and/or on your computer at home)

Main installation methods (choose one):

How to check: Open a Cygwin Terminal or start Command Prompt with Ruby and execute ruby -v

Important: If you have problems with installing Ruby, come to my lab to fix it before the next lecture.

 

Preparation for the Next Lecture

 

ラボワークへのお誘い

 

Glossary

job search
就職活動
data structure
データ構造
linked list
連続リスト
data item
データ項目
abstract data type (ADT)
抽象データ型
algorithm
アルゴリズム
linear search
線形探索
binary search
二分探索
implement/implementation
実装する / 実装
land area calculations
土地面積の計算
ancient Egypt
古代エジプト
Euclid
ユークリッド
greatest common denominator (GCD)
最大公約数
Mathematician
数学者
ancient Greece
古代ギリシャ
state
状態
static aspect
静的側面
dynamic aspect
動的側面
economic
経済的