topic 25 - more array algorithms 1 "to excel in java, or any computer language, you want to...

4
Topic 25 - more array algorithms 1 in Java, or any computer language, you want to buil e "large" and "small". By "large" I mean the sweepi issues of algorithms, data structures, ... what we ly as a degree in Computer Science. You also need s all" -- 10 or 20 line methods built of loops, logic to solve each piece of the larger problem. Working n my office hours, I see what an advantage it is fo ho are practiced and quick with their method code. the method code allows you to concentrate on the l he problem. Or put another other way, someone who with the loops, logic, etc. does not have time for ues." lante niversity, Google

Upload: audra-lawrence

Post on 13-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Topic 25 - more array algorithms 1 "To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean

Topic 25 - more array algorithms

1

"To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean the sweeping, strategic issues of algorithms, data structures, ... what we think of basically as a degree in Computer Science. You also need skill in the "small" -- 10 or 20 line methods built of loops, logic, strings, lists etc. to solve each piece of the larger problem. Working with students in my office hours, I see what an advantage it is for students who are practiced and quick with their method code. Skill with the method code allows you to concentrate on the larger parts of the problem. Or put another other way, someone who struggles with the loops, logic, etc. does not have time for the larger issues." - Nick ParlanteStanford University, Google

Page 2: Topic 25 - more array algorithms 1 "To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean

More array problems write a method to change an array to a sub-

array, similar to substring method– does initial version work?

"rotate" elements in an array a given amount determine how many elements in an array of

Strings variables are set to null determine if the elements in an array of ints

or doubles are in sorted ascending order

2

Page 3: Topic 25 - more array algorithms 1 "To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean

More array problems shuffle an array determine the longest run length in array of

characters (longest run of all characters the same)

ensure all elements in an array are within a given range

given an array with ints 1 to N determine if there are any duplicates in the array

3

Page 4: Topic 25 - more array algorithms 1 "To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean

More array problems given an array, create and return an array the

same as the original expect all duplicates are removed

implement the sieve of Eratosthenes to find prime numbers

We'll say that an element in an array is "alone" if there are values before and after it, and those values are different from it. Return a version of the given array where every instance of the given value which is alone is replaced by whichever value to its left or right is larger. (from coding bat)

4