DEV Community

Luca Eftimie
Luca Eftimie

Posted on

Why do we need to learn DSA?

Hi DEVCommunity,

I don't have a formal education in computer science. In college I studied a mix of coding, economics and maths. I learned basic concepts about programming in C, writing PL/SQL and R code. After I graduated, during the summer break, I wanted to focus my attention on low level programming. Until now, I build a linked list, a stack, a min-heap and studied the algorithms for knapsack problem and Huffman encoding.

I think it's an effective way of getting used to the programming environment. In addition, I noticed that my minds gets sharper and sharper with each passing day as long as I spend at least 2 hours on studying DSA.

In the coming months, I plan to continue this project adding more algorithms and data structures to the repos I made.

Luca

These are the links for the repos:

GitHub logo lucaeftimie / Data_Structures

Small C implementations of classic data structures, built with dynamically allocated linked nodes.

Data structures

Small C implementations of classic data structures, built with dynamically allocated linked nodes.

Contents

File Description
linkedlist.c A singly linked list supporting insertion (front, end, before/after a reference value, sorted), search, removal, sorting, reversal, and concatenating two lists.
queue.c A FIFO queue (enqueue/dequeue) built on a linked list with front/rear pointers and O(1) operations.
stack.c A LIFO stack (push/pop) built on a linked list.
min_heap.c A priority queue (Min-Heap) flat array implementation guaranteeing O(log n) insertions and O(1) extractions.

Each file is self-contained and includes its own main() with example usage.

linkedlist.c

Key operations:

  • create_node, add_node_at_the_front, add_node_at_the_end
  • add_node_before_ref / add_node_after_ref — insert relative to a value already in the list
  • add_node_sorted, create_sorted_list, sort_list — keep or make the list sorted
  • find_node, get_length, print_list
  • remove_node, modify_node
  • reverse_list
  • concatenate_lists — join two lists…

Algorithms

This is a collection of algorithms which helps me learn about how to think logically and how to write code in C.
Below you can see a contents table with the algorithms studied by me I used Clion as a development tool, and compiled the code using the CMake build tool.

Contents

Algorithm File Category Time Complexity Space Complexity
0/1 Knapsack dynamic_programming/knapsack.c Dynamic Programming O(n × W) O(n × W)
O(W) - optimized version

|

Structure

Each algorithm is a standalone .c file that can be compiled and run independently.
The algorithms are organized in folders, based on programming techniques.

Algorithms/
├── dynamic_programming/
│   └── knapsack.c
│
├── greddy_algorithms/
│   └──
│
├── encoding_algorithms/
│    └── huffman_encoding.c
│
└── README.md

Building and running

Each file can be compiled individually with gcc:

gcc -o knapsack knapsack.c
./knapsack
Enter fullscreen mode Exit fullscreen mode

Or it can be built using CMake.

cmake commands that i don
Enter fullscreen mode Exit fullscreen mode

Top comments (0)