IT1170 – Data Structures and Algorithms Lecture 01

0.0(0)
Studied by 3 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/49

flashcard set

Earn XP

Description and Tags

Introductory flashcards covering the basics of algorithms, pseudocode, and algorithm analysis methods (RAM model and Operation Count) as presented in the SLIIT Data Structures and Algorithms lecture.

50 Terms

1
New cards

How is an 'Algorithm' defined in the lecture?

It is any well defined computational procedure that takes some value or set of values as input and produce some value or set of values as output.

2
New cards

According to the example on Page 3, what is the first step in the sorting algorithm provided?

Get the smallest value from the input.

3
New cards

What is the third step of the algorithm example logic on Page 3?

Repeat steps 1 and 2 for remaining input until there is no item in the input.

4
New cards

List the five properties of an algorithm mentioned on Page 4.

Be correct, be unambiguous, give the correct solution for all cases, be simple, and it must terminate.

5
New cards

What are five applications of algorithms listed on Page 5?

Data retrieval, network routing, sorting, searching, and shortest paths in a graph.

6
New cards

How does the transcript define 'Pseudocode'?

A method of writing down an algorithm that is easy to read and understand, more expressive, and similar to other programming languages.

7
New cards

Does pseudocode concern itself with the techniques of software engineering?

No, it does not concern with the technique of software engineering.

8
New cards

In pseudocode conventions, what symbol is used to indicate a comment line?

//

9
New cards

In pseudocode conventions, what symbol is used to indicate assignment?

==

10
New cards

How are array elements accessed according to pseudocode conventions?

By specifying the array name followed by the index in the square bracket.

11
New cards

What notation is used in pseudocode to indicate a range of values within an array?

The notation ".." (e.g., A[1..i]A[1..i]).

12
New cards

According to the transcript, what does the index notation A[1..i]A[1..i] indicate?

The sub array of AA consisting of elements A[1],A[2],..,A[i]A[1], A[2], \text{..}, A[i].

13
New cards

What is the primary idea behind the 'Analysis of Algorithms'?

To predict the resource usage.

14
New cards

What three resources are typically predicted during algorithm analysis?

Memory, Logic Gates, and Computational Time.

15
New cards

What are the two reasons provided for needing an analysis of algorithms?

To compare and to predict the growth of run time.

16
New cards

How is the 'Best case' running time defined?

Minimum number of steps taken on any instance of size nn.

17
New cards

How is the 'Worst case' running time defined?

Maximum number of steps taken on any instance of size nn.

18
New cards

How is the 'Average case' running time defined?

An average number of steps taken on any instance of size nn.

19
New cards

What are the four analysis methods mentioned on Page 12?

Operation Count Methods, Step Count Method(RAM Model), Exact Analysis, and Asymptotic Notations.

20
New cards

What is the focus of the 'Operation count' method for time complexity analysis?

Selecting one or more operations (such as add, multiply, and compare) and considering the time spent on those chosen operations, but not all.

21
New cards

What is the core assumption of the Step Count (RAM Model) regarding processors?

It assumes a generic one processor where instructions are executed one after another with no concurrent operations.

22
New cards

In the RAM Model, how many steps does an operation like ++, −-, or == take?

11 step.

23
New cards

In the RAM Model, how many steps does each memory access take?

11 step.

24
New cards

In the RAM Model, how is 'Running Time' calculated?

Running Time=Sum of the steps\text{Running Time} = \text{Sum of the steps}.

25
New cards

In RAM Model Example 1, how many steps are assigned to the code segment: n=100n = 100, n=n+100n = n + 100, and Print n\text{Print } n?

11 step, 22 steps, and 11 step, totaling 44 steps.

26
New cards

What is the total step count formula for Example 2 involving a loop to calculate sum?

Steps=6n+3\text{Steps} = 6n + 3

27
New cards

In the RAM analysis of a loop 'for i=1i=1 to nn', how many assignments and comparisons are attributed to the loop control?

n+1n + 1 assignments and n+1n + 1 comparisons.

28
New cards

In RAM analysis, how many steps are counted for the operation 'sum=sum+A[i]sum = sum + A[i]'?

nn additions, nn assignments, and nn memory accesses.

29
New cards

Using the RAM model, how many steps are needed to display numbers from 11 to 1010?

4242 steps.

30
New cards

In Question 01, how many steps are calculated for the instruction 'While i <= 10i \text{ <= } 10'?

1111 steps.

31
New cards

In Question 01, how many steps are calculated for 'i=i+1i = i + 1'?

10+10=2010 + 10 = 20 steps.

32
New cards

Using the RAM model, how many steps are needed to display numbers from 1010 to 2020?

4646 steps.

33
New cards

What is the hint given for calculating the steps for 'While i <= 20i \text{ <= } 20' when starting at i=10i = 10?

20−10+2=1220 - 10 + 2 = 12 steps.

34
New cards

In Question 02, how many steps are counted for 'print ii' when displaying numbers from 1010 to 2020?

1111 steps.

35
New cards

Using the RAM model, how many steps are needed to display even numbers from 1010 to 2020?

6363 steps.

36
New cards

In Question 03, what is the total step count for the loop 'for i=10 to 20i = 10 \text{ to } 20'?

12+12+11=3512 + 12 + 11 = 35 steps.

37
New cards

In Question 03, how many steps is 'if i \text{ % } 2 \text{ == } 0' worth?

2×11=222 \times 11 = 22 steps.

38
New cards

In Question 03, how many steps are counted for 'print ii' when displaying even numbers from 1010 to 2020?

66 steps.

39
New cards

What is a major problem with the RAM model regarding different architectures?

The number of steps differs with different architecture.

40
New cards

Provide the example given in the transcript of an instruction that is one step in a CISC processor but potentially more in others.

sum=sum+A[i]sum = sum + A[i]

41
New cards

Besides architectural differences, what is another problem with the RAM model?

It is difficult to count the exact number of steps in the algorithm.

42
New cards

What specific algorithm is mentioned as being efficient for sorting a small number of elements?

Insertion sort.

43
New cards

What does Page 7 list as common Pseudocode Conventions?

English, Indentation, Separate line for each instruction, Looping and conditional constructs, // for comments, and = for assignment.

44
New cards

What is the step count for the initialization 'i=1i = 1' in the RAM model analysis of Question 01?

11 step.

45
New cards

In the RAM model analysis for Question 02, 'i=i+1i = i + 1' results in 2222 steps. How is this broken down?

1111 additions and 1111 assignments.

46
New cards

In the summary, what are the five main areas covered in the lecture?

What is an algorithm, Properties of an algorithm, Design methods, Pseudocode, and Analysis (Operation count & Step count, RAM model).

47
New cards

How many steps are counted for 'sum=0sum = 0' in the loop example analysis on Page 15?

11 assignment (total 1 step).

48
New cards

How many steps are assigned to 'i=1i = 1' in the 'for 1 to n1 \text{ to } n' loop analysis on Page 15?

11 assignment (total 1 step).

49
New cards

According to Page 15, how many steps does 'sum=sum+A[i]sum = sum + A[i]' represent in terms of memory accesses?

nn memory accesses.

50
New cards

Are instructions executed concurrently in the RAM model?

No, instructions are executed one after another, with no concurrent operations.