You are on page 1of 11

Welcome back to

CSE331 – Data Structures


and Algorithms
Exercise
Implement the following generic sorting algorithms found in exercise
ASU-F23-Tut08-Ex01-GenericSearchAlgorithms.cpp :

template <typename t>


int linearSearch(const std::vector<t>&, const t&);

template <typename t>


int binarySearch(const std::vector<t>&, const t&);

// return -1 if not found


Exercise
Implement the member functions of the BST class in the following file,
EXCEPT FOR remove() and search2().

ASU-F23-Tut08-Ex02-BST.hpp

Use the accompanying driver to test your implementation.

ASU-F23-Tut08-Ex02-BST-Driver.cpp
IMPORTANT
ASSIGNMENT
Question 1
Write a function to reverse a linked list using a stack with function prototype:
Node* reverse_linked_list(Node* head)

This function takes a pointer to the first node of the linked list as input, and
returns a pointer to the first node of the reversed linked list.

. Weight: 1.5 marks .


IMPORTANT
ASSIGNMENT
Question 2
Write the enqueue function of the priority queue. It takes two arguments: the
element to be added and its priority. The function then inserts the element into
the queue in a way that maintains the priority order of the queue.

. Weight: 1.5 marks .


IMPORTANT
ASSIGNMENT
Question 3
Write the code for enqueue() and dequeue() methods of a Queue data structure
that uses two STL stacks for its logic. The enqueue method inserts an element
into the end of the queue, while the dequeue method removes and returns an
element from the front of the queue. You may only use stack methods.

. Weight: 2 marks .
IMPORTANT
ASSIGNMENT
Submission Details (Due next Monday)
- On LMS, soft copy submission: .cpp files and .hpp files (if you made any); and simple
code documentation in a Word (.docx) or PDF (.pdf) file.

- Make sure you submit working code. Test if before submitting!

- Keep your code clean. Clean code does not need comments to explain it, it should be
readable on its own. Save your commentary and explanation for your documentation.
Exercise
Let’s change topics… Hash Table time! Starting simple: Chaining Hash Table.

Refer to the given header file and implement the HashTable.

ASU-F23-Tut08-Ex03-StudentsHashTableChaining-Header.hpp

Use the accompanying driver to test your implementation.

ASU-F23-Tut08-Ex03-StudentsHashTableChaining-Driver.cpp
THANKS
Does anyone have any questions?
See you next time! :)

P.S. Don’t forget, you can always find me


on Microsoft Teams.

You might also like