Giter VIP home page Giter VIP logo

ekalgorithms's Introduction

Hello, World!

profile for Evgeny Karkan at Stack Overflow, Q&A for professional and enthusiast programmers

ekalgorithms's People

Contributors

aceisscope avatar ahanmal avatar aspcartman avatar bitdeli-chef avatar chocochipset avatar cuongtv51 avatar evgenykarkan avatar kiwivandi avatar klmitchell2 avatar shrtlist avatar squarezw avatar stanislaw avatar vittoriom avatar xhzengaib avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ekalgorithms's Issues

Is more efficient implementation of reversedArrayWithArray: possible?

Following my previous issue #34:

I think that your original implementation of reversedArrayWithArray can be improved by using the technique similar to what is used in #30 and #31:

Only first n/2 elements should be traversed exchanging i and count-i on each step - the middle element (if it exists - stays one the same position - hm, nice!).

Let me know, what do you think.

No visible interface for

Error:(33, 53) no visible @interface for 'NSNumber' declares the selector 'isLessThan:'
Error:(52, 26) no visible @interface for 'NSNumber' declares the selector 'isGreaterThan:'

etc. It seems podspec has some dependency missing. Strange enough, no invalid imports detected.

EDIT:
Well, NSComparisonMethods is only available on macosx. Well, I guess I make a fix and a pull request.

LCS and LD for NSString

hi i once wrote longest common subsequence and Levenshtein distanc algorithm as an NSString category in this tiny reop but when i came across this repo of yours i feel that maybe i could add the two methods into your project. is it okay for me to make a pull request then?

Array Shuffle

I would like to add the Fisher–Yates method to shuffle an array.

Cool?

EKAlgorithms is on Travis

All works fine now.

There were problems with MapKit on OS X - it is supported only in 10.9, while Travis machines still have 10.8.5. I mocked all the geometry needed for now, so EKAlgorithms does not depend on any external frameworks: nor CoreLocation, nor MapKit.

Implement algorithms both using highest Cocoa API and our "white-boxed" implementations.

The changed proposed #14 is good but only partially - it is good to know that Apple's reverseObjectEnumerator does its job - and as of Apple recommends to "use highest API possible" - it would be a better choice than to implement it by hands, but I think it would still be great to have both variant of methods to be kept in EKAlgorithms.

What I suggest is to keep both methods side by side, the only trick is again to invent a good convention to handle this:

My initial thought was something like:

+ (NSArray *)reversedArrayWithArray:(NSArray *)arrayToReverse
+ (NSArray *)native_reversedArrayWithArray:(NSArray *)arrayToReverse

or

+ (NSArray *)reversedArrayWithArray:(NSArray *)arrayToReverse
+ (NSArray *)CocoaImplementation_reversedArrayWithArray:(NSArray *)arrayToReverse

But I personally dislike using underscores in method names that is why I also thought about something like

+ (NSArray *)reversedArrayWithArray:(NSArray *)arrayToReverse
+ (NSArray *)reversedArrayWithArrayImplementedByCocoa:(NSArray *)arrayToReverse

For now I think that "CocoaImplementation_reversedArrayWithArray" is the best naming convention to be used for methods showing usage of highest-level of API suggested by Cocoa.

Let me know what you think.


Here are more examples we could write using Cocoa API:

Index of maximum element: [array valueForKeyPath:@"@max.integerValue"]
Binary search from awesome objc.io Issue n7, Binary Search.

To move most of the methods in appropriate categories

After taking a look at the classes, I found that most of the methods could be simplified if moved to categories instead of their own class.

Example:
+ (NSUInteger)indexOfMaximumElementInArray:(NSArray *)array;
could become
- (NSUInteger)indexOfMaximumElement;

+ (NSInteger)indexOfObjectViaLinearSearch:(id)object inArray:(NSArray *)arrayToSearch;
could become
- (NSInteger)indexOfObjectViaLinearSearch:(id)object;

+ (NSMutableArray *)bubbleSortedArrayWithUnsortedArray:(NSMutableArray *)unsortedArray;
could become
- (NSArray *)bubbleSort;

+ (BOOL)isGivenStringPalindrome:(NSString *)string;
could become
- (BOOL)isPalindrome;

and so on..
Do you agree with this? If yes, I will move methods to categories so that their interface will be easier to use.

To create Unit Tests for the algorithms

I'm quite a fan of unit testing (not necessarily TDD), and while refactoring methods of EKSearchStuff, EKSortStuff and EKArrayStuff I found myself in the position of having to check the console (for the output of the main file) to see if I broke something or not.
I would like to create a unit tests suite (if you don't mind I would use Kiwi framework) to make it easier in the future to refactor things and also for new people to add new algorithms.
Of course I won't be able to write the whole suite by myself, so I will need some help.
What do you think?

Thank you for your great collection.

Hi, I'm new to programming, and I chose Objective-C as my first programming language. I've been search for a while but I couldn't find any book about Data Structure and Algorithms in Objective-C. So can you give me some source for learning these things.

Thanks.

Incorrect isPrime Method

for (int i = 2; i <= (int)sqrt(givenNumber); i++) {
         if (givenNumber % i == 0) {
           return YES;
         }
     }

should be:

for (int i = 2; i <= (int)sqrt(givenNumber); i++) {
         if (givenNumber % i == 0) {
           return NO;
         }
     }

I'll open a PR soon.

Replace mutableCopy with [NSMutableArray arrayWithArray:] everywhere.

Before today I wasn't aware that besides creating mutable array -[NSArray mutableCopy] also makes copy of each element.

Now, having this in mind, I am pretty sure, that for general consistency of the whole algorithms base we need to eliminate all these mutableCopy strings and replace them with corresponding [NSMutableArray arrayWithArray:] strings.

Use NSTreeController instead

I found AppKit framework have already implement tree structure, and I will rewrite tree related code if possible.

To optimize each loop.

Every single loop will be faster without any additional computations and methods call.
E.g "[array count]" in loop such as "for (NSUinteger i = 0; i < [array count]; i++)" should be extracted to independent local variable NSUinteger counter = [array count].
So the loop will be faster & look like "for (NSUinteger i = 0; i < counter; i++)".

[Question]Some code style? function question?

Hi,

In EKGraph.m, I see code like this

NSMutableArray *parent = [@[] mutableCopy];
NSMutableDictionary *dist     = [@{} mutableCopy];

why not

NSMutableArray *parent = [NSMutableArray array];
NSMutableDictionary *dist     = [NSMutableDictionary dictionary];

Is this kind of code relative to special function or just a way of style?

Add a section about friendly/similar repositories?

Hello, @EvgenyKarkan.

How about adding section with similar repositories? I think this growing one is a good candiate to start section.

I haven't been doing anything on this algorithms topic during these latest months because of almost entire focus on patterns/architecture area so no contributions 😄 Anyway I like it a lot that we created and now have this basic base of algorithms just in case if a need in some of them raises! Good work!

Thanks,

Stanislaw

EKAlgorithmsExamples bug.

Please fix:

EKAlgorithmsExamples crashes (XCode 5.1.1, OS 10.9): main.m, line 72, message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil. Or, did you forget to nil-terminate your parameter list?'

[oneArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"EKAlgorithms100", nil]];

should be:

[oneArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"EKAlgorithms100", someKey, nil]];

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.