Data Structures

This project covers the organization of data and the algorithms!

Software Used  

Languages Used  

Visual Studio

C++

Feel Free to Download the Source Code.
Source Code

Project Topics

Explanations
Dynamic Array
Vector
List
Dynamic List
Unordered Map
Dictionary
Binary Search Tree
Huffman Compression
Code
Dynamic Array
Vector
List
Dynamic List
Unordered Map
Dictionary
Binary Search Tree
Huffman Compression

Objectives

image

This project covers the organization of data and the algorithms that are used for sorting, searching, and problem solving. Students will learn how fundamental data structures and algorithms function and are implemented. Topics addressed in this course include managing complexity, linked structures, abstraction, analysis, vectors, lists, stacks, queues, trees, heaps, and graphs.

Programming Code

Guidance

Set Up the basic structure of each data type!

Programming Explanation

What is a Dynamic Array?

A dynamic array is quite similar to a regular array, but its size is modifiable during program runtime. DynamArray elements occupy a contiguous block of memory.

Once an array has been created, its size cannot be changed. However, a dynamic array is different. A dynamic array can expand its size even after it has been filled.

During the creation of an array, it is allocated a predetermined amount of memory. This is not the case with a dynamic array as it grows its memory size by a certain factor when there is a need.

Vector

Vectors are same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators. In vectors, data is inserted at the end. Inserting at the end takes differential time, as sometimes there may be a need of extending the array. Removing the last element takes only constant time because no resizing happens. Inserting and erasing at the beginning or in the middle is linear in time.

List

Lists are sequence containers that allow constant time insert and erase operations anywhere within the sequence, and iteration in both directions.

List containers are implemented as doubly-linked lists; Doubly linked lists can store each of the elements they contain in different and unrelated storage locations. The ordering is kept internally by the association to each element of a link to the element preceding it and a link to the element following it.

Dynamic List

Linked lists are inherently dynamic data structures; they rely on new anddelete (or malloc and free) for their operation. Normally, dynamic memory management is provided by the C/C++ standard library, with help fromthe operating system. However, nothing stops us from writing our own allocator,providing the same services as malloc and free.

Unordered Map

The unordered_map in C++ is like a data structure of dictionary type that store element. It has a sequence of (key, value) pair, which allows fast retrieval of an individual element based on their unique key.

Dictionary

A dictionary is defined as a general-purpose data structure for storing a group of objects. A dictionary is associated with a set of keys and each key has a single associated value. Whenpresented with a key, the dictionary will simply return the associated value.

Binary Search Tree

A Binary Search Tree or BST as it is popularly called is a binary tree that fulfills the following conditions:

  1. The nodes that are lesser than the root node which is placed as left children of the BST.
  2. The nodes that are greater than the root node that is placed as the right children of the BST.
  3. The left and right subtrees are in turn the binary search trees.

This arrangement of ordering the keys in a particular sequence facilitates the programmer to carry out operations like searching, inserting, deleting, etc. more efficiently. If the nodes are not ordered, then we might have to compare each and every node before we can get the operation result.

Huffman Compression

Huffman coding is a lossless data compression algorithm. The idea is to assign variable-length codes to input characters, lengths of the assigned codes are based on the frequencies of corresponding characters. The most frequent character gets the smallest code and the least frequent character gets the largest code.