Skip to content

(Java && C#)/ Ch 10 / Q 1 - Sorted Merge / Input demo array is not sorted #191

Open
@moudrick

Description

@moudrick

There is a flaw in demo example for Question 1 Sorted Merge of Chapter 10 Sorting and Searching. The demo array that is supposed to be sorted as a pre-condition is not actually sorted. This leads to the fact that the demo result is not sorted as well.
See CtCI-6th-Edition/Java/Ch 10. Sorting and Searching/Q10_01_Sorted_Merge/Question.java:

Line 34: int[] b = {1, 4, 7, 6, 7, 7};

Same goes to C# Demo.
See Issue #17 there - Ch 10 / Q 1 - Sorted Merge / Input demo array is not sorted.
See CtCI-6th-Edition-CSharp/Ch 10. Sorting and Searching/Q10_01_Sorted_Merge.cs

Line 42: int[] b = new int[] { 1, 4, 7, 6, 7, 7 };

At the same time, in PHP solutions, this example is modified to be sorted and used in demo unit tests.
See CtCI-6th-Edition-php/test/chapter10/question10.01/SortedMergeTest.php

Line 48: $b = [ 1, 4, 6, 7, 7, 7 ];

If this unsorted sample is not introduced intentionally to check if the reader is attentive, this should be fixed, I believe. Preparing Pull Requests for this:

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