Welcome to the Interview Algorithm Lab! This repository is a focused collection of classic computer science algorithms, implemented in C#. It's designed to be a practical resource for interview preparation, learning, and practice.
Whether you're brushing up for a technical interview, studying data structures and algorithms, or just curious, this lab provides clear, well-documented, and easy-to-understand implementations.
- Clear Implementations: Each algorithm is implemented in C# with a focus on readability and correctness.
- Detailed Explanations: Every algorithm includes a
README.mdfile that explains its logic, time/space complexity, and a real-world analogy. - Interactive Demo: A console application is included to run each algorithm and see it in action, step-by-step.
This repository contains a collection of fundamental searching algorithms, sorting algorithms, and data structures.
- Binary Search: An efficient algorithm for finding an item from a sorted list of items.
- Linear Search: A simple method that sequentially checks each element of a list until a match is found or the whole list has been searched.
- Bubble Sort: A straightforward sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.
- Insertion Sort: A simple sorting algorithm that builds the final sorted array one item at a time.
- Merge Sort: A highly efficient, stable, comparison-based sorting algorithm using a divide and conquer strategy.
-
Quick Sort: An efficient, in-place sorting algorithm that uses a divide and conquer approach. It is often faster in practice than other
$O(n \log n)$ algorithms.
- HashTable: A data structure that maps keys to values for highly efficient lookup, implementing an associative array.
- LinkedList: A linear collection of data elements where each element points to the next, allowing for efficient insertions and deletions.
- Queue: A linear structure which follows a First-In-First-Out (FIFO) order.
- Stack: A linear structure which follows a Last-In-First-Out (LIFO) order.
The Algorithms.Demo project makes it easy to visualize and understand how these algorithms work.
The console application provides a simple menu to:
- Choose an algorithm to execute (e.g., Bubble Sort, Binary Search).
- Select your input:
- Enter a comma-separated list of numbers.
- Generate a random array of a specified size.
- See the output: The application will print the step-by-step execution of the chosen algorithm, showing comparisons, swaps, and the state of the array at each stage.
To get started with this repository:
- Clone the repository:
git clone https://github.com/beheshty/interview-algo-lab.git - Open in Visual Studio:
Open the
Interview-Algo-Lab.slnsolution file. - Explore the code:
Navigate through the
Algorithmsdirectory to see the implementations and read the detailedREADME.mdfiles for each algorithm.
Contributions are welcome! If you'd like to add more algorithms, improve existing ones, or enhance the demo application, please feel free to fork the repository and submit a pull request.