Algorithms and Data Structures – Lecture 1 (Stacks & Queues, Complexity Basics)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards

What is the primary aim of the module "Algorithms and Data Structures"?

To give students additional insight into programming techniques through data structures, algorithms and their complexity analysis in a practical context.

2
New cards

List any two intended learning outcomes of this module.

(1) Understand and select appropriate algorithms for a range of problems. (2) Design and implement algorithms and data structures for novel problems.

3
New cards

How many contact hours per week does the class meet, and in what formats?

Three hours per week, comprising lectures, discussions and tutorial sessions.

4
New cards

Name the essential textbook recommended for this course.

McGrath, M. (2011) C++ Programming in Easy Steps (4th ed.).

5
New cards

According to course policies, what is the consequence of missing assignment deadlines?

Failure to keep deadlines will adversely affect a student’s grade.

6
New cards

Complete the equation: Data Structures + Algorithms = .

Programs (Problem → Solution).

7
New cards

Define a data structure.

A specialized format (logical or mathematical model) for organizing and storing data to enable efficient access and manipulation.

8
New cards

Give three general examples of data structures mentioned in the lecture.

Array, Stack, Tree (also acceptable: Record, Queue, etc.).

9
New cards

What are the three broad categories into which data can be organized?

Primitive types, Composite types, Abstract Data Types (ADTs).

10
New cards

Give two examples of primitive data types.

Character (char) and Integer (int).

11
New cards

What is a composite data type?

A data type constructed from primitive and/or other composite types within a program (composition).

12
New cards

In C/C++, what keyword declares a user-defined composite type and what is it commonly called?

The keyword struct; it is called a structure (user-defined data structure).

13
New cards

Define an Abstract Data Type (ADT).

A mathematical model of data objects plus the operations on them, specified only by their behavior and constraints, not by implementation.

14
New cards

Which two core operations define an abstract stack ADT?

push (insert an item) and pop (remove the most recently pushed item).

15
New cards

State the main goal and two criteria for using data structures.

Goal: Organize data. Criteria: Facilitate efficient storage, retrieval and manipulation.

16
New cards

List four fundamental operations that can be performed on data structures.

Traversing, Searching, Insertion, Deletion (also Sorting, Merging).

17
New cards

Provide one formal definition of an algorithm given in the lecture.

A finite set of statements that guarantees an optimal solution in a finite interval of time.

18
New cards

What property must every correct algorithm satisfy when sorting input that is already sorted or contains duplicates?

It must still correctly sort the input (handle sorted and repeated elements).

19
New cards

State the two primary resources considered when measuring algorithm efficiency.

Time and Memory (space).

20
New cards

Why is measuring processor time alone insufficient for evaluating an algorithm’s efficiency?

Because real execution time varies with processor speed, language, compiler quality, OS, and input size; theoretical analysis abstracts from these factors.

21
New cards

How is running time typically expressed in theoretical analysis?

As a function of input size N, counting the number of primitive operations or steps.

22
New cards

What does asymptotic analysis focus on when N becomes very large?

The highest-order term of the time-complexity function, ignoring lower-order terms and constant factors.

23
New cards

Define Big O notation in one sentence.

A mathematical notation that describes an upper bound on the growth rate (worst-case) of an algorithm’s time or space complexity.

24
New cards

What is the Big O time complexity of accessing any single array element?

O(1) – Constant time.

25
New cards

Give the typical Big O for a simple loop that scans every element of an array once.

O(n) – Linear time.

26
New cards

What kind of nested-loop algorithm has time complexity O(n²)?

An algorithm that performs a full inner loop for each iteration of an outer loop over the same data set (e.g., duplicate checking).

27
New cards

Describe exponential time complexity and provide the Big O symbol.

Growth doubles with each additional input element; O(2^n).

28
New cards

Which classic problem often requires exponential time when solved exactly via dynamic programming?

The Traveling Salesman Problem (TSP).

29
New cards

State one example of an algorithm that typically runs in O(log n) time.

Binary search on a sorted array.

30
New cards

According to the Big-Oh rules, how would you simplify 3n + 5 for asymptotic notation?

O(n) – drop the constant coefficient and lower-order term.

31
New cards

Formally, f(n) is O(g(n)) if there exist positive constants c and n₀ such that .

f(n) ≤ c ·

32
New cards