Coder Social home page Coder Social logo

poulcheria / data-structures--sorting-and-searching-algorithms Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 94 KB

Data Structures in C++: Sorting & Searching algorithms in C++. Implementations & performance analysis with a dataset of temperature & humidity measurements.

C++ 100.00%

data-structures--sorting-and-searching-algorithms's Introduction

Data-Structures--Sorting-and-Searching-Algorithms

Data Structures in C++: Sorting & Searching algorithms in C++.
Overview
This repository contains C++ implementations and performance analysis of essential sorting and searching algorithms as part of my university project for the Computer Engineering and Informatics Department (CEID) . The algorithms were tested on a dataset consisting of temperature and humidity measurements.

Sorting Algorithms

1. Merge Sort and Quick Sort

Merge Sort execution time: 21.643 sec
Quick Sort execution time: 24.844 sec

Theoretical complexities: Merge Sort: O(nlogn) comparisons and O(nlogn) swaps in the worst case. Quick Sort: O(n^2) comparisons and O(logn) swaps in the worst case, but O(nlogn) comparisons and O(logn) swaps on average.

Explanation: Merge Sort's worst-case complexity is O(nlogn) for both comparisons and swaps. Quick Sort has a worst-case complexity of O(n^2) for comparisons and O(logn) swaps. However, on average, Quick Sort's performance improves significantly to O(nlogn) comparisons and O(logn) swaps due to its randomized pivot selection strategy.

2. Heap Sort and Counting Sort

Heap Sort execution time: 22.949 sec
Counting Sort execution time: 20.513 sec

Theoretical complexities: Heap Sort: O(nlogn) comparisons and O(1) swaps in the worst case. Counting Sort: O(n + k) comparisons and O(n + k) swaps, where k is the range of input elements.

Explanation: Heap Sort's worst-case complexity is O(nlogn) for comparisons and performs a constant number of swaps (O(1)) per comparison. Counting Sort, on the other hand, has a complexity of O(n + k) for both comparisons and swaps, where k is the range of input elements. Counting Sort can be particularly efficient when the range of input elements is relatively small.

Searching Algorithms

1. Binary Search and Interpolation Search

Binary Search execution time: 4.717 sec
Interpolation Search execution time: 4.492 sec

Theoretical complexity: Both Binary Search and Interpolation Search have an average time complexity of O(logn).

Explanation: The theoretical complexity for the searching algorithms is correct. Both Binary Search and Interpolation Search have an average time complexity of O(logn) for sorted arrays.

Installation and Usage

To run the Data-Structures--Sorting-and-Searching-Algorithms project:

  1. Clone or Download the Repository.
  2. Open the Project in a C++ IDE or Text Editor.
  3. Compile the C++ Files.
  4. Run the Executable by running the following command: ./main
  5. Interpret the Results

data-structures--sorting-and-searching-algorithms's People

Contributors

poulcheria avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.