Skip to content

Conversation

@jherna37
Copy link

My native programming language is Java and I am new to swift. To the best of my knowledge I have translated from Java to Swift. Thanks for the opportunity and don't be afraid to hurt my feelings. I'm open to any feedback. This was merely the first step of many.

@hollance
Copy link
Member

hollance commented Mar 1, 2016

Swift 3.0 is going to come out later this year and it removes this kind of for loop:

for var j = 0; j < array.count; j++

I also think you can get rid of the if i + 1 < count line if you make the loop for i go from 0 to count-1.

You can swap two array elements in Swift with: swap(&a[i], &a[j]), so no need to use a temporary variable.

It is possible to make the bubble sort a little bit more efficient: if no swap was necessary, then the sort is done and you can exit the loop.

That should give you something to do. ;-)

@hollance
Copy link
Member

@jherna37: Is this something you're willing to work on some more?

@jherna37
Copy link
Author

Hey sorry for the delay. I just finished my mid term exams and haven't had
much time since my first submission to work on it.

On Fri, Mar 18, 2016 at 4:16 AM, Matthijs Hollemans <
notifications@github.com> wrote:

@jherna37 https://github.com/jherna37: Is this something you're willing
to work on some more?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#60 (comment)

@hollance
Copy link
Member

No worries. I'll just leave this open until you get a chance to work on it again.

@jherna37
Copy link
Author

Just for clarification, would you like me to implement this algorithm without the use of for loops?

@hollance
Copy link
Member

You can still use for loops, but it must be for in, not for var i = ...; ... ; ... since the latter is now deprecated in Swift.

@jherna37
Copy link
Author

jherna37 commented Apr 6, 2016

I've made the changes to the code. I was wondering if instead of radix sort you'd be open to more algorithm interview questions. I have a few examples from an interview I just came back from and think they'll make a nice addition.

@hollance
Copy link
Member

hollance commented Apr 7, 2016

Have you actually tried out those changes? I'm pretty sure it doesn't work like that...

Interview questions are very welcome! We already have a few simple ones, but more is better. :-)

@chris-pilcher
Copy link

Hi @jherna37. We're in the process of cleaning up our pull requests.

Would you still like to work on the bubble sort algorithm?

@kelvinlauKL
Copy link
Member

Closing this due to inactivity. @jherna37 feel free to open another PR if you're up for another shot!

@kelvinlauKL kelvinlauKL closed this Jul 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants