0 Up votes0 Down votes

8 views24 pagesmodel

Nov 20, 2013

© Attribution Non-Commercial (BY-NC)

PDF, TXT or read online from Scribd

model

Attribution Non-Commercial (BY-NC)

8 views

model

Attribution Non-Commercial (BY-NC)

- Steve Jobs
- Wheel of Time
- NIV, Holy Bible, eBook
- NIV, Holy Bible, eBook, Red Letter Edition
- Cryptonomicon
- The Woman Who Smashed Codes: A True Story of Love, Spies, and the Unlikely Heroine who Outwitted America's Enemies
- Contagious: Why Things Catch On
- Crossing the Chasm: Marketing and Selling Technology Project
- Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are
- Zero to One: Notes on Start-ups, or How to Build the Future
- Console Wars: Sega, Nintendo, and the Battle that Defined a Generation
- Dust: Scarpetta (Book 21)
- Hit Refresh: The Quest to Rediscover Microsoft's Soul and Imagine a Better Future for Everyone
- The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
- Crushing It!: How Great Entrepreneurs Build Their Business and Influence—and How You Can, Too
- Make Time: How to Focus on What Matters Every Day
- Algorithms to Live By: The Computer Science of Human Decisions
- Wild Cards

You are on page 1of 24

Dorel Lucanu

Faculty of Computer Science Alexandru Ioan Cuza University, Ia si, Romania dlucanu@info.uaic.ro

TPAA 2013

An Algorithmic Language

TPAA 2013

1 / 24

Outline

An Algorithmic Language

TPAA 2013

2 / 24

Introduction

Plan

An Algorithmic Language

TPAA 2013

3 / 24

Introduction

Motivation

The goal is to have a language that is simple enough to be easily understood by the undergraduate students expressive enough to describe all taught algorithms abstract: the description of algorithm is abstracted from the implementation details such that the focus is on the algorithmic thinking supply a computation model suitable for analysis, especially time complexity executable: the students (and teachers, as well) should be able to make experiments with the described algorithms the input and output data should be represented in an abstract way (e.g., as simple mathematical objects) such that of the implementation details are totally omitted

D. Lucanu (FII - UAIC) An Algorithmic Language TPAA 2013 4 / 24

Memory Model

Plan

An Algorithmic Language

TPAA 2013

5 / 24

Memory Model

Memory Model

the memory is a set of variables variables are nothing but reserved memory locations to store values however, we do not care about the memory locations, so that we represent a variable as a pair math notation variable-name value value variable-name

graphical notation

D. Lucanu (FII - UAIC) An Algorithmic Language TPAA 2013 6 / 24

Memory Model

Scalars

primitive data types: booleans, integers, oats, strings math notation b true true b bool b=true; i5 5 i int i=5;

An Algorithmic Language

TPAA 2013

7 / 24

Memory Model

Cons Lists

Con lists are also called lists a la Lisp. They have a recursive denition: the empty list () is a cons list; if V is a value and L is a list, then (V , L) is a cons list (this is the cons (from constructor) operation) Cons lists are abstract representation of the linked lists math notation L = (a, (b , (c , ()))) a L b c

graphical notation

C++

struct List { int info; List *next; } * L; L = new List; L.info = a; L.next = new List; ...

An Algorithmic Language TPAA 2013 8 / 24

Memory Model

Arrays

An array is represented as a nite set of maps from indexes to values. math notation a {0 a0 1 a1 2 a2 }. 0 a0 a 1 a1 2 a2

graphical notation

C++

or int a = {a0, a1, a2};

An Algorithmic Language

TPAA 2013

9 / 24

Memory Model

Structures

The structures are represented in a similar way as the arrays, but the maps are from elds names to values. For instance, a structure p representing 2D points has two elds: x and y: math notation p {x 2 y 7} x 2 p y 7

graphical notation

C++

An Algorithmic Language

TPAA 2013

10 / 24

Memory Model

the graph G = ({0, 1, 2}, {(0, 1), (0, 2), (1, 2)}) is represented by adjacency lists as follows: math notation {n 3 a {0 [1, (2, ())] 1 [0, (2, ())] 2 [0, (1, ())]}} graphical notation n a 0 1 3 1, (2, ()) 0, (2, ()) G C++ struct Graph { int n; vector<list<int>> a; } G;

