0% found this document useful (0 votes)
12 views

Class Note 2: Data Structures and Algorithms

Intro into Data Structures and Algorithms

Uploaded by

Dillon Sterling
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Class Note 2: Data Structures and Algorithms

Intro into Data Structures and Algorithms

Uploaded by

Dillon Sterling
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structures and Algorithms

Page 1
Arrays

Definition: A collection of elements of the same data type stored in contiguous


memory locations.
Advantages:
Fast Access and Modification: Arrays allow for fast access and modification
of elements using their index.
Efficient Use of Memory: Arrays store elements in contiguous memory
locations, making efficient use of memory.
Disadvantages:
Fixed Size: Arrays have a fixed size, which means that once an array is
created, its size cannot be changed.
Slow Insertion and Deletion: Inserting or deleting elements in an array can
be slow, especially if the array is large.

Linked Lists

Definition: A dynamic collection of elements, each pointing to the next


element.
Advantages:
Efficient Insertion and Deletion: Linked lists allow for efficient
insertion and deletion of elements, as only the affected nodes need to be updated.
Flexible Size: Linked lists can grow or shrink dynamically, making them
suitable for applications where the size of the data is unknown.
Disadvantages:
Slow Access: Linked lists have slower access times compared to arrays, as
each element must be traversed sequentially.
More Memory Usage: Linked lists require more memory than arrays, as each
element has a pointer to the next element.

Page 2
Sorting Algorithms

Bubble Sort:
Definition: A simple sorting algorithm that repeatedly steps through the
list, compares adjacent elements, and swaps them if they are in the wrong order.
Time Complexity: O(n^2)
Space Complexity: O(1)
Selection Sort:
Definition: A sorting algorithm that selects the smallest element from the
unsorted portion of the list and swaps it with the first unsorted element.
Time Complexity: O(n^2)
Space Complexity: O(1)
Insertion Sort:
Definition: A sorting algorithm that builds the final sorted list one item
at a time, inserting each item into its proper position.
Time Complexity: O(n^2)
Space Complexity: O(1)
Merge Sort:
Definition: A divide-and-conquer algorithm that splits the list into
smaller sublists, sorts each sublist, and then merges the sorted sublists.
Time Complexity: O(n log n)
Space Complexity: O(n)
Quick Sort:
Definition: A divide-and-conquer algorithm that selects a pivot element,
partitions the list around the pivot, and recursively sorts the sublists.
Time Complexity: O(n log n) on average, O(n^2) in the worst case
Space Complexity: O(log n) on average, O(n) in the worst case

Other Data Structures

Stacks: A last-in, first-out (LIFO) data structure that allows for efficient
insertion and deletion of elements.
Queues: A first-in, first-out (FIFO) data structure that allows for efficient
insertion and deletion of elements.
Trees: A hierarchical data structure that consists of nodes, each with a value
and zero or more child nodes.
Graphs: A non-linear data structure that consists of nodes and edges, which
connect pairs of nodes.

You might also like