COMP280: Data Structures Lecture 1

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

1/22

flashcard set

Earn XP

Description and Tags

Flashcards covering key concepts from the lecture notes on data structures, algorithms, and Big-O analysis.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

23 Terms

1
New cards

Data Structures

A collection of data values, the storage format for these values (e.g., array, linked list, stack, queue, search tree, graph), and the operations defined on them (the ADT).

2
New cards

Abstract Data Type (ADT)

A data type defined by its operations and behavior, independent of implementation.

3
New cards

Why Data Structures?

Different storage formats have different efficiencies for a problem; no single DS is best for all cases; choose the best DS for the problem.

4
New cards

Common data structures covered

Arrays, Linked Lists, Binary Search Trees, Heaps, Hash Tables, and Graph-related structures; many languages provide built-in DS (e.g., C++ STL: vector, set, map, queue, stack, priority_queue).

5
New cards

C++ importance

C++ remains an important language alongside Python, Java, JavaScript, C#, Swift; relatively old but evolving, efficient and powerful.

6
New cards

C++ basics ( Hello World )

A minimal C++ program structure, e.g., #include , using namespace std; int main() { cout << "Hello World!" << endl; return 0; }.

7
New cards

C++ compiling

g++ compiles a program; default output is executable a.out; using -o option names the executable (e.g., g++ myprog.cpp -o myprog.out).

8
New cards

C++ editors

IDEs: Dev C++, Eclipse, NetBeans, Xcode; vi is a text editor, not a full IDE, useful for small programs.

9
New cards

What is an Algorithm?

The ideas behind computer programs; language-independent; solves a general, specified problem.

10
New cards

What is a problem?

A mapping from input instances (domain) to an output set (range); problem specification includes typical input and expected output (e.g., sorting).

11
New cards

Input and Output in a problem

Describe how input looks (domain) and how output should look and relate to the input.

12
New cards

Find Minimum problem (definition)

Input: N ≥ 1 and a list a1, a2, …, aN; Output: the minimum element x = ai for some i, such that x ≤ aj for all j.

13
New cards

Input instance

An assignment of values to input variables, e.g., N = 10 and (a1, …, aN) = (5,1,7,4,3,2,3,3,0,8).

14
New cards

Implementing a mapping

Write a program that takes input and produces the correct output (Input → Program → Output).

15
New cards

Example Find Minimum solution idea

An O(n) algorithm that scans the array, updating the current minimum as it goes.

16
New cards

Two properties of algorithms

Correctness: always produces the correct output for legal input. Efficiency: fast in time and space (Big-O) and simplicity.

17
New cards

Odd Number problem (efficient approach)

To test if n is odd, look at the last bit (or last digit); other naive methods are less efficient.

18
New cards

Analyzing algorithms

Study the time and space resources an algorithm uses without running it on hardware; compare algorithms theoretically.

19
New cards

Big-O notation

A notation for measuring the upper bound of an algorithm's time (and sometimes space) complexity as a function of input size.

20
New cards

Common complexity functions

Functions used to classify growth: n, n^2, n^3, n^5, 2^n, 3^n, 2n, n log n, log n, etc.

21
New cards

Worst, Best, and Average case

Worst-case: maximum steps for size n; Best-case: minimum steps; Average-case: expected steps. Worst-case is simpler to guarantee and often close to average.

22
New cards

Average-case analysis drawbacks

Depends on assumed input distribution; harder to compute than worst-case; sometimes worst-case ≈ average (with exceptions like Quicksort and simplex).

23
New cards

Worst-case analysis

Typically easier to compute; identifies an input that causes the worst performance and provides a universal guarantee.