D. Lucanu (FII - UAIC) An Algorithmic Language

2 0, (1, ())

TPAA 2013 11 / 24

Operations

Plan

An Algorithmic Language

TPAA 2013

12 / 24

Operations

Scalars

Integers: Operation a+b ab ... Uniform cost O (1) O (1) Logarithmic cost O (max(log a, log b )) O (log a log b ) O (max(log a, log b )1.545 )

An Algorithmic Language

TPAA 2013

13 / 24

Operations

Cons Lists

An Algorithmic Language

TPAA 2013

14 / 24

Operations

Arrays

An Algorithmic Language

TPAA 2013

15 / 24

Statements

Plan

An Algorithmic Language

TPAA 2013

16 / 24

Statements

Expressions

syntax Exp ::= Id | Int | Exp "+" Exp | Exp "*" Exp ... | Id "(" Exps ")" ... syntax Exps ::= List{Exp,","}

An Algorithmic Language

TPAA 2013

17 / 24

Statements

Satements Syntax

syntax Stmt ::= Exp "=" Exp ";" | Exp ";" | "{" "}" | "{" Stmts "}" | "while" "(" Exp ")" Stmt | "return" Exps ";" | Exp "(" Ids ")" "{" Stmts "}" | "if" "(" Exp ")" Stmt "else" Stmt | "if" "(" Exp ")" Stmt ... syntax Stmts ::= List{Stmt,""}

An Algorithmic Language

TPAA 2013

18 / 24

Statements

Congurations

Conguration

An Algorithmic Language

TPAA 2013

19 / 24

Statements

Congurations

Evaluation of Expressions

eval (, E ) returns the value obtained by replacing program variables with their values in the state S Formal denition . . . (on the blackboard) Example eval (x 7 y 12, y + 2 * x) = eval (x 7 y 12, y) + 2 eval (x 7 y 12, x) = 12 + 2 7 = 26

An Algorithmic Language

TPAA 2013

20 / 24

Statements

Computations

Computations:Denition

S, S , i executing the current statement of S in the state we get new code (to execute) S and a new state

An Algorithmic Language

TPAA 2013

21 / 24

Statements

Computations

assignment: x = e ; informal : evaluate e and the result is the new value of the variable e formal : x = e ;S , S , [x eval (, e )] while: while (e ) S informal : evaluate e ; if the result is true, then execute S and after that evaluate e . . . ; otherwise the execution of the statement is nished formal : while (e ) S S , S ; while (e ) S S , if eval (, e ) = true while (e ) S S , S , if eval (, e ) = false

An Algorithmic Language

TPAA 2013

22 / 24

Statements

Computations

if: if (e ) then S else S informal : evaluate e ; if the result is true, then execute S , otherwise execute S formal : e ) then S else S S , S S , if eval (, e ) = true e ) then S else S S , S S , if eval (, e ) = false

An Algorithmic Language

TPAA 2013

23 / 24

Statements

Computations

Computations:Example

x = x + 1; y = y + 2 * x;, x 7 y 12 y = y + 2 * x;, x 8 y 12 ., x 8 y 28

An Algorithmic Language

TPAA 2013

24 / 24

