Skip to content

Instantly share code, notes, and snippets.

View tannaurus's full-sized avatar
🏠
Working from home

Tanner Gill tannaurus

🏠
Working from home
View GitHub Profile
//Iterative versions of https://gist.github.com/tparveen/edddf988ec68ef6bb74cff9d1284d09d
//Exercise 1 - Counting Sheep
//Write an iterative algorithm that counts how many sheep jumps over the fence. Your program should take a number
//as an input. That number should be the number of sheep you have. The program should diplay the number along
//with the msg "Another sheep jumps over the fence" until no more sheep left.
function countSheepLoop(num){
for(let i=num; i>0; i--){
console.log(`counting sheeps ${i}`);
//For each one these exercises identify the Big O. Once you have done so, put a counter
//variable and now check to see how the counter related to understanding the Big O for
//each of these algorithms.
/*=================================================================================
/*
Your task is to step through the code thoughly with
the input provided. You should be able to describe what is happening in each step.
Identify the Big O of this algorithm and be able to explain your answer.
Finally use a counter to show how your the counter can be helpful in understanding the