trainings/AdvancedCppV2/Presentation/exercises/list
2024-04-25 09:39:28 +02:00
..
solution AdvC++ - pierwszy commit 2024-04-25 09:39:28 +02:00
CMakeLists.txt AdvC++ - pierwszy commit 2024-04-25 09:39:28 +02:00
list.cpp AdvC++ - pierwszy commit 2024-04-25 09:39:28 +02:00
README.md AdvC++ - pierwszy commit 2024-04-25 09:39:28 +02:00

Linux compilation

> mkdir build
> cd build
> cmake -DCMAKE_BUILD_TYPE=Debug ..
> make

Valgrind usage

> valgrind valgrind_params path/to/binary binary_params, eg:
> valgrind --leak-check=full ./List
> or full output using command: valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./List

Resource exapmle

Take a look at list.cpp file, where simple (and buggy) single-linked list is implemented.

  • pushFront method adds a new Node at the begining of the list.
  • findByValue method iterates over the list and returns the first Node with matching value or nullptr.
  1. Compile and run List application
  2. Fix memory leaks without introducing smart pointers
  3. Fix memory leaks with smart pointers. What kind of pointers needs to be applied and why?
  4. Add function to add a node at the end of the list (try to do this with time complexity O(1))
  5. Add function to delete node with provided value.