- 171809674 SPM Form 4 Additional Mathematics QuestionsUploaded byWei Hou
- Unit2 Input OutputUploaded byDeepak Kumbhar
- tmpA22DUploaded byFrontiers
- algoExcelAssignmentUploaded bySiddharth Das
- Manual on Rainfall Analysis For Storm Water Drainage Systems, Second EditionUploaded byShashikant Dattatray Chawathe
- Java TutUploaded bySasa Leung
- Prisoners ShortUploaded byRuth
- Gr 12 LogarithmsUploaded byRoshan Upadhyay
- Batty 2008Uploaded byVitor Caram
- PHP Question AnswerUploaded byManish Sharma
- 10s 01 IntroductionUploaded bybrazselva
- Ramanujan's Published PaperUploaded byMrigank
- Croot, Ernest - Binary Egyptian Fractions (2000)Uploaded byPere Garcia
- tws lesson plan 2Uploaded byapi-265324068
- 01Uploaded byIjaz Talib
- ECE 401 Exercise 2 BerbanoUploaded byMelric Lamparas
- Tic Tac ToeUploaded bySoubhik Biswas
- fluid mechanicUploaded byteknokolik
- meta_erlang.pdfUploaded bySalvador Tamarit Muñoz
- Taking the Mystery Out of Monte CarloUploaded bySlamat Parulian Simamora
- Mini TabUploaded byDamu Arief Sogi
- Elastic ATributes.pdfUploaded bystarbrid
- Stokes PolesUploaded byMichael Pearson
- 906-966-1-PB (1)Uploaded byjohnoftheroad
- AQA-2450-W-TRB-ISAPSAG.pdfUploaded bydenesha1996_42639989
- 10 Determination of PorosityUploaded byAsad Meraj
- gammaFunction.pdfUploaded byTeferi
- compliersUploaded by99806672
- Fungsi e Dan Laju BerkaitanUploaded byputrasempoerna
- geostbUploaded bysumokeke

- Engleza Pentru Incepatori - Lectia 21-22Uploaded byFerenk
- Probleme Laborator YaccUploaded byCornelius Paul Asoltanei
- Probleme Laborator LexxUploaded byCornelius Paul Asoltanei
- Test Exemplu Futures First BUploaded byCornelius Paul Asoltanei
- Test Exemplu Futures First AUploaded byCornelius Paul Asoltanei
- Track ListUploaded byCornelius Paul Asoltanei
- 3 Siruri Kmp Bm RkUploaded byCornelius Paul Asoltanei
- Cur So AreUploaded byCornelius Paul Asoltanei

- C42C42M.pdfUploaded byGiancarlo Calle
- Legal MedicineUploaded byPaulo San Juan
- Variables de PagoUploaded byGregorio
- cinema português e filosofiaUploaded byÉrica Sarmet
- Antigone Discussion QuestionsUploaded bypoopface96
- Worksheet Song Listening Treat You Better Shawn MendesUploaded bypepe00731@latinmail.com
- 5 Foods That Kill ErectionsUploaded byshawn
- FORWARD KINEMATICS1.docxUploaded byadirey
- Ict Strategy Formulation-A Case Study of Insurance CompanyUploaded bySmilka Janeska-Sarkanjac
- Review of health safety aspects of nanotechnologies in food production.pdfUploaded byMuhammad Nadeem
- Death in Humanist TraditionUploaded bykarnyg
- 2019 Dr. Yuni Ch29-EyeUploaded byDEWI MULYANI
- Fossier v. Jefferson Parish, 985 So.2d 255Uploaded byGreg aymond
- Lesson 44 Jesus Feeds 5000Uploaded byJayamany
- Philosophical and Ideological Foundations of EducationUploaded byMaan Felizardo-Poblete
- Domesticating Nature, Appropriating Hierarchy: the representation of European and non-European peoples in an Early-Nineteenth-Century Schoolbook of Natural HistoryUploaded byKazumi Munakata
- ISM Practice TestUploaded byAndre Cabelo
- [Citibank]+Convertible+Bonds+-+A+GuideUploaded bystalker199
- LM311Uploaded byapi-3825669
- C4 Silver 2Uploaded byCostas Paschalides
- in the land of the free are you free to sit out the national anthemUploaded byapi-365566091
- Solutions test Unit 2 AUploaded byГалина Яковлева
- Impulse and Change of MomentumUploaded byJohn Johnson
- Tutorial: Topology Optimization of a cantilever beamUploaded bydemsdots
- Avenido vs AvenidoUploaded byEl Sitas
- Days, Weeks, Months, Seasons.pdfUploaded bydidian_vlad3769
- Safety MeasuresUploaded byGuia Jane ʚϊɞ ﺕ
- The Goals of MussarUploaded bySteve Williams
- 102085 group assignment log book 1Uploaded byapi-332411347
- m tech-3rd semester pesu edUploaded byapi-294538209

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.