





























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























































Algorithmics - Lecture 2 1
Algorithms pseudocode; examples
Algorithmics - Lecture 2 2
Efficiency An algorithm should use a reasonable amount of computing resources: memory and time Finiteness is not enough if we have to wait too much to obtain the result Example: Consider a dictionary containing 50000 words. Write an algorithm that takes a word as input and returns all anagrams of that word appearing in the dictionary. Example of anagram: ship -> hips
Efficiency Second approach: Step 1: sort the letters of the initial word Step 2: for each word in the dictionary having m letters:
Efficiency First approach Second approach m! m log 2 n n m 2 +n m+ m 2 Example: m=12 (e.g. word algorithmics) n=50000 (number of words in dictionary) 8* 10^10 8*10^ one basic operation (e.g.comparison)= 1ms=
How can we describe algorithms? Solving problems can usually be described in mathematical language Not always adequate to describe algorithms because:
How can we describe algorithms? Two basic instruments:
Types of data Data = container of information Characteristics:
Types of data
Index: 1 2 3
(1,1) (1,2) (2,1) (2,2)
How can we specify data?
How can we specify data?
What are the basic instructions? Instruction (statement) = action to be executed by the algorithm There are two main types of instructions: