CS50x - Week 5

Data Structures

·

2 min read

Introduction

Data structures are fundamental tools that help organize and store data efficiently, enabling us to perform operations and solve problems with ease.

This week I explored the fascinating world of data structures and their significance in computer science.

Stacks and Queues

They have the FIFO or “first in first out” property. This has specific actions associated with it like an item can be enqueued (meaning it can join a line or a queue) or *dequeued (*meaning it can leave the queue once it gets to the front of the line).

They contrast stack which has LIFO or “last in first out” property.

Resizing Arrays

This allows for dynamic memory allocation and provides a flexible approach to storing elements. With resizing arrays, I learnt how I can efficiently handle variable-sized collections, dynamically expanding or shrinking the array as needed.

Linked Lists

Linked lists consist of nodes that hold data and references to other nodes, forming a chain-like structure. It allows one to include values that are located in varying areas of memory. They also allow one dynamically grow and shrink the list as one desire.

Hashing and Hash Tables

Hashing is the idea of taking a value and being able to output a value that becomes a shortcut to it later. A fantastic combination of both arrays and linked lists is a hash table. It is an array of pointers to nodes

Tries

These are specialized data structures used for efficient string searching and retrieval. Tries are particularly useful when dealing with large sets of words or when implementing auto-complete functionality. By organizing words in a tree-like structure, tries offer fast and efficient search operations, making them essential in various applications.

I am astounded by the breadth and significance of data structures in computer science.