Challenges/ReverseArray/ReverseArray/Program.cs
/// <summary>
/// Reveres an array with the instatiation of a new array creating additional space 
/// Time: O (n) for the iteration of the array n times
/// Space: O (n) Additional space is create/insertion of array for the length of the new array
/// </summary>
Reveres an array with the instatiation of a new array creating additional space
Time: O (n) for the iteration of the array n times
Space: O (n) Additional space is create/insertion of array for the length of the new array
Reveres an array with the instatiation of a new array creating additional space Time : O ( n ) for the iteration of the array n times Space : O ( n ) Additional space is create / insertion of array for the length of the new array
static void ReverseArray1()
        {
            string[] locations = { "alki beach", "capital hill", "queene anne", "belltown" };
            Console.WriteLine("Input array 1:");
            foreach (string i in locations)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine(" ");
            string[] reversed = new string[locations.Length];
            int counter = 0;
            for(int i = locations.Length-1; i >= 0; i--)
            {
                reversed[counter] = locations[i];
                counter++;
            }
            Console.WriteLine("This is the reverese if input array 1 using brute force:");
            foreach (string item in reversed)
            {
                Console.WriteLine(item);
            }
        }
static void ReverseArray1 ( ) { string [ ] locations = { " " , " " , " " , " " } ; Console . WriteLine ( " " ) ; foreach ( string i in locations ) { Console . WriteLine ( i ) ; } Console . WriteLine ( " " ) ; string [ ] reversed = new string [ locations . Length ] ; int counter = 0 ; for ( int i = locations . Length - 1 ; i >= 0 ; i -- ) { reversed [ counter ] = locations [ i ] ; counter ++ ; } Console . WriteLine ( " " ) ; foreach ( string item in reversed ) { Console . WriteLine ( item ) ; } }
Reveres an array with the instatiation of a new array creating additional space
Time: O (n) for the iteration of the array n times
Space: O (n) Additional space is create/insertion of array for the length of the new array
Reveres an array with the instatiation of a new array creating additional space Time : O ( n ) for the iteration of the array n times Space : O ( n ) Additional space is create / insertion of array for the length of the new array
//hard coded input string //instatiate new array adds additional space //intatiate counter //iterate string with for loop for (variable initialization; condition; steps)