- ES Español

- EN English

5.19. Algorithms and Data Structures (Mandatory)
- Semester: 4th Sem. Credits: 4
- Hour of this course: Theory: 2 hours; Practice: 2 hours; Laboratory: 2 hours;
- Syllabus:
- htmlonly

Español

English - Prerrequisites:
- CS113 Objects-oriented programming II (3rd Sem) itemize
5.19.1. Justification ↑ Back to top
This course provides a comprehensive study of fundamental data structures and algorithms with emphasis on implementation using advanced C++ features. Building on prior C++ knowledge, students will implement generic data structures using templates and traits, ensuring type flexibility and performance. The course covers linear structures (vectors, various linked lists), tree structures (binary, AVL, B-trees), heaps, hash tables, tries, and concurrent data structures. Special focus is placed on modern C++ techniques including variadic templates for generic operations and concurrent programming for thread-safe data structures.
5.19.2. Generales Goals ↑ Back to top
- Implement generic data structures using templates and traits.
- Master advanced tree structures and balanced trees.
- Understand and implement concurrent data structures.
- Apply variadic templates for generic operations on containers.
- Analyze algorithmic complexity of all implemented structures.
- Design efficient data structures for specific problem constraints.
5.19.3. Contribution to Outcomes ↑ Back to top
- AG-C08) Problem Analysis: Identifies, formulates, and analyzes complex computing problems. (Usage)
- AG-C09) Design and Development of Solutions: Designs, implements, and evaluates solutions for complex computing problems. (Usage)
5.19.4. Content ↑ Back to top
5.19.4.1. Advanced Foundation for Data Structures (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Stroustrup, 2013; Vandevoorde et al., 2017a)
Topics
- Template metaprogramming review and advanced traits.
- Type traits and SFINAE for conditional compilation.
- Variadic templates and parameter packs.
- Perfect forwarding and universal references.
- Lambda expressions with generic captures.
- Policy-based design and CRTP (Curiously Recurring Template Pattern).
- Concept-based constraints (C++20 concepts if applicable).
Learning Outcomes
- Design type traits for customizing data structure behavior [Usage].
- Implement variadic templates for generic container operations [Usage].
- Apply policy-based design to create configurable data structures [Assessment].
- Use perfect forwarding to implement efficient constructors [Usage].
5.19.4.2. Foundational Data Structures (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Cormen et al., 2009; Stroustrup, 2013)
Topics
- Abstract Data Type (ADT) and operations on an ADT:
- Dictionary operations (insert, delete, find) enumerate
- Arrays:
- Numeric vs non-numeric, character strings
- Single (vector) vs multidimensional (matrix) enumerate
- Records/Structs/Tuples and Objects
- Linked lists (for historical reasons):
- Single vs Double and Linear vs Circular enumerate
- Stacks
- Queues and deques:
- Heap-based priority queue enumerate
- Hash tables/maps:
- Collision resolution and complexity (e.g., probing, chaining, rehash) enumerate
- Trees:
- Binary, n-ary, and search trees
- Balanced (e.g., AVL, Red-Black, Heap) enumerate
- Sets
Learning Outcomes
- For each ADT/Data-Structure in this unit:
- Explain its definition, properties, representation(s), and associated ADT operations.
- Explain step-by-step how the ADT operations associated with the data structure transform it. enumerate [Usage]
- For each algorithm in this unit explain step-by-step how the algorithm operates [Usage]
- Implement vector with customizable allocation policy using templates [Usage].
- Design generic linked list nodes with trait-based memory management [Usage].
- Compare time/space complexity of different linear structures [Assessment].
- Apply variadic templates to initialize containers with multiple elements [Usage].
5.19.4.3. Foundational Data Structures (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Cormen et al., 2009; Knuth, 1997a)
Topics
- Trees:
- Binary, n-ary, and search trees
- Balanced (e.g., AVL, Red-Black, Heap) enumerate
- Binary tree template implementation with iterator support.
- Binary search tree with trait-based comparison operators.
- Tree traversal algorithms (iterative and recursive).
- Expression trees and their applications.
- Template-based node structures with configurable payload.
Learning Outcomes
- Given requirements for a problem, develop multiple solutions using various data structures and algorithms. Subsequently, evaluate the suitability, strengths, and weaknesses selecting an approach that best satisfies the requirements [Assessment]
- Explain factors beyond computational efficiency that influence the choice of algorithms, such as programming time, maintainability, and the use of application-specific patterns in the input data [Familiarity]
- Implement generic binary tree with configurable traversal order [Usage].
- Design expression tree evaluator using visitor pattern [Usage].
- Analyze tree operation complexities for different balancing strategies [Assessment].
5.19.4.4. Balanced and Multi-way Trees (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Cormen et al., 2009; Knuth, 1997a; Sedgewick and Wayne, 2011)
Topics
- AVL tree implementation with template-based balancing trait.
- Red-black tree properties and operations.
- B-Tree template implementation for disk-based storage.
- 2-3 Tree and 2-3-4 Tree structures.
- Digital trie (prefix tree) implementation.
- Suffix trees and their applications in string processing.
- Node splitting/merging strategies for B-trees.
Learning Outcomes
- Implement self-balancing trees using policy-based design [Usage].
- Design B-tree for database index applications [Usage].
- Evaluate trade-offs between different balanced tree structures [Assessment].
- Implement trie for efficient string prefix matching [Usage].
5.19.4.5. Foundational Data Structures (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Cormen et al., 2009; Sedgewick and Wayne, 2011)
Topics
- Trees:
- Binary, n-ary, and search trees
- Balanced (e.g., AVL, Red-Black, Heap) enumerate
- Binary heap implementation using array representation.
- Min-heap and max-heap variants.
- Heapify algorithms and complexity analysis.
- Priority queue ADT implementation.
- Binomial heap and Fibonacci heap overview.
- Heap applications: Dijkstra's algorithm, heap sort.
Learning Outcomes
- Explain the heap property and the use of heaps as an implementation of a priority queue [Familiarity]
- Implement generic heap with configurable comparison trait [Usage].
- Design priority queue supporting multiple priority update strategies [Usage].
- Analyze heap operations complexity for different heap types [Assessment].
- Apply heap in graph algorithm implementations [Usage].
5.19.4.6. Foundational Data Structures (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Cormen et al., 2009; Knuth, 1997a)
Topics
- Hash tables/maps:
- Collision resolution and complexity (e.g., probing, chaining, rehash) enumerate
- Hash function design and properties.
- Separate chaining implementation with linked lists.
- Open addressing: linear probing, quadratic probing, double hashing.
- Perfect hashing and minimal perfect hashing.
- Cuckoo hashing and hopscotch hashing.
- Hash table resizing strategies and load factor management.
Learning Outcomes
- Explain how collision avoidance and collision resolution is handled in hash tables [Familiarity]
- Design generic hash table with configurable collision resolution [Usage].
- Implement custom hash functions for user-defined types [Usage].
- Evaluate performance of different hashing schemes [Assessment].
- Apply hash tables in compiler symbol table implementation [Usage].
5.19.4.7. Concurrent Data Structures (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Herlihy and Shavit, 2012; Williams, 2019)
Topics
- Thread-safe data structure design principles.
- Lock-based concurrent linked lists.
- Lock-free and wait-free algorithms.
- Concurrent hash tables with fine-grained locking.
- Atomic operations and memory ordering.
- Concurrent queues (bounded and unbounded).
- Concurrent stacks and elimination techniques.
Learning Outcomes
- Design thread-safe data structures using mutex and lock guards [Usage].
- Implement lock-free linked list using atomic operations [Usage].
- Analyze performance of concurrent vs sequential data structures [Assessment].
- Apply concurrent queues in producer-consumer patterns [Usage].
5.19.4.8. Specialized Structures and Applications (8 hours) [Skills AG-C08,AG-C09] ↑ Back to top
Bibliography: (Okasaki, 1999; Sedgewick and Wayne, 2011)
Topics
- Persistent data structures.
- Disjoint-set union (union-find) with path compression.
- Bloom filters and their probabilistic properties.
- Skip lists for probabilistic balanced search.
- Segment trees and Fenwick trees for range queries.
- Spatial data structures: k-d trees, quadtrees.
- Cache-oblivious data structures.
Learning Outcomes
- Implement persistent data structures with structural sharing [Usage].
- Design union-find with both union by rank and path compression [Usage].
- Apply specialized structures to solve domain-specific problems [Assessment].
- Evaluate space-time tradeoffs in probabilistic data structures [Assessment].
5.19.5. Bibliography ↑ Back to top
Stroustrup, B. (2013). The C++ Programming Language. Addison-Wesley Professional, Upper Saddle River, NJ, 4th edition.
Vandevoorde, D., Josuttis, N. M., and Gregor, D. (2017a). C++ Templates: The Complete Guide. Addison-Wesley Professional, Upper Saddle River, NJ, 2nd edition.
Cormen, T. H., Leiserson, C. E., Rivest, R. L., and Stein, C. (2009). Introduction to Algorithms. MIT Press, 3rd edition.
Knuth, D. E. (1997a). The Art of Computer Programming, Volume 1: Fundamental Algorithms. Addison-Wesley, 3rd edition.
Sedgewick, R. and Wayne, K. (2011). Algorithms. Addison-Wesley, 4th edition.
Herlihy, M. and Shavit, N. (2012). The Art of Multiprocessor Programming. Morgan Kaufmann, revised 1st edition.
Williams, A. (2019). C++ Concurrency in Action. Manning Publications, Shelter Island, NY, 2nd edition.
Okasaki, C. (1999). Purely Functional Data Structures. Cambridge University Press.