Перейти к содержимому

Stacks, Queues and Binary Search Trees in C++ — Built From Scratch, No STL

PRANAV SINGH

0:00 / 0:00

Stacks, Queues and Binary Search Trees in C++ — Built From Scratch, No STL

5 просмотров · 1 месяц назад
PRANAV SINGH
2 подписчика
5 просмотров · 1 месяц назад
Three data structures implemented from scratch in C++ with no STL containers: an array based stack, an array based circular queue, and a pointer based binary search tree. For each one I explain the idea first, then walk through the diagram, then run the actual program. This is my Basic Learning Assignment for CSC-6021, Data Structures and Algorithms II at Concordia University Chicago. GitHub repository (full source, diagrams and written documentation): https://github.com/Pranavxoxo/DS2-BLA... WHAT IS COVERED Stack: push, pop, peek, isEmpty, isFull, the top index and the -1 empty sentinel, stack overflow and stack underflow, and why every operation is O(1). Queue: enqueue and dequeue, front and rear indices, false overflow in a linear array queue, and why shifting elements is the wrong fix. Circular queue: modulo indexing, ring buffers, using a count member to distinguish full from empty, and why the rear can end up at a lower index than the front. Binary search tree: nodes, root, leaves and subtrees, the smaller-left larger-right ordering rule, insertion order and tree shape, duplicate rejection at no extra cost, predecessor and successor, and all three depth first traversals. Also covered: why an inorder traversal comes out sorted, why preorder rebuilds an identical tree, and why postorder is what a destructor uses. All three programs compile clean with -Wall under C++11 and each one is standalone with its own main function.