GithubHelp home page GithubHelp logo

cmsi-281's Introduction

Assignment 5

Fibonacci

The fibonnaci sequence runs using recursion and returns the nth element. It is written similiar to the mathematical definition and has a private helper method to help it start.

Multiply Without Adding

The multiply without adding recursion just uses basic addition to add two numbers, without getting too fancy like the Russian Peasant's Algorithm. It checks for the largest and continues to this number including until the smaller number hits one, which is the base case.

String to Integer

String to Integer converts the String to a char array and passes it through recursion. I chose this method over using String's method of substring for a performance reason. Each newly passed substring to the recursive call creates a new immutable String, I believe it easier just use a charr array and keep track of the index. The recursive essentially grabs each char in the array and converts it to Base 10 using the index it is currently at. ( Assuming no leading zero magic)

Stack Parenthesis Checker

The stack parenthesis checker uses the Java stack to check for a balanced parenthesis. If the brace is open then it is pushed, if it closed then the stack is popped and checked with the current parenthesis if it is a matching brace, if this fails then it is not a balanced parenthesis. As in the simplified example below checking open parenthesis against a closed bracket and etc; assuming pop is the popped string off of the stack

	switch(pop){
		
		case "(":
		
		if(now.equals("]")){
			return false;
			}
			else{
				continue;
			}
		}

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.