Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

☕ Exercise solutions for chapter 1.1 written in Java

NotificationsYou must be signed in to change notification settings

dev-xero/java-algorithms-exercise-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

☕ Exercise solutions for chapter 1.1 written in Java

Algorithms Implemented

  1. isBetweenZeroAndOne()
  2. toBinaryString()
  3. printTwoDmBooleanArray()
  4. printTwoDmIntArray()
  5. printIntArray()
  6. matrixTransposition()
  7. lg()
  8. Fibonacci.Fib()
  9. Fibonnaci.FastFib()
  10. fact()
  11. binarySearch()
  12. bruteForceSearch()

Code Examples

We are asked in exercise (1.1.19) to improve the fib method to use some sort of cache. This one is particularly interesting because it runs in O(1) time provided that the cache contains the previous two sequences. Generating the previous sequences is done using loops.

// dynamic programming and memoizationpublicstaticlongFastFib(intN,HashMap<Integer,Long>cache) {if (N ==0) {cache.put(N,0L);return0;        }if (N ==1) {cache.put(N,1L);return1;        }cache.put(N,cache.get(N -2) +cache.get(N -1));returncache.get(N);    }

Python Implementation

I've implemented the same methods but in Python overhere, if you're interested.

About

☕ Exercise solutions for chapter 1.1 written in Java

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp