0% found this document useful (0 votes)
2 views1 page

Pc Science

The document outlines core concepts of data structures and algorithms, comparing arrays and linked lists in terms of access time, insertion, and memory usage. It details sorting algorithms like QuickSort and MergeSort, including their time complexities and operational steps. Additionally, it introduces graph algorithms such as BFS and DFS, and provides practice problems for implementation and application of these concepts.

Uploaded by

michal.boga64
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)
2 views1 page

Pc Science

The document outlines core concepts of data structures and algorithms, comparing arrays and linked lists in terms of access time, insertion, and memory usage. It details sorting algorithms like QuickSort and MergeSort, including their time complexities and operational steps. Additionally, it introduces graph algorithms such as BFS and DFS, and provides practice problems for implementation and application of these concepts.

Uploaded by

michal.boga64
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/ 1

# Data Structures & Algorithms

*Core concepts for efficient programming*

## **1. Arrays vs. Linked Lists**


| **Feature** | **Array** | **Linked List** |
|--------------|----------|----------------|
| Access Time | O(1) | O(n) |
| Insertion | O(n) | O(1) |
| Memory | Static | Dynamic |

## **2. Sorting Algorithms**


**QuickSort**
- **Time Complexity:** O(n log n) avg, O(n²) worst
- **How it works:**
1. Pick a pivot.
2. Partition into elements < pivot and > pivot.
3. Recursively sort subarrays.

**MergeSort**
- **Time Complexity:** O(n log n) always
- **How it works:**
1. Split array in half.
2. Recursively sort each half.
3. Merge the two halves.

## **3. Graph Algorithms**


**BFS (Breadth-First Search)**
- Uses a queue.
- Finds shortest path in unweighted graphs.

**DFS (Depth-First Search)**


- Uses a stack.
- Useful for topological sorting.

## **Practice Problems**
1. Implement a stack using a linked list.
2. Sort `[5, 2, 9, 1]` using QuickSort step-by-step.
3. Perform BFS on a given graph starting from node A.

**Sample Solution for #2:**


- Pivot = 5 → Partitions: `[2, 1]` and `[9]`
- Sort `[2, 1]` → `[1, 2]`
- Final sorted array: `[1, 2, 5, 9]`

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy