Skip to content

Commit f0cb3cc

Browse files
committed
initial commit
0 parents  commit f0cb3cc

File tree

31 files changed

+265
-0
lines changed

31 files changed

+265
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vs/
2+
Build/

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# CMakeList.txt : CMake project for DataStructures_Algorithms, include source and define
2+
# project specific logic here.
3+
#
4+
cmake_minimum_required (VERSION 3.8)
5+
6+
# Enable Hot Reload for MSVC compilers if supported.
7+
if (POLICY CMP0141)
8+
cmake_policy(SET CMP0141 NEW)
9+
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
10+
endif()
11+
12+
project ("DataStructures_Algorithms")
13+
14+
set(CMAKE_CXX_STANDARD 14)
15+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
16+
17+
include_directories(${CMAKE_SOURCE_DIR}/Headers)
18+
19+
add_subdirectory(Headers)
20+
add_subdirectory(SourceCodes)
21+
22+
include(FetchContent)
23+
FetchContent_Declare(
24+
googletest
25+
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
26+
)
27+
# For Windows: Prevent overriding the parent project's compiler/linker settings
28+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
29+
30+
enable_testing()
31+
32+
add_subdirectory(Tests)

CMakePresets.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "windows-base",
6+
"hidden": true,
7+
"generator": "Ninja",
8+
"binaryDir": "${sourceDir}/Build/build/${presetName}",
9+
"installDir": "${sourceDir}/Build/install/${presetName}",
10+
"cacheVariables": {
11+
"CMAKE_C_COMPILER": "cl.exe",
12+
"CMAKE_CXX_COMPILER": "cl.exe"
13+
},
14+
"condition": {
15+
"type": "equals",
16+
"lhs": "${hostSystemName}",
17+
"rhs": "Windows"
18+
}
19+
},
20+
{
21+
"name": "x64-debug",
22+
"displayName": "x64 Debug",
23+
"inherits": "windows-base",
24+
"architecture": {
25+
"value": "x64",
26+
"strategy": "external"
27+
},
28+
"cacheVariables": {
29+
"CMAKE_BUILD_TYPE": "Debug"
30+
}
31+
},
32+
{
33+
"name": "x64-release",
34+
"displayName": "x64 Release",
35+
"inherits": "x64-debug",
36+
"cacheVariables": {
37+
"CMAKE_BUILD_TYPE": "Release"
38+
}
39+
},
40+
{
41+
"name": "x86-debug",
42+
"displayName": "x86 Debug",
43+
"inherits": "windows-base",
44+
"architecture": {
45+
"value": "x86",
46+
"strategy": "external"
47+
},
48+
"cacheVariables": {
49+
"CMAKE_BUILD_TYPE": "Debug"
50+
}
51+
},
52+
{
53+
"name": "x86-release",
54+
"displayName": "x86 Release",
55+
"inherits": "x86-debug",
56+
"cacheVariables": {
57+
"CMAKE_BUILD_TYPE": "Release"
58+
}
59+
}
60+
]
61+
}

Headers/0001_Basics/CMakeLists.txt

Whitespace-only changes.

Headers/0001_Basics/Node.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
class Node
4+
{
5+
public:
6+
int value;
7+
Node();
8+
};

Headers/0002_Tree/CMakeLists.txt

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
3+
#include<map>
4+
#include<list>
5+
using namespace std;
6+
enum color { WHITE, GRAY, BLACK };
7+
class Node
8+
{
9+
public:
10+
char data;
11+
int distance;
12+
int color;
13+
Node* parent;
14+
Node(char val);
15+
};
16+
17+
class CompareNodes
18+
{
19+
public:
20+
bool operator()(Node* temp_u, Node* temp_v);
21+
};
22+
23+
class BFSGraph
24+
{
25+
private:
26+
map<Node*, list<Node*>, CompareNodes> adjlist;
27+
list<Node*> node_list;
28+
Node* find_node_in_list(char val);
29+
void graph_bfs(Node* node);
30+
public:
31+
void push_edge(char val_u, char val_v);
32+
void show_graph_data();
33+
void bfs(char val);
34+
void show_bfs_result();
35+
};

Headers/0003_Graph/CMakeLists.txt

Whitespace-only changes.

Headers/0004_GreedyAlgorithms/CMakeLists.txt

Whitespace-only changes.

Headers/0005_DynamicProgramming/CMakeLists.txt

Whitespace-only changes.

Headers/0006_BitwiseAlgorithms/CMakeLists.txt

Whitespace-only changes.

Headers/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_subdirectory(0001_Basics)
2+
add_subdirectory(0002_Tree)
3+
add_subdirectory(0003_Graph)
4+
add_subdirectory(0004_GreedyAlgorithms)
5+
add_subdirectory(0005_DynamicProgramming)
6+
add_subdirectory(0006_BitwiseAlgorithms)

README.md

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Specify the source files
2+
set(0001BASICS_SOURCES
3+
Node.cc
4+
)
5+
6+
# Create a library target
7+
add_library(0001Basics ${0001BASICS_SOURCES})

SourceCodes/0001_Basics/Node.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "../Headers/0001_Basics/Node.h"
2+
using namespace std;
3+
4+
Node::Node()
5+
{
6+
value = 8;
7+
}

SourceCodes/0002_Tree/CMakeLists.txt

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "../Headers/0003_Graph/0001_BreadthFirstSearch.h"
2+
using namespace std;
3+
4+
Node::Node(char val)
5+
{
6+
this->data = val;
7+
distance = INT_MAX;
8+
color = WHITE;
9+
parent = NULL;
10+
}
11+
12+
bool CompareNodes::operator()(Node* temp_u, Node* temp_v)
13+
{
14+
return (temp_u->data < temp_v->data);
15+
}

SourceCodes/0003_Graph/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Specify the source files
2+
set(0003GRAPH_SOURCES
3+
0001_BreadthFirstSearch.cc
4+
)
5+
6+
# Create a library target
7+
add_library(0003GRAPH ${0003GRAPH_SOURCES})

SourceCodes/0004_GreedyAlgorithms/CMakeLists.txt

Whitespace-only changes.

SourceCodes/0005_DynamicProgramming/CMakeLists.txt

Whitespace-only changes.

SourceCodes/0006_BitwiseAlgorithms/CMakeLists.txt

Whitespace-only changes.

SourceCodes/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_subdirectory(0001_Basics)
2+
add_subdirectory(0002_Tree)
3+
add_subdirectory(0003_Graph)
4+
add_subdirectory(0004_GreedyAlgorithms)
5+
add_subdirectory(0005_DynamicProgramming)
6+
add_subdirectory(0006_BitwiseAlgorithms)

Tests/0001_Basics/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
include(FetchContent)
2+
FetchContent_Declare(
3+
googletest
4+
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
5+
)
6+
# For Windows: Prevent overriding the parent project's compiler/linker settings
7+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
8+
FetchContent_MakeAvailable(googletest)
9+
10+
11+
enable_testing()
12+
13+
add_executable(
14+
0001-Basics-Tests
15+
NodeTest.cc)
16+
17+
target_link_libraries(
18+
0001-Basics-Tests
19+
GTest::gtest_main
20+
)
21+
22+
target_link_libraries(
23+
0001-Basics-Tests
24+
0001Basics
25+
)
26+
27+
28+
include(GoogleTest)
29+
gtest_discover_tests(0001-Basics-Tests)

Tests/0001_Basics/NodeTest.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <gtest/gtest.h>
2+
#include "../Headers/0001_Basics/Node.h"
3+
4+
// Demonstrate some basic assertions.
5+
namespace NodeTesting
6+
{
7+
TEST(TestingNodeValue, PositiveTestCase) {
8+
// Expect two strings not to be equal.
9+
Node* temp = new Node();
10+
EXPECT_EQ(temp->value, 8);
11+
EXPECT_STRNE("hello", "world");
12+
// Expect equality.
13+
EXPECT_EQ(2 * 4, 8);
14+
}
15+
}

Tests/0002_Tree/CMakeLists.txt

Whitespace-only changes.

Tests/0003_Graph/0001_BreadthFirstSearchTest.cc

Whitespace-only changes.

Tests/0003_Graph/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
include(FetchContent)
2+
FetchContent_Declare(
3+
googletest
4+
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
5+
)
6+
# For Windows: Prevent overriding the parent project's compiler/linker settings
7+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
8+
FetchContent_MakeAvailable(googletest)
9+
10+
11+
enable_testing()
12+
13+
add_executable(
14+
0003-Graph-Tests
15+
0001_BreadthFirstSearchTest.cc)
16+
17+
target_link_libraries(
18+
0003-Graph-Tests
19+
GTest::gtest_main
20+
)
21+
22+
target_link_libraries(
23+
0003-Graph-Tests
24+
0003GRAPH
25+
)
26+
27+
28+
include(GoogleTest)
29+
gtest_discover_tests(0003-Graph-Tests)

Tests/0004_GreedyAlgorithms/CMakeLists.txt

Whitespace-only changes.

Tests/0005_DynamicProgramming/CMakeLists.txt

Whitespace-only changes.

Tests/0006_BitwiseAlgorithms/CMakeLists.txt

Whitespace-only changes.

Tests/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_subdirectory(0001_Basics)
2+
add_subdirectory(0002_Tree)
3+
add_subdirectory(0003_Graph)
4+
add_subdirectory(0004_GreedyAlgorithms)
5+
add_subdirectory(0005_DynamicProgramming)
6+
add_subdirectory(0006_BitwiseAlgorithms)

0 commit comments

Comments
 (0)