Commit Graph
23 Commits
Author SHA1 Message Date
CaZzzer 0789614ef1 10.9 Lab: Heap - Build min/max-heaps (of integers)
Generalize one of the previous labs to build a min-heap or a max-heap using the same heap functions. In main() pass either compareMin or compareMax to the insertHeap function:

- minHeap.insertHeap(num, compareMin);
- maxHeap.insertHeap(num, compareMax);

You also have to update the following functions of the Heap class:

- bool insertHeap(int itemIn);
- bool deleteHeap(int &itemOut);
- void _reHeapUp(int lastndx);
- void _reHeapDown(int rootndx);

This program will:

- read integers from the keyboard and insert them into a min-heap and a max-heap
- display the integers as they are deleted from the min-heap.
- display the integers as they are deleted from the max-heap.
2024-05-28 19:21:43 -07:00
CaZzzer cc06e5fbdb 10.8 Lab: Heap - Display Heap as an Indented List
Change the previous lab to display a min-heap as an indented list (level numbers included). In order to do this you will have to add two new member functions to the heap class

- void _printIndented(int index, void visit(int, int)); // A
- void printIndented(void visit(int, int)); // B

Note: One function would be sufficient(A). However, to make the call simpler, a wrapper function (B) has been added (to "hide" the root of the heap).

Another solution is to add level as a parameter to _printIndented:

- void _printIndented(int index, int level, void visit(int, int));
2024-05-28 18:59:23 -07:00
CaZzzer eb1cf4176f 10.7 Lab: Heap - Build a min-heap (of integers)
Change the previous lab to work with a min-heap instead of a max-heap.
2024-05-28 18:41:58 -07:00
CaZzzer 0ca7ce28fd 10.6 Lab: Heap - Build a max-heap (of integers)
This program will read integers from the keyboard, insert them into a max-heap, and display them as they are deleted from the heap. Most of the code is given:

- Heap.h
- Heap.cpp
- main.cpp

Your task is to finish defining four function in Heap.cpp:

- insertHeap
- deleteHeap
- _reHeapUp
- _reHeapDown
2024-05-28 18:33:44 -07:00
CaZzzer 276575ca62 6.21 Lab: Doubly-Linked List (Insert - reject duplicates)
Fix memory leak when attempting to insert a duplicate
2024-05-19 13:46:15 -07:00
CaZzzer 30ad8892de 9.14 Lab: Hash ADT
Now that you have a working implementation of the HashNode and HashTable classes, you can convert them to templates, and update main.cpp to match with the new template classes.

In order for everything to work you will also have to:

- overload the == operator for the Student class
- declare the hash function a friend function of the Student class
- send the hash function as an argument to insert, remove, and search functions.
2024-05-11 16:44:34 -07:00
CaZzzer b43f08aacc 9.13 Lab: Hashing - Linear Probe (insert, search, delete)
Reuse code from the previous lab and write new code as described below:

- search hash: Modify this function to return -1 if the target key is not found or the number of collisions for that key if found.

`int search(Student &target, string key);`

- remove hash: Create a new function to delete an item from the hash table.
- insert manager: inserts user provided data into the hash table and rejects duplicates.
2024-05-11 16:16:27 -07:00
CaZzzer 3d112946f5 9.12 Lab: Hashing - Linear Probe (insert, search)
Hash Function: Add the ASCII values of all characters in the key string and return the reminder obtained when divided by the size of the table.

Example: If key = "Bob", and size = 53, we get (66 + 111 + 98) % 53 => 275 % 53 => 10.

Collision Resolution Method: Linear Probe.

The assignment consists of the following classes/files:

- main.cpp (incomplete)
- Student.h (given)
- HashNode.h (given)
- HashTable.h (given)
- HashTable.cpp (incomplete)

Read and understand the given code then write two functions:

- insert hash
- search hash
2024-05-11 15:43:39 -07:00
CaZzzer 01d2d7f2cf 8.14 Lab*: BT <--- BST ADT (Park)
- Modify the Park class from previous assignments.
- Rewrite the private insert as a recursive function.
- Write the buildBST() function (similar to buildList() in the doubly-linked list lab).
- Display the number of nodes in the tree as shown below:

- Display the tree in inorder, preorder or postorder
- Display the tree as an indented list
- Display the inner nodes of the BST (including its root), in alphabetical order by code

- Write the searchManager() function (similar to searchManager() in the doubly-linked list lab). It calls search BST in a loop.
- Search the BST (implement the recursive private search function).
2024-05-03 17:08:04 -07:00
CaZzzer 42ba63e654 8.12 Lab: BT <--- BST (Search)
Implement the pair of search functions for searching the BST:

- _search - recursive (private function)
- search - wrapper for _search (public function)
2024-05-03 15:11:07 -07:00
CaZzzer 0bc2b9690f 8.9 Lab: BT <--- BST (Indented Tree)
Write a variation of one of the Depth-First Traversal Functions named printTree that displays the indented tree, including the level numbers.
2024-05-03 14:00:39 -07:00
CaZzzer 8e55246e9c 8.8 Lab: BT <--- BST (Smallest/Largest)
The assignment consists of the following classes/files:

- BinaryNode.h (template, given)
- BinaryTree.h (template, incomplete)
- BinarySearchTree.h(template, incomplete)
- main.cpp (incomplete)

Write the following functions:

- findSmallest (recursive)
- findLargest (recursive)
2024-05-03 13:15:46 -07:00
CaZzzer 2ff40ef4e9 8.7 Lab: BT <--- BST (Traversals) 2024-05-03 13:02:04 -07:00
CaZzzer 41c45e09fb 8.4 Lab: BT - Traversals (in-, post-, and pre-Order) - Version 2 2024-05-03 12:34:37 -07:00
CaZzzer 6f5d2f2d5e 8.3 Lab: BT - Traversals (in-, post-, and pre-Order) 2024-05-02 17:34:56 -07:00
CaZzzer 5b5e2b6d67 6.10 Lab*: Singly-Linked Lists (Park)
Optimize searchList
2024-05-02 16:14:13 -07:00
CaZzzer 4ae56c5a42 6.10 Lab*: Singly-Linked Lists (Park)
Replace Park.hDisplay() with output stream operator
2024-05-02 13:03:38 -07:00
CaZzzer ef6762ad57 6.23 Lab*: Doubly-Linked Lists (Park) - Templates 2024-04-28 13:51:08 -07:00
CaZzzer 274e3025b1 6.22 Lab: Doubly-Linked Lists (Park) 2024-04-28 13:22:45 -07:00
CaZzzer 2f6299ac85 6.21 Lab: Doubly-Linked List (Insert - reject duplicates) 2024-04-28 12:38:23 -07:00
CaZzzer a3cc673c86 6.20 Lab: Doubly-Linked List (Delete) 2024-04-28 12:25:34 -07:00
CaZzzer fa7aed64b2 6.19 Lab: Doubly-Linked List (Insert & Display) 2024-04-28 12:14:36 -07:00
CaZzzer a828b3525a initial commit 2024-04-28 11:54:46 -07:00