Skip to content

Implement optimal merge pattern #5076

@Raj-Pansuriya

Description

@Raj-Pansuriya

Objective

  • Merge a set of sorted files of different length into a single sorted file. We need to find an optimal solution, where the resultant file will be generated in minimum time.

Approach

  • If the number of sorted files are given, there are many ways to merge them into a single sorted file. This merge can be performed pair wise.
  • To merge a m-record file and a n-record file requires possibly m+n record moves, the optimal choice being, merge the two smallest files together at each step (greedy approach).

Hey, @poyea
I would like to contribute the mentioned algorithm to the repo.
Also if you feel its worth the contribution, please guide me as where to put this algo in the directory tree as there is no dedicated directory for greedy algorithms.

Waiting for your response...!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions