Commit 252cf41d authored by Rachel Wil Sha Singh's avatar Rachel Wil Sha Singh 💬
Browse files

Backup

parent c4a368f8
......@@ -15,6 +15,10 @@ class Node
ptrNext = nullptr;
}
Node* ptrPrev;
Node* ptrNext;
T data;
void Display()
{
cout << left
......@@ -22,10 +26,8 @@ class Node
<< setw( 20 ) << ptrPrev
<< setw( 20 ) << ptrNext << endl;
}
T data;
Node* ptrNext;
Node* ptrPrev;
};
#endif
# depslib dependency file v1.0
1600730786 source:/home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/01 Nodes/main.cpp
<iostream>
<iomanip>
<string>
"Node.hpp"
1600730560 /home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/01 Nodes/Node.hpp
<iomanip>
<iostream>
......@@ -2,14 +2,14 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="640" topLine="21" />
<Cursor1 position="1554" topLine="53" />
</Cursor>
</File>
<File name="Node.hpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="Node.hpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="376" topLine="0" />
<Cursor1 position="188" topLine="6" />
</Cursor>
</File>
</CodeBlocks_layout_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="Node.hpp" open="1" top="1" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
......@@ -14,10 +14,10 @@ void OneNode()
<< setw( 20 ) << "next" << endl;
cout << "----------------------------------------------" << endl;
Node<string> node;
node.data = "one node";
node.Display();
Node<string>* node = new Node<string>;
node->data = "first";
node->Display();
delete node;
}
void TwoNodes()
......@@ -29,16 +29,20 @@ void TwoNodes()
<< setw( 20 ) << "next" << endl;
cout << "----------------------------------------------" << endl;
Node<string> node1, node2;
node1.data = "first";
node2.data = "second";
Node<string>* node1 = new Node<string>;
Node<string>* node2 = new Node<string>;
node1->data = "first";
node2->data = "second";
node1.ptrNext = &node2;
node1->ptrNext = node2;
node2->ptrPrev = node1;
node2.ptrPrev = &node1;
node1->Display();
node2->Display();
node1.Display();
node2.Display();
delete node1;
delete node2;
}
void ThreeNodes()
......@@ -50,21 +54,28 @@ void ThreeNodes()
<< setw( 20 ) << "next" << endl;
cout << "----------------------------------------------" << endl;
Node<string> node1, node2, node3;
node1.data = "first";
node2.data = "second";
node3.data = "third";
Node<string>* node1 = new Node<string>;
Node<string>* node2 = new Node<string>;
Node<string>* node3 = new Node<string>;
node1->data = "first";
node2->data = "second";
node3->data = "third";
node1->ptrNext = node2;
node1.ptrNext = &node2;
node2->ptrPrev = node1;
node2->ptrNext = node3;
node2.ptrPrev = &node1;
node2.ptrNext = &node3;
node3->ptrPrev = node2;
node3.ptrPrev = &node2;
node1->Display();
node2->Display();
node3->Display();
node1.Display();
node2.Display();
node3.Display();
delete node1;
delete node2;
delete node3;
}
int main()
......
......@@ -62,3 +62,55 @@
"timer.hpp"
"animal.hpp"
1593110188 source:/home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/parser.cpp
"parser.hpp"
1593110061 /home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/parser.hpp
<iostream>
<fstream>
<string>
<vector>
"timer.hpp"
"animal.hpp"
1593786127 /home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/timer.hpp
<chrono>
1593111584 /home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/animal.hpp
<string>
1593109727 source:/home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/search.cpp
"search.hpp"
1593110098 /home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/search.hpp
<string>
<vector>
"animal.hpp"
1593111599 source:/home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/sort.cpp
"sort.hpp"
<iostream>
"menu.hpp"
1593111257 /home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/sort.hpp
<vector>
<string>
"animal.hpp"
1593108496 /home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/menu.hpp
<iostream>
<string>
<vector>
<cstdlib>
<limits>
1593786127 source:/home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/animal.cpp
"animal.hpp"
<iostream>
1595878886 source:/home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/class-stuff/2020-09-21/02 CS200 SearchSortLab/main.cpp
"search.hpp"
"sort.hpp"
"parser.hpp"
"menu.hpp"
......@@ -2,59 +2,59 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="parser.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="sort.hpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1273" topLine="30" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="sort.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="sort.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1909" topLine="51" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="timer.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="timer.hpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="192" topLine="5" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="animal.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="136" topLine="12" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="search.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="search.hpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="115" topLine="0" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="animal.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="parser.hpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1147" topLine="27" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="parser.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="main.cpp" open="1" top="1" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="39" topLine="0" />
<Cursor1 position="450" topLine="15" />
</Cursor>
</File>
<File name="sort.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="animal.hpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="menu.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="search.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3340" topLine="136" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="animal.hpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="menu.hpp" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="39" topLine="0" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="search.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="parser.cpp" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="670" topLine="0" />
<Cursor1 position="188" topLine="12" />
</Cursor>
</File>
</CodeBlocks_layout_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="sort.hpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="sort.cpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="timer.hpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="animal.cpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="search.hpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="parser.hpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="1" top="1" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="animal.hpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="search.cpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="menu.hpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="parser.cpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Fibonacci Iterative vs Recursive" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/Fibonacci Iterative vs Recursive" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/Fibonacci Iterative vs Recursive" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="fib.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Fibonacci Iterative vs Recursive" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/Fibonacci Iterative vs Recursive" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/Fibonacci Iterative vs Recursive" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="fib.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>
# depslib dependency file v1.0
1600701833 source:/home/wilsha/RACHEL/_ADULTING/TEACHING/PUBLIC/cs250-basic-data-structures-with-cpp/example-code/Algorithm Efficiency/Fibonacci Iterative vs Recursive/fib.cpp
<iostream>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="fib.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="37" />
</Cursor>
</File>
</CodeBlocks_layout_file>
#include <iostream>
using namespace std;
int GetFib_Iterative( int n, int& iters )
{
if ( n == 0 || n == 1 )
{
return 1;
}
int n_prev2 = 1; // F[n-2]
int n_prev1 = 1; // F[n-1]
int ni; // F[n]
for ( int i = 2; i <= n; i++ )
{
// F[n] = F[n-2] + F[n-1]
ni = n_prev2 + n_prev1;
// F[n-2] = F[n-1]
n_prev2 = n_prev1;
// F[n-1] = F[n]
n_prev1 = ni;
// Keep track of amount of iterations
iters++;
}
return ni;
}
int GetFib_Recursive( int n, int& iters )
{
if ( n == 0 || n == 1 ) { return 1; }
else
{
iters++;
// F[n] = F[n-2] + F[n-1]
int ni = GetFib_Recursive( n-2, iters ) + GetFib_Recursive( n-1, iters );
return ni;
}
}
int main()
{
bool done = false;
while ( !done )
{
int iterativeIterations = 0;
int recursiveIterations = 0;
int n;
cout << "Enter n: ";
cin >> n;
cout << GetFib_Iterative( n, iterativeIterations )
<< "\t Total iterations: " << iterativeIterations << endl;
cout << GetFib_Recursive( n, recursiveIterations )
<< "\t Total iterations: " << recursiveIterations << endl;
}
return 0;
}
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Growth Rates" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/Growth Rates" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/Growth Rates" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>