• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 65 pages
Exam (elaborations)

Data Structures and Algorithms I (C949): Comprehensive Study Notes

Document preview thumbnail
Preview 4 out of 65 pages

This document is a comprehensive set of study notes for a Data Structures and Algorithms I course (C949). It provides a structured overview of fundamental computer science concepts, starting with Python programming basics and progressing through key abstract data types and algorithms. The content covers topics such as Python syntax and style, data types, expressions, control flow, functions, classes, and then delves into core data structures like lists, stacks, queues, hash tables, trees, and heaps. It also includes detailed explanations and Python implementations of essential algorithms, including various sorting and searching methods (linear search, binary search, selection sort, insertion sort, shell sort, quicksort, merge sort), as well as algorithm analysis using Big-O, Omega, and Theta notations. The notes are formatted as a quick-reference guide, making them ideal for exam review and practical programming application.

Content preview

Data Structures and Algorithms I – C949
1. Python Code Commenting Style Requirements
Comments
• In-line/Multiline comments: more in-depth explanations → section of lines all
beginning with #
o # This section of code
# Requires a longer comment
# So we can add as many lines as needed
• Multi-line comments.
"""
This is a multi-line comment
that continues on a second line.
And even uses a third line.
D

"""
O


Formatting style
• Classes: capitalized (Member instead of member) & "CamelCase"
N


• Functions: should be lowercase → separated by underscores (calculate_sqrt).
•
O

Objects: (parameters, instance/local variables) lowercase noun (grade)
• Constants: all capital letters and underscores (MAX_SIZE).
T
C


2. Introduction to Python 3
O


The Python interactive interpreter
PY


• Arrow key: Scrolls through lines previously executed with the interpreter.
• Code: The text that represents a computer program.
• Prompt (">>>"): Informs the programmer that the interpreter is ready to accept
commands → displayed by the Phyton interpreter

Programming in Python
• Statement: a program instruction
• Program: series of statements
• Expressions: code that return a value when evaluated
• Variables: named references to values stored by the interpreter.

Basic output
• Print an output → print('hello’+’world') = hello world
• Print and maintain same line → print('Hello', end=' ')
• Good practice
o single quotes for shorter strings
o double quotes for more complicated text or text that contains single quotes

,Basic input
• Reading input → statement: variable_name = input(‘text inside the Text box’)
• convert strings to integers
o my_string = '123'
o my_int = int('123')
• combine input and int → wage = int(input())

Errors
• SyntaxError: The program contains invalid code that can not be understood.
• IndentationError: The lines of the program are not properly indented.
• ValueError: An invalid value is used – can occur if giving letters to int().
• NameError: The program tries to use a variable that does not exist.
• TypeError: An operation uses incorrect types – can occur if adding an int to a string.
• Logic error/bug: the program is logically flawed.

Computer tour
• Operating system: Manages programs and interfaces with peripherals.
D


• Disk: Non-volatile storage with slower access.
O


• RAM: Volatile storage with faster access usually located off processor chip.
• Cache: Relatively small volatile storage with fastest access located on processor chip.
N


• Clock: Rate at which a processor executes instructions.
• Moore’s law: The doubling of IC capacity roughly every 18 months.
O
T


Language history
• Machine language: founded on a two-character alphabet → bit
C


• Machine Instruction: Particular sequence of 0s and 1s rep
•
O


Executable program: sequence of machine instructions together
• Assemblers: translate human readable instructions (assembly language) into an
PY


executable program
• High-level languages: support programming using formulas or algorithms
o FORTRAN (for "Formula Translator")
o ALGOL (for "Algorithmic Language")
• High level instruction: statement
• Compilers: to automatically translate high-level language, into assembly-language
• Scripting languages: to execute programs without the need for compilation
• Script: program whose instructions are executed by another program → an interpreter
→ slower but no need for compilation
• Python: scripting language
o Python 3.0 is not backwards compatible.
o Python 3.x versions are becoming more widely
o Open source

,3. ADTs and Algorithms
Introduction to algorithms
• Algorithm: sequence of steps to solve a problem or calculation
• Computational problem: input + question about the input + output.
• Common algorithm
o Longest common substring: between two inputs strings.
o Binary search: an efficient algorithm for searching a list.
o Dijkstra's shortest path: determines the shortest path from a start vertex to each
vertex in a graph.

Efficient algorithms and hard problems
• Algorithm efficiency: measured by the algorithm runtime
• Efficient algorithm: runtime increases no more than polynomially (nk)
• NP-complete problems: no known efficient algorithm exists

Data structures
D


• Data structure: a way of organizing, storing, and performing operations on data
O


• Selection of data structure: depends on
o type of data being stored
o operations the program may need to perform on that data
N


• the algorithms to implement operations are typically specific to each data structure
O


Basic data structures.
T


• Record: stores subitems, with a name associated to each
•
C


Array: stores an ordered list of items → each item is accessible by a positional index.
• Linked list: stores ordered list of items in nodes → each node stores data and has a
O


pointer to the next node.
•
PY


Binary tree: each node stores data and has up to two children → left and right child.
• Hash table: stores unordered items by mapping (or hashing) each item to a location in
an array.
• Heap:
o Max-heap: node's key is greater than or equal to the node's childrens' keys
o Min-heap: node's key is less than or equal to the node's childrens' keys.
• Graph: representing connections among items
o A vertex represents an item in a graph
o An edge represents a connection between two vertices in a graph.

Abstract data types
• Data type described by predefined user operations, such as "insert data at rear," without
indicating how each operation is implemented
• Programmer need not have knowledge of which data structure is used to use the list
ADT.
• Common ADTs.

, •
D

Common list ADT operations
O
N
O
T
C
O
PY



• Common operations for a queue ADT→ items are inserted at the end of the queue
and removed from the front of the queue.




Applications of ADTs
• ADTs support abstraction (hiding the underlying implementation details) → designers to
focus on higher-level operations → improves programmer efficiency
• Knowledge of an ADT's underlying implementation → to analyze runtime efficiency.
• ADTs in standard libraries

Document information

Uploaded on
August 10, 2026
Number of pages
65
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$28.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Highgradeshub
4.0
(2)
Sold
21
Followers
0
Items
5998
Last sold
2 weeks ